Skip to content

Commit

Permalink
Make tests work across all releases (#712)
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenjohnson authored Jul 3, 2024
1 parent fe2130c commit b1f3b33
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 19 deletions.
7 changes: 7 additions & 0 deletions test/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"npm-run-all": "^4.1.5",
"prettier": "^3.2.5",
"prettier-plugin-organize-imports": "^3.2.4",
"semver-parser": "^4.1.6",
"stylelint-config-wikimedia": "0.16.1",
"ts-node": "^10.9.2",
"tslib": "^2.6.2",
Expand Down
40 changes: 24 additions & 16 deletions test/specs/repo/extensions/universal-language-selector.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { parseSemVer } from 'semver-parser';
import page from '../../../helpers/pages/page.js';

describe( 'UniversalLanguageSelector', function () {
Expand All @@ -8,23 +9,30 @@ describe( 'UniversalLanguageSelector', function () {
it( 'Should be able to see the language selector menu', async function () {
await page.open( '' );

await $( '#searchform input' ).click();
// MediaWiki 1.39 default skin sets up language selector differently than subsequent versions,
// this exception can be removed once MW 1.39 is no longer supported.
if ( parseSemVer( testEnv.vars.MEDIAWIKI_VERSION ).minor === 39 ) {
await $( '#searchInput' ).click();
await $( '.imeselector' ).click();

// work around lang selector not showing up the first time
// blur the search bar
await $( '.page-Main_Page' ).click();
// focus search bar again, lang selector should be there now
await $( '#searchform input' ).click();
await expect( $( '.imeselector-menu h3' ) ).toHaveText( 'English' );
} else {
await $( '#searchform input' ).click();
// work around lang selector not showing up the first time
// blur the search bar
await $( '.page-Main_Page' ).click();
// focus search bar again, lang selector should be there now
await $( '#searchform input' ).click();
await $$( '.imeselector' )
.filter( async ( selector ) => selector.isClickable() )[ 0 ]
.click();

await $$( '.imeselector' )
.filter( async ( selector ) => selector.isClickable() )[ 0 ]
.click();

// We need to use getHTML(). If an element isn't interactable
// getText() returns an empty string.
// https://webdriver.io/docs/api/element/getText/
await expect(
$( 'div.imeselector-menu h3.ime-list-title' ).getHTML()
).resolves.toMatch( /English/ );
// We need to use getHTML(). If an element isn't interactable
// getText() returns an empty string.
// https://webdriver.io/docs/api/element/getText/
await expect(
$( 'div.imeselector-menu h3.ime-list-title' ).getHTML()
).resolves.toMatch( /English/ );
}
} );
} );
18 changes: 15 additions & 3 deletions test/specs/repo/property.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { parseSemVer } from 'semver-parser';
import WikibaseApi from 'wdio-wikibase/wikibase.api.js';
import PropertyPage from '../../helpers/pages/entity/property.page.js';
import page from '../../helpers/pages/page.js';
Expand Down Expand Up @@ -89,7 +90,9 @@ describe( 'Property', function () {

it( 'Should display the added properties on the "Recent changes" page', async function () {
await browser.waitForJobs();
await $( '.vector-main-menu-dropdown' ).click();
if ( parseSemVer( testEnv.vars.MEDIAWIKI_VERSION ).minor > 39 ) {
await $( '.vector-main-menu-dropdown' ).click();
}
await $( '=Recent changes' ).click();
await expect( $( `=(${ propertyId })` ) ).toExist();
await expect( $( `=(${ stringPropertyId })` ) ).toExist();
Expand Down Expand Up @@ -121,7 +124,12 @@ describe( 'Property', function () {
await page.open( '/wiki/Special:SetLabelDescriptionAliases/' );
await $( 'label=ID:' ).click();
await browser.keys( propertyId.split( '' ) );
await $( 'span=Continue' ).click();

if ( parseSemVer( testEnv.vars.MEDIAWIKI_VERSION ).minor === 39 ) {
await $( 'span=Set label, description and aliases' ).click();
} else {
await $( 'span=Continue' ).click();
}

await $( 'label=Label:' ).click();
await browser.keys( `${ dataType.name } Label`.split( '' ) );
Expand All @@ -132,7 +140,11 @@ describe( 'Property', function () {
`${ dataType.name } Alias A|${ dataType.name } Alias B`.split( '' )
);

await $( 'span=Save changes' ).click();
if ( parseSemVer( testEnv.vars.MEDIAWIKI_VERSION ).minor === 39 ) {
await $( 'span=Set label, description and aliases' ).click();
} else {
await $( 'span=Save changes' ).click();
}

await expect(
$( `span.wikibase-labelview-text=${ dataType.name } Label` )
Expand Down

0 comments on commit b1f3b33

Please sign in to comment.