Skip to content

Commit

Permalink
Work
Browse files Browse the repository at this point in the history
  • Loading branch information
RickiJay-WMDE committed Nov 20, 2023
1 parent 28f5cb6 commit e16c1cc
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 34 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;
10 changes: 10 additions & 0 deletions test/helpers/wikibase-property-types.ts
Original file line number Diff line number Diff line change
@@ -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'
};
19 changes: 14 additions & 5 deletions test/specs/repo/property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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();

Expand Down
59 changes: 30 additions & 29 deletions test/specs/repo/special-property.ts
Original file line number Diff line number Diff line change
@@ -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;

Expand Down

0 comments on commit e16c1cc

Please sign in to comment.