From e735f05e8b13ceec67313bf8459c35827f9856b2 Mon Sep 17 00:00:00 2001 From: roti Date: Wed, 25 Oct 2023 14:07:33 +0000 Subject: [PATCH 1/4] test(property-list): reproduce new property not shown issue --- .../pages/special/list-properties.page.ts | 21 ++++++++++++ .../pages/special/new-property.page.ts | 6 ++++ test/specs/repo/special-property.ts | 34 +++++++++++++------ 3 files changed, 50 insertions(+), 11 deletions(-) create mode 100644 test/helpers/pages/special/list-properties.page.ts 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..9db51c5c1 --- /dev/null +++ b/test/helpers/pages/special/list-properties.page.ts @@ -0,0 +1,21 @@ +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 open(): Promise { + await browser.url( + `${process.env.MW_SERVER}/wiki/Special:ListProperties` + ); + + 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 74d1807ef..8b352686f 100644 --- a/test/specs/repo/special-property.ts +++ b/test/specs/repo/special-property.ts @@ -1,27 +1,39 @@ import assert from 'assert'; import SpecialNewProperty from '../../helpers/pages/special/new-property.page.js'; +import SpecialListProperties from '../../helpers/pages/special/list-properties.page.js'; import awaitDisplayed from '../../helpers/await-displayed.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.open( 'string' ); + 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.open(); + 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(); + + + await SpecialListProperties.open(); + const numberOfPropertiesAfter = await SpecialListProperties.properties.length; + + assert.strictEqual( numberOfPropertiesBefore + 1, numberOfPropertiesAfter ); + + } ); + } ); From 7d8ce1edcb753e67483226adf901ac1ea74d792d Mon Sep 17 00:00:00 2001 From: roti Date: Thu, 26 Oct 2023 13:00:36 +0000 Subject: [PATCH 2/4] fix: configure cache and wait for it to timeout --- test/specs/repo/special-property.ts | 9 +++++---- test/suites/repo/LocalSettings.php | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/test/specs/repo/special-property.ts b/test/specs/repo/special-property.ts index 8b352686f..d7e38ed6d 100644 --- a/test/specs/repo/special-property.ts +++ b/test/specs/repo/special-property.ts @@ -5,8 +5,8 @@ import awaitDisplayed from '../../helpers/await-displayed.js'; describe( 'Special:NewProperty', function () { it( 'Should be able to create a new property', async () => { - await SpecialNewProperty.open( 'string' ); + await SpecialNewProperty.labelInput.setValue( 'Cool label' ); await SpecialNewProperty.descriptionInput.setValue( 'Cool description' ); await SpecialNewProperty.aliasesInput.setValue( 'Great job!|Bra Jobbat' ); @@ -27,13 +27,14 @@ describe( 'Special:NewProperty', function () { await SpecialNewProperty.labelInput.setValue( 'Property type string' ); await SpecialNewProperty.descriptionInput.setValue( 'A string property' ); await SpecialNewProperty.submit(); - + + // wait for the cache to timeout, so the list of properties reflects the change + await browser.pause( 1100 ); await SpecialListProperties.open(); const numberOfPropertiesAfter = await SpecialListProperties.properties.length; - assert.strictEqual( numberOfPropertiesBefore + 1, numberOfPropertiesAfter ); - + 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; From 3e1fdf6998e5b5201a53f0be0c9115760ab893cd Mon Sep 17 00:00:00 2001 From: roti Date: Thu, 26 Oct 2023 13:03:49 +0000 Subject: [PATCH 3/4] fix: lint --- test/specs/repo/special-property.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/specs/repo/special-property.ts b/test/specs/repo/special-property.ts index d7e38ed6d..a3cb86fcb 100644 --- a/test/specs/repo/special-property.ts +++ b/test/specs/repo/special-property.ts @@ -27,7 +27,7 @@ describe( 'Special:NewProperty', function () { await SpecialNewProperty.labelInput.setValue( 'Property type string' ); await SpecialNewProperty.descriptionInput.setValue( 'A string property' ); await SpecialNewProperty.submit(); - + // wait for the cache to timeout, so the list of properties reflects the change await browser.pause( 1100 ); From fe6296c721bdd1ce9a4aeb48ccc4a9665f032832 Mon Sep 17 00:00:00 2001 From: roti Date: Wed, 1 Nov 2023 08:51:52 +0000 Subject: [PATCH 4/4] fix: list of properties page test for more than 50 properties --- test/.eslintrc.json | 1 + test/helpers/pages/special/list-properties.page.ts | 12 ++++++++++-- test/specs/repo/special-property.ts | 13 +++++++------ 3 files changed, 18 insertions(+), 8 deletions(-) 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 index 9db51c5c1..6eb62d61f 100644 --- a/test/helpers/pages/special/list-properties.page.ts +++ b/test/helpers/pages/special/list-properties.page.ts @@ -9,9 +9,17 @@ class SpecialListProperties extends Page { return $$( '.mw-spcontent ol li' ); } - public async open(): Promise { + 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` + `${process.env.MW_SERVER}/wiki/Special:ListProperties?${dataType}&${limit}&${offset}` ); await awaitDisplayed( this.content ); diff --git a/test/specs/repo/special-property.ts b/test/specs/repo/special-property.ts index a3cb86fcb..9c99c5a49 100644 --- a/test/specs/repo/special-property.ts +++ b/test/specs/repo/special-property.ts @@ -1,7 +1,8 @@ import assert from 'assert'; -import SpecialNewProperty from '../../helpers/pages/special/new-property.page.js'; -import SpecialListProperties from '../../helpers/pages/special/list-properties.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 () => { @@ -20,7 +21,7 @@ describe( 'Special:NewProperty', function () { } ); it( 'Should be able to see newly created properties in list of properties special page', async () => { - await SpecialListProperties.open(); + await SpecialListProperties.openParams( { limit: 1000 } ); const numberOfPropertiesBefore = await SpecialListProperties.properties.length; await SpecialNewProperty.open( 'string' ); @@ -28,13 +29,13 @@ describe( 'Special:NewProperty', function () { await SpecialNewProperty.descriptionInput.setValue( 'A string property' ); await SpecialNewProperty.submit(); - // wait for the cache to timeout, so the list of properties reflects the change + // wait for the $wgWBRepoSettings['sharedCacheDuration'] cache to + // timeout, so the list of properties reflects the change await browser.pause( 1100 ); - await SpecialListProperties.open(); + await SpecialListProperties.openParams( { limit: 1000 } ); const numberOfPropertiesAfter = await SpecialListProperties.properties.length; assert.strictEqual( numberOfPropertiesAfter, numberOfPropertiesBefore + 1 ); } ); - } );