diff --git a/src/components/QueryCondition.vue b/src/components/QueryCondition.vue index 66674416..e0321c52 100644 --- a/src/components/QueryCondition.vue +++ b/src/components/QueryCondition.vue @@ -91,9 +91,10 @@ export default Vue.extend( { if ( selectedProperty === null ) { this.$store.dispatch( 'unsetProperty', this.conditionIndex ); return; + } else if ( selectedProperty.datatype === 'wikibase-item' ) { + this.$store.dispatch( 'setSubclasses', { conditionIndex: this.conditionIndex, subclasses: true } ); } - this.$store.dispatch( - 'updateProperty', + this.$store.dispatch( 'updateProperty', { property: selectedProperty, conditionIndex: this.conditionIndex }, ); }, diff --git a/tests/unit/components/QueryCondition.spec.ts b/tests/unit/components/QueryCondition.spec.ts index f87d2e07..76679f75 100644 --- a/tests/unit/components/QueryCondition.spec.ts +++ b/tests/unit/components/QueryCondition.spec.ts @@ -102,6 +102,24 @@ describe( 'QueryCondition.vue', () => { expect( store.dispatch ).toHaveBeenCalledWith( 'updateValue', { value: userInput, conditionIndex } ); } ); + it( 'set subclasses to true when property type is wikibase-item', async () => { + + const property = { label: 'postal code', id: 'P123', datatype: 'wikibase-item' }; + const propertyGetter = () => () => ( property ); + const store = newStore( propertyGetter ); + const conditionIndex = 0; + store.dispatch = jest.fn(); + const wrapper = shallowMount( QueryCondition, { + store, + localVue, + propsData: { + 'condition-index': 0, + }, + } ); + + expect( store.dispatch ).toHaveBeenCalledWith( 'setSubclasses', { subclasses: true, conditionIndex } ); + } ); + it( 'removes current row when the removeCondition button is clicked', async () => { const store = newStore(); const conditionIndex = 0;