diff --git a/test/helpers/types/wikibase-property-type.ts b/test/helpers/types/wikibase-property-type.ts new file mode 100644 index 000000000..01a6be206 --- /dev/null +++ b/test/helpers/types/wikibase-property-type.ts @@ -0,0 +1,6 @@ +type WikibasePropertyType = { + name: string; + urlName: string; +}; + +export default WikibasePropertyType; diff --git a/test/helpers/wikibase-property-types.ts b/test/helpers/wikibase-property-types.ts new file mode 100644 index 000000000..dd0aed406 --- /dev/null +++ b/test/helpers/wikibase-property-types.ts @@ -0,0 +1,10 @@ +import WikibasePropertyType from './types/wikibase-property-type.js'; + +export const wikibasePropertyItem: WikibasePropertyType = { + name: 'Item', + urlName: 'wikibase-item' +}; +export const wikibasePropertyString: WikibasePropertyType = { + name: 'String', + urlName: 'string' +}; diff --git a/test/specs/repo/property.ts b/test/specs/repo/property.ts index 233198d4f..20ef43810 100644 --- a/test/specs/repo/property.ts +++ b/test/specs/repo/property.ts @@ -6,19 +6,28 @@ import { Reference, SpecialEntityData } from '../../helpers/types/request-response.js'; +import WikibasePropertyType from '../../helpers/types/wikibase-property-type.js'; +import { + wikibasePropertyItem, + wikibasePropertyString +} from '../../helpers/wikibase-property-types.js'; -const dataTypes = [ 'string' ]; +const dataTypes = [ + wikibasePropertyItem, + wikibasePropertyString +]; const propertyIdSelector = ( id: string ): string => `=${id} (${id})`; // =P1 (P1) describe( 'Property', () => { // eslint-disable-next-line mocha/no-setup-in-describe - dataTypes.forEach( ( dataType: string ) => { - describe( `Should be able to work with type ${dataType}`, () => { + dataTypes.forEach( ( dataType: WikibasePropertyType ) => { + // eslint-disable-next-line mocha/no-setup-in-describe + describe( `Should be able to work with type ${dataType.name}`, () => { let propertyId: string = null; before( async () => { - propertyId = await WikibaseApi.getProperty( dataType ); + propertyId = await WikibaseApi.getProperty( dataType.urlName ); } ); it( 'Should be able to add statement to property', async () => { @@ -37,7 +46,7 @@ describe( 'Property', () => { await Property.open( propertyId ); } ); - it( `Should be able to add reference to property of type ${dataType}`, async () => { + it( `Should be able to add reference to property of type ${dataType.name}`, async () => { await Property.open( propertyId ); await Property.addReference.click(); diff --git a/test/specs/repo/special-property.ts b/test/specs/repo/special-property.ts index ffc17e20f..d8ce10b98 100644 --- a/test/specs/repo/special-property.ts +++ b/test/specs/repo/special-property.ts @@ -1,67 +1,68 @@ import assert from 'assert'; import SpecialListProperties from '../../helpers/pages/special/list-properties.page.js'; import SpecialNewProperty from '../../helpers/pages/special/new-property.page.js'; +import WikibasePropertyType from '../../helpers/types/wikibase-property-type.js'; +import { + wikibasePropertyItem, + wikibasePropertyString +} from '../../helpers/wikibase-property-types.js'; -const dataTypes = [ - // 'Commons media file', - // 'EDTF Date/Time', - // 'Entity Schema', - // 'External identifier', - // 'Geographic coordinates', - // 'Geographic shape', - 'Item', - // 'Media file', - // 'Monolingual text', - // 'Point in time', - // 'Property', - // 'Quantity', - 'String' - // 'Tabular data', - // 'URL' -]; +const dataTypes = [ wikibasePropertyItem, wikibasePropertyString ]; describe( 'Special:NewProperty', function () { // eslint-disable-next-line mocha/no-setup-in-describe - dataTypes.forEach( ( dataType: string ) => { - it( `Should be able to create a new property of datatype ${dataType}`, async () => { + dataTypes.forEach( ( dataType: WikibasePropertyType ) => { + it( `Should be able to create a new property of datatype ${dataType.name}`, async () => { await SpecialNewProperty.open(); - await SpecialNewProperty.labelInput.setValue( `Cool ${dataType} label` ); + await SpecialNewProperty.labelInput.setValue( + `Cool ${dataType.name} label` + ); await SpecialNewProperty.descriptionInput.setValue( - `Cool ${dataType} description` + `Cool ${dataType.name} description` ); await SpecialNewProperty.aliasesInput.setValue( - `Great ${dataType}!|Greatest ${dataType}!` + `Great ${dataType.name}!|Greatest ${dataType.name}!` ); await SpecialNewProperty.datatypeInput.click(); await $( 'oo-ui-menuSelectWidget' ); - await $( `.oo-ui-labelElement-label=${dataType}` ).click(); + await $( `.oo-ui-labelElement-label=${dataType.name}` ).click(); await SpecialNewProperty.submit(); const dataTypeText = await $( '.wikibase-propertyview-datatype-value' ).getText(); - assert.strictEqual( dataTypeText, dataType ); + assert.strictEqual( dataTypeText, dataType.name ); } ); } ); it( 'Should be able to see newly created properties in list of properties special page', async () => { - await SpecialListProperties.openParams( { limit: 1000 } ); + await SpecialListProperties.openParams( { + dataType: wikibasePropertyString.urlName, + limit: 1000 + } ); const numberOfPropertiesBefore = await SpecialListProperties.properties.length; - await SpecialNewProperty.open( 'string' ); - await SpecialNewProperty.labelInput.setValue( 'Property type string' ); - await SpecialNewProperty.descriptionInput.setValue( 'A string property' ); + await SpecialNewProperty.open( wikibasePropertyString.urlName ); + await SpecialNewProperty.labelInput.setValue( + `Property type ${wikibasePropertyString.urlName}` + ); + await SpecialNewProperty.descriptionInput.setValue( + `A ${wikibasePropertyString.urlName} property` + ); await SpecialNewProperty.submit(); // wait for the $wgWBRepoSettings['sharedCacheDuration'] cache to // timeout, so the list of properties reflects the change await browser.pause( 1100 ); - await SpecialListProperties.openParams( { limit: 1000 } ); + await SpecialListProperties.openParams( { + dataType: wikibasePropertyString.urlName, + limit: 1000 + } ); const numberOfPropertiesAfter = await SpecialListProperties.properties.length;