Skip to content

Commit

Permalink
T350879: Special Property: Item (#513)
Browse files Browse the repository at this point in the history
* Special Property Item

* Run without Pause

* Iterate

* Iterate Await

* Unused

* Just

* Types

* Notes
  • Loading branch information
RickiJay-WMDE authored Nov 29, 2023
1 parent d7ff487 commit ab8e626
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 15 deletions.
6 changes: 6 additions & 0 deletions test/helpers/types/wikibase-property-type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type WikibasePropertyType = {
name: string;
urlName: string;
};

export default WikibasePropertyType;
25 changes: 25 additions & 0 deletions test/helpers/wikibase-property-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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'
};

// OTHER TYPES:
// 'Commons media file',
// 'EDTF Date/Time',
// 'Entity Schema',
// 'External identifier',
// 'Geographic coordinates',
// 'Geographic shape',
// 'Media file',
// 'Monolingual text',
// 'Point in time',
// 'Property',
// 'Quantity',
// 'Tabular data',
// 'URL'
61 changes: 46 additions & 15 deletions test/specs/repo/special-property.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,69 @@
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 = [ wikibasePropertyItem, wikibasePropertyString ];

describe( 'Special:NewProperty', function () {
it( 'Should be able to create a new property', async () => {
await SpecialNewProperty.open( 'string' );
// eslint-disable-next-line mocha/no-setup-in-describe
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 label' );
await SpecialNewProperty.descriptionInput.setValue( 'Cool description' );
await SpecialNewProperty.aliasesInput.setValue( 'Great job!|Bra Jobbat' );
await SpecialNewProperty.submit();
await SpecialNewProperty.labelInput.setValue(
`Cool ${dataType.name} label`
);
await SpecialNewProperty.descriptionInput.setValue(
`Cool ${dataType.name} description`
);
await SpecialNewProperty.aliasesInput.setValue(
`Great ${dataType.name}!|Greatest ${dataType.name}!`
);

await SpecialNewProperty.datatypeInput.click();
await $( 'oo-ui-menuSelectWidget' );
await $( `.oo-ui-labelElement-label=${dataType.name}` ).click();

await SpecialNewProperty.submit();

const dataTypeText = await $(
'.wikibase-propertyview-datatype-value'
).getText();
assert.strictEqual( dataTypeText, 'String' );
const dataTypeText = await $(
'.wikibase-propertyview-datatype-value'
).getText();
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
// eslint-disable-next-line wdio/no-pause
await browser.pause( 1100 );

await SpecialListProperties.openParams( { limit: 1000 } );
await SpecialListProperties.openParams( {
dataType: wikibasePropertyString.urlName,
limit: 1000
} );
const numberOfPropertiesAfter =
await SpecialListProperties.properties.length;

Expand Down

0 comments on commit ab8e626

Please sign in to comment.