From d85f0042d8387c69d3774f5eda358e44ce3a3d79 Mon Sep 17 00:00:00 2001 From: rti Date: Thu, 9 Nov 2023 09:02:36 +0100 Subject: [PATCH] T349718 property list test (#493) * 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 --- test/.eslintrc.json | 1 + .../pages/special/list-properties.page.ts | 29 ++++++++++++++++ .../pages/special/new-property.page.ts | 6 ++++ test/specs/repo/special-property.ts | 33 +++++++++++++------ test/suites/repo/LocalSettings.php | 3 ++ 5 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 test/helpers/pages/special/list-properties.page.ts diff --git a/test/.eslintrc.json b/test/.eslintrc.json index 4566fcf42..a430eaeb4 100644 --- a/test/.eslintrc.json +++ b/test/.eslintrc.json @@ -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" } } diff --git a/test/helpers/pages/special/list-properties.page.ts b/test/helpers/pages/special/list-properties.page.ts new file mode 100644 index 000000000..6eb62d61f --- /dev/null +++ b/test/helpers/pages/special/list-properties.page.ts @@ -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 { + 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(); diff --git a/test/helpers/pages/special/new-property.page.ts b/test/helpers/pages/special/new-property.page.ts index 63ddf58b9..788e9914b 100644 --- a/test/helpers/pages/special/new-property.page.ts +++ b/test/helpers/pages/special/new-property.page.ts @@ -1,4 +1,5 @@ import SubmittablePage from '../submittable.page.js'; +import awaitDisplayed from '../../await-displayed.js'; class SpecialNewProperty extends SubmittablePage { public get labelInput(): ChainablePromiseElement { @@ -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 ); } } diff --git a/test/specs/repo/special-property.ts b/test/specs/repo/special-property.ts index 4ad9c51b2..4ee0dae05 100644 --- a/test/specs/repo/special-property.ts +++ b/test/specs/repo/special-property.ts @@ -1,26 +1,39 @@ import assert from 'assert'; +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 SpecialNewProperty.labelInput; - await labelInput.setValue( 'Cool label' ); - - const descriptionInput = await SpecialNewProperty.descriptionInput; - await descriptionInput.setValue( 'Cool description' ); - - const aliasesInput = await 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 $( '.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 ); + } ); } ); diff --git a/test/suites/repo/LocalSettings.php b/test/suites/repo/LocalSettings.php index dd46e4a85..adfe04ee5 100644 --- a/test/suites/repo/LocalSettings.php +++ b/test/suites/repo/LocalSettings.php @@ -2,3 +2,6 @@ // EntitySchema $wgEntitySchemaShExSimpleUrl = "http://validator.svc"; + +// Cache for one second only, so tests can see updates +$wgWBRepoSettings['sharedCacheDuration'] = 1;