Skip to content

Commit

Permalink
T349718 property list test (#493)
Browse files Browse the repository at this point in the history
* test(property-list): reproduce new property not shown issue

* fix: configure cache and wait for it to timeout

* fix: lint

* fix: list of properties page test for more than 50 properties
  • Loading branch information
rti authored Nov 9, 2023
1 parent 54fe727 commit afeba85
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 11 deletions.
1 change: 1 addition & 0 deletions test/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"node/no-missing-import": "off",
"wdio/no-pause": "warn",
"es-x/no-import-meta": "off",
"es-x/no-nullish-coalescing-operators": "off",
"es-x/no-class-fields": "off"
}
}
29 changes: 29 additions & 0 deletions test/helpers/pages/special/list-properties.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Page from '../page.js';
import awaitDisplayed from '../../await-displayed.js';

class SpecialListProperties extends Page {
public get content(): ChainablePromiseElement {
return $( '.mw-spcontent' );
}
public get properties(): ChainablePromiseArray {
return $$( '.mw-spcontent ol li' );
}

public async openParams( params: {
dataType?: string;
limit?: number;
offset?: number;
} ): Promise<void> {
const dataType = 'datatype=' + ( params.dataType ?? '' );
const limit = 'limit=' + ( params.limit ?? 50 );
const offset = 'offset=' + ( params.offset ?? 0 );

await browser.url(
`${process.env.MW_SERVER}/wiki/Special:ListProperties?${dataType}&${limit}&${offset}`
);

await awaitDisplayed( this.content );
}
}

export default new SpecialListProperties();
6 changes: 6 additions & 0 deletions test/helpers/pages/special/new-property.page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import SubmittablePage from '../submittable.page.js';
import awaitDisplayed from '../../await-displayed.js';

class SpecialNewProperty extends SubmittablePage {
public get labelInput(): ChainablePromiseElement {
Expand All @@ -22,6 +23,11 @@ class SpecialNewProperty extends SubmittablePage {
await browser.url(
`${process.env.MW_SERVER}/wiki/Special:NewProperty${dataType}`
);
await awaitDisplayed( this.labelInput );
await awaitDisplayed( this.descriptionInput );
await awaitDisplayed( this.aliasesInput );
await awaitDisplayed( this.datatypeInput );
await awaitDisplayed( this.submitBtn );
}
}

Expand Down
36 changes: 25 additions & 11 deletions test/specs/repo/special-property.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
import assert from 'assert';
import SpecialNewProperty from '../../helpers/pages/special/new-property.page.js';

import awaitDisplayed from '../../helpers/await-displayed.js';
import SpecialListProperties from '../../helpers/pages/special/list-properties.page.js';
import SpecialNewProperty from '../../helpers/pages/special/new-property.page.js';

describe( 'Special:NewProperty', function () {
it( 'Should be able to create a new property', async () => {
await SpecialNewProperty.open( 'string' );

const labelInput = await awaitDisplayed( SpecialNewProperty.labelInput );
await labelInput.setValue( 'Cool label' );

const descriptionInput = await awaitDisplayed( SpecialNewProperty.descriptionInput );
await descriptionInput.setValue( 'Cool description' );

const aliasesInput = await awaitDisplayed( SpecialNewProperty.aliasesInput );
await aliasesInput.setValue( 'Great job!|Bra Jobbat' );

await SpecialNewProperty.labelInput.setValue( 'Cool label' );
await SpecialNewProperty.descriptionInput.setValue( 'Cool description' );
await SpecialNewProperty.aliasesInput.setValue( 'Great job!|Bra Jobbat' );
await SpecialNewProperty.submit();

const propertyviewDatatypeValueEl = await awaitDisplayed(
'.wikibase-propertyview-datatype-value'
);
const dataTypeText = await propertyviewDatatypeValueEl.getText();

assert.strictEqual( dataTypeText, 'String' );
} );

it( 'Should be able to see newly created properties in list of properties special page', async () => {
await SpecialListProperties.openParams( { 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.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 } );
const numberOfPropertiesAfter = await SpecialListProperties.properties.length;

assert.strictEqual( numberOfPropertiesAfter, numberOfPropertiesBefore + 1 );
} );
} );
3 changes: 3 additions & 0 deletions test/suites/repo/LocalSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

// EntitySchema
$wgEntitySchemaShExSimpleUrl = "http://validator.svc";

// Cache for one second only, so tests can see updates
$wgWBRepoSettings['sharedCacheDuration'] = 1;

0 comments on commit afeba85

Please sign in to comment.