From 4bb409887d7d20decc3fbf17ff69e20ca42b2563 Mon Sep 17 00:00:00 2001 From: WMDE-Fisch Date: Thu, 29 Jun 2023 14:27:57 +0200 Subject: [PATCH] selenium: run tests concurrently Includes a bit untangling of the setup. Concurrent tests should not overwrite each others user settings so one of the tests gets it's own user. Bug: T337862 Change-Id: Iae245063932d4c5d9e6b61c1fe102505d70c1039 --- tests/selenium/pageobjects/edit.page.js | 9 +++++---- tests/selenium/specs/highlighting-wikitext2010.js | 3 +-- tests/selenium/userpreferences.js | 11 ++++++++++- tests/selenium/wdio.conf.js | 4 +++- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/tests/selenium/pageobjects/edit.page.js b/tests/selenium/pageobjects/edit.page.js index c8cf5cb4..cc00fecb 100644 --- a/tests/selenium/pageobjects/edit.page.js +++ b/tests/selenium/pageobjects/edit.page.js @@ -22,7 +22,6 @@ class EditPage extends Page { } get visualEditorSave() { return $( '.ve-ui-toolbar-saveButton' ); } - get visualEditorToggle() { return $( '.ve-init-mw-editSwitch' ); } get visualEditorSurface() { return $( '.ve-ui-surface-source' ); } async cursorToPosition( index ) { @@ -36,9 +35,11 @@ class EditPage extends Page { await browser.keys( keys ); } - getHighlightedMatchingBrackets() { - const elements = $$( '.CodeMirror-line .cm-mw-matchingbracket' ); - const matchingTexts = elements.map( function ( el ) { + get highlightedBrackets() { return $$( '.CodeMirror-line .cm-mw-matchingbracket' ); } + + async getHighlightedMatchingBrackets() { + await this.highlightedBrackets[ 0 ].waitForDisplayed(); + const matchingTexts = await this.highlightedBrackets.map( function ( el ) { return el.getText(); } ); return matchingTexts.join( '' ); diff --git a/tests/selenium/specs/highlighting-wikitext2010.js b/tests/selenium/specs/highlighting-wikitext2010.js index aab3ea65..c7e56c13 100644 --- a/tests/selenium/specs/highlighting-wikitext2010.js +++ b/tests/selenium/specs/highlighting-wikitext2010.js @@ -3,7 +3,6 @@ const assert = require( 'assert' ), EditPage = require( '../pageobjects/edit.page' ), FixtureContent = require( '../fixturecontent' ), - LoginPage = require( 'wdio-mediawiki/LoginPage' ), UserPreferences = require( '../userpreferences' ), Util = require( 'wdio-mediawiki/Util' ); @@ -12,7 +11,7 @@ describe( 'CodeMirror bracket match highlighting for the wikitext 2010 editor', before( async function () { title = Util.getTestString( 'CodeMirror-fixture1-' ); - await LoginPage.loginAdmin(); + await UserPreferences.loginAsOther(); await FixtureContent.createFixturePage( title ); await UserPreferences.enableWikitext2010EditorWithCodeMirror(); } ); diff --git a/tests/selenium/userpreferences.js b/tests/selenium/userpreferences.js index 31525d8c..98c209a9 100644 --- a/tests/selenium/userpreferences.js +++ b/tests/selenium/userpreferences.js @@ -1,9 +1,18 @@ 'use strict'; -const BlankPage = require( 'wdio-mediawiki/BlankPage' ), +const Api = require( 'wdio-mediawiki/Api' ), + BlankPage = require( 'wdio-mediawiki/BlankPage' ), + LoginPage = require( 'wdio-mediawiki/LoginPage' ), Util = require( 'wdio-mediawiki/Util' ); class UserPreferences { + async loginAsOther() { + const username = Util.getTestString( 'User-' ); + const password = Util.getTestString(); + await Api.createAccount( await Api.bot(), username, password ); + await LoginPage.login( username, password ); + } + async setPreferences( preferences ) { await BlankPage.open(); Util.waitForModuleState( 'mediawiki.base' ); diff --git a/tests/selenium/wdio.conf.js b/tests/selenium/wdio.conf.js index 18d71e2d..7eccde69 100644 --- a/tests/selenium/wdio.conf.js +++ b/tests/selenium/wdio.conf.js @@ -2,10 +2,12 @@ const { config } = require( 'wdio-mediawiki/wdio-defaults.conf.js' ); -exports.config = { ...config +exports.config = { ...config, // Override, or add to, the setting from wdio-mediawiki. // Learn more at https://webdriver.io/docs/configurationfile/ // // Example: // logLevel: 'info', + + maxInstances: 4 };