Skip to content

Commit 6b7bea9

Browse files
jenkins-botGerrit Code Review
authored andcommitted
Merge "Fix edit display for no-value and unknown snaktypes"
2 parents 63b32a4 + 05e3669 commit 6b7bea9

File tree

2 files changed

+47
-41
lines changed

2 files changed

+47
-41
lines changed

repo/resources/wikibase.wbui2025/wikibase.wbui2025.editableSnakValue.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
>
1515
<cdx-text-input v-if="!valueStrategy.isLookupDatatype() && snakTypeSelection === 'value'" v-model.trim="textvalue"></cdx-text-input>
1616
<cdx-lookup
17-
v-else-if="valueStrategy.isLookupDatatype()"
17+
v-else-if="valueStrategy.isLookupDatatype() && snakTypeSelection === 'value'"
1818
v-model:selected="lookupSelection"
1919
v-model:input-value="lookupInputValue"
2020
:menu-items="lookupMenuItems"

repo/tests/jest/wikibase.wbui2025.editableSnakValue.spec.js

Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -252,49 +252,55 @@ describe( 'wikibase.wbui2025.editableSnakValue', () => {
252252
} );
253253
} );
254254

255-
describe( 'the mounted component with a novalue statement', () => {
256-
let wrapper, textInput, noValueSomeValuePlaceholder;
257-
beforeEach( async () => {
258-
const testPropertyId = 'P1';
259-
const testNoValueStatementId = 'Q1$98ce7596-5188-4218-9195-6d9ccdcc82bd';
260-
const testNoValueStatement = {
261-
id: testNoValueStatementId,
262-
mainsnak: {
263-
hash: 'placeholder-hash',
264-
snaktype: 'novalue',
265-
datatype: 'string'
266-
},
267-
rank: 'normal'
268-
};
269-
270-
const testingPinia = storeWithStatements( [ testNoValueStatement ] );
271-
const editStatementsStore = useEditStatementsStore();
272-
await editStatementsStore.initializeFromStatementStore( [ testNoValueStatement.id ], testPropertyId );
273-
const editStatementStore = useEditStatementStore( testNoValueStatementId )();
274-
275-
wrapper = await mount( editableSnakValueComponent, {
276-
props: {
277-
propertyId: testPropertyId,
278-
snakKey: editStatementStore.mainSnakKey
279-
},
280-
global: {
281-
plugins: [ testingPinia ]
282-
}
255+
describe.each(
256+
[ 'string', 'tabular-data', 'geo-shape' ]
257+
)( 'the mounted component with %s datatype', ( datatype ) => {
258+
describe.each(
259+
[ 'novalue', 'somevalue' ]
260+
)( 'and %s snaktype', ( snaktype ) => {
261+
262+
let wrapper, textInput, noValueSomeValuePlaceholder;
263+
beforeEach( async () => {
264+
const testPropertyId = 'P1';
265+
const testNoValueStatementId = 'Q1$98ce7596-5188-4218-9195-6d9ccdcc82bd';
266+
const testNoValueStatement = {
267+
id: testNoValueStatementId,
268+
mainsnak: {
269+
hash: 'placeholder-hash',
270+
snaktype,
271+
datatype
272+
},
273+
rank: 'normal'
274+
};
275+
276+
const testingPinia = storeWithStatements( [ testNoValueStatement ] );
277+
const editStatementsStore = useEditStatementsStore();
278+
await editStatementsStore.initializeFromStatementStore( [ testNoValueStatement.id ], testPropertyId );
279+
const editStatementStore = useEditStatementStore( testNoValueStatementId )();
280+
281+
wrapper = await mount( editableSnakValueComponent, {
282+
props: {
283+
propertyId: testPropertyId,
284+
snakKey: editStatementStore.mainSnakKey
285+
},
286+
global: {
287+
plugins: [ testingPinia ]
288+
}
289+
} );
290+
await wrapper.vm.$nextTick();
291+
textInput = wrapper.findComponent( CdxTextInput );
292+
noValueSomeValuePlaceholder = wrapper.find( 'div.wikibase-wbui2025-novalue-somevalue-holder' );
283293
} );
284-
await wrapper.vm.$nextTick();
285-
textInput = wrapper.findComponent( CdxTextInput );
286-
noValueSomeValuePlaceholder = wrapper.find( 'div.wikibase-wbui2025-novalue-somevalue-holder' );
287-
} );
288294

289-
it( 'mount its child components', () => {
290-
expect( wrapper.exists() ).toBe( true );
291-
expect( textInput.exists() ).toBe( false );
292-
expect( noValueSomeValuePlaceholder.exists() ).toBe( true );
293-
} );
295+
it( 'mount its child components', () => {
296+
expect( wrapper.exists() ).toBe( true );
297+
expect( textInput.exists() ).toBe( false );
298+
expect( noValueSomeValuePlaceholder.exists() ).toBe( true );
299+
} );
294300

295-
it( 'loads and shows data correctly', () => {
296-
expect( noValueSomeValuePlaceholder.text() ).toContain( 'wikibase-snakview-variations-novalue-label' );
301+
it( 'loads and shows data correctly', () => {
302+
expect( noValueSomeValuePlaceholder.text() ).toContain( `wikibase-snakview-variations-${ snaktype }-label` );
303+
} );
297304
} );
298305
} );
299-
300306
} );

0 commit comments

Comments
 (0)