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
This commit is contained in:
WMDE-Fisch 2023-06-29 14:27:57 +02:00
parent 5b69b2380c
commit 4bb409887d
4 changed files with 19 additions and 8 deletions

View file

@ -22,7 +22,6 @@ class EditPage extends Page {
} }
get visualEditorSave() { return $( '.ve-ui-toolbar-saveButton' ); } get visualEditorSave() { return $( '.ve-ui-toolbar-saveButton' ); }
get visualEditorToggle() { return $( '.ve-init-mw-editSwitch' ); }
get visualEditorSurface() { return $( '.ve-ui-surface-source' ); } get visualEditorSurface() { return $( '.ve-ui-surface-source' ); }
async cursorToPosition( index ) { async cursorToPosition( index ) {
@ -36,9 +35,11 @@ class EditPage extends Page {
await browser.keys( keys ); await browser.keys( keys );
} }
getHighlightedMatchingBrackets() { get highlightedBrackets() { return $$( '.CodeMirror-line .cm-mw-matchingbracket' ); }
const elements = $$( '.CodeMirror-line .cm-mw-matchingbracket' );
const matchingTexts = elements.map( function ( el ) { async getHighlightedMatchingBrackets() {
await this.highlightedBrackets[ 0 ].waitForDisplayed();
const matchingTexts = await this.highlightedBrackets.map( function ( el ) {
return el.getText(); return el.getText();
} ); } );
return matchingTexts.join( '' ); return matchingTexts.join( '' );

View file

@ -3,7 +3,6 @@
const assert = require( 'assert' ), const assert = require( 'assert' ),
EditPage = require( '../pageobjects/edit.page' ), EditPage = require( '../pageobjects/edit.page' ),
FixtureContent = require( '../fixturecontent' ), FixtureContent = require( '../fixturecontent' ),
LoginPage = require( 'wdio-mediawiki/LoginPage' ),
UserPreferences = require( '../userpreferences' ), UserPreferences = require( '../userpreferences' ),
Util = require( 'wdio-mediawiki/Util' ); Util = require( 'wdio-mediawiki/Util' );
@ -12,7 +11,7 @@ describe( 'CodeMirror bracket match highlighting for the wikitext 2010 editor',
before( async function () { before( async function () {
title = Util.getTestString( 'CodeMirror-fixture1-' ); title = Util.getTestString( 'CodeMirror-fixture1-' );
await LoginPage.loginAdmin(); await UserPreferences.loginAsOther();
await FixtureContent.createFixturePage( title ); await FixtureContent.createFixturePage( title );
await UserPreferences.enableWikitext2010EditorWithCodeMirror(); await UserPreferences.enableWikitext2010EditorWithCodeMirror();
} ); } );

View file

@ -1,9 +1,18 @@
'use strict'; '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' ); Util = require( 'wdio-mediawiki/Util' );
class UserPreferences { 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 ) { async setPreferences( preferences ) {
await BlankPage.open(); await BlankPage.open();
Util.waitForModuleState( 'mediawiki.base' ); Util.waitForModuleState( 'mediawiki.base' );

View file

@ -2,10 +2,12 @@
const { config } = require( 'wdio-mediawiki/wdio-defaults.conf.js' ); const { config } = require( 'wdio-mediawiki/wdio-defaults.conf.js' );
exports.config = { ...config exports.config = { ...config,
// Override, or add to, the setting from wdio-mediawiki. // Override, or add to, the setting from wdio-mediawiki.
// Learn more at https://webdriver.io/docs/configurationfile/ // Learn more at https://webdriver.io/docs/configurationfile/
// //
// Example: // Example:
// logLevel: 'info', // logLevel: 'info',
maxInstances: 4
}; };