Merge "[selenium] Update REL1_39 to current master tests" into REL1_39

This commit is contained in:
jenkins-bot 2024-05-12 00:41:50 +00:00 committed by Gerrit Code Review
commit 6ed0eab1fa
8 changed files with 2516 additions and 1969 deletions

4218
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -6,12 +6,11 @@
"selenium-test": "wdio tests/selenium/wdio.conf.js"
},
"devDependencies": {
"@wdio/cli": "7.4.6",
"@wdio/dot-reporter": "7.4.2",
"@wdio/junit-reporter": "7.4.2",
"@wdio/local-runner": "7.4.6",
"@wdio/mocha-framework": "7.13.2",
"@wdio/sync": "6.10.11",
"@wdio/cli": "7.30.1",
"@wdio/junit-reporter": "7.29.1",
"@wdio/local-runner": "7.30.1",
"@wdio/mocha-framework": "7.26.0",
"@wdio/spec-reporter": "7.29.1",
"dotenv": "8.2.0",
"eslint-config-wikimedia": "0.22.1",
"grunt": "1.5.3",
@ -19,7 +18,6 @@
"grunt-eslint": "24.0.0",
"grunt-stylelint": "0.17.0",
"stylelint-config-wikimedia": "0.13.0",
"wdio-mediawiki": "1.2.0",
"webdriverio": "7.4.6"
"wdio-mediawiki": "2.3.0"
}
}

View file

@ -1,7 +1,6 @@
'use strict';
const Api = require( 'wdio-mediawiki/Api' );
const Util = require( 'wdio-mediawiki/Util' );
const fixture1 = '[]{{template}}';
@ -9,14 +8,11 @@ class FixtureContent {
/**
* Create a new fixture for testing syntax highlighting.
*
* @return {string} Page title
* @param {string} title
*/
createFixturePage() {
const title = Util.getTestString( 'CodeMirror-fixture1-' );
browser.call( () => Api.bot().then( ( bot ) => bot.edit( title, fixture1 ) ) );
return title;
async createFixturePage( title ) {
const bot = await Api.bot();
await bot.edit( title, fixture1 );
}
}

View file

@ -4,41 +4,75 @@ const Page = require( 'wdio-mediawiki/Page' );
// Copied from mediawiki-core edit.page.js
class EditPage extends Page {
openForEditing( title ) {
super.openTitle( title, { action: 'edit', vehidebetadialog: 1, hidewelcomedialog: 1 } );
async openForEditing( title, cm6enable = false ) {
const queryParams = {
action: 'edit',
vehidebetadialog: 1,
hidewelcomedialog: 1
};
if ( cm6enable ) {
queryParams.cm6enable = '1';
}
await super.openTitle( title, queryParams );
}
get wikiEditorToolbar() { return $( '#wikiEditor-ui-toolbar' ); }
get legacyTextInput() { return $( '#wpTextbox1' ); }
clickText() {
if ( this.visualEditorSave.isDisplayed() ) {
this.visualEditorSurface.click();
} else if ( this.legacyTextInput.isDisplayed() ) {
this.legacyTextInput.click();
get wikiEditorToolbar() {
return $( '#wikiEditor-ui-toolbar' );
}
get legacyTextInput() {
return $( '#wpTextbox1' );
}
get legacyCodeMirrorButton() {
return $( '#mw-editbutton-codemirror' );
}
async clickText() {
if ( await this.visualEditorSave.isDisplayed() ) {
await this.visualEditorSurface.click();
} else if ( await this.legacyTextInput.isDisplayed() ) {
await this.legacyTextInput.click();
} else {
// Click the container, if using WikiEditor etc.
this.legacyTextInput.parentElement().click();
await this.legacyTextInput.parentElement().click();
}
}
get visualEditorSave() { return $( '.ve-ui-toolbar-saveButton' ); }
get visualEditorToggle() { return $( '.ve-init-mw-editSwitch' ); }
get visualEditorSurface() { return $( '.ve-ui-surface-source' ); }
get visualEditorSave() {
return $( '.ve-ui-toolbar-saveButton' );
}
cursorToPosition( index ) {
this.clickText();
get visualEditorSurface() {
return $( '.ve-ui-surface-source' );
}
get codeMirrorTemplateFoldingButton() {
return $( '.cm-tooltip-fold' );
}
get codeMirrorTemplateFoldingPlaceholder() {
return $( '.cm-foldPlaceholder' );
}
async cursorToPosition( index ) {
await this.clickText();
// Second "Control" deactivates the modifier.
const keys = [ 'Control', 'Home', 'Control' ];
for ( let i = 0; i < index; i++ ) {
keys.push( 'ArrowRight' );
}
browser.keys( keys );
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( '' );

View file

@ -3,31 +3,32 @@
const assert = require( 'assert' ),
EditPage = require( '../pageobjects/edit.page' ),
FixtureContent = require( '../fixturecontent' ),
LoginPage = require( 'wdio-mediawiki/LoginPage' ),
UserPreferences = require( '../userpreferences' );
UserPreferences = require( '../userpreferences' ),
Util = require( 'wdio-mediawiki/Util' );
describe( 'CodeMirror bracket match highlighting for the wikitext 2010 editor', function () {
before( function () {
LoginPage.loginAdmin();
this.title = FixtureContent.createFixturePage();
UserPreferences.enableWikitext2010EditorWithCodeMirror();
let title;
before( async function () {
title = Util.getTestString( 'CodeMirror-fixture1-' );
await UserPreferences.loginAsOther();
await FixtureContent.createFixturePage( title );
await UserPreferences.enableWikitext2010EditorWithCodeMirror();
} );
beforeEach( function () {
EditPage.openForEditing( this.title );
EditPage.wikiEditorToolbar.waitForDisplayed();
EditPage.clickText();
beforeEach( async function () {
await EditPage.openForEditing( title );
await EditPage.wikiEditorToolbar.waitForDisplayed();
await EditPage.clickText();
} );
it( 'highlights matching bracket', function () {
EditPage.cursorToPosition( 0 );
assert.strictEqual( EditPage.getHighlightedMatchingBrackets(), '[]' );
it( 'highlights matching bracket', async function () {
await EditPage.cursorToPosition( 0 );
assert.strictEqual( await EditPage.getHighlightedMatchingBrackets(), '[]' );
} );
it( 'matches according to cursor movement', function () {
EditPage.cursorToPosition( 3 );
// FIXME: wait for hook to fire
browser.pause( 100 );
assert.strictEqual( EditPage.getHighlightedMatchingBrackets(), '{}' );
it( 'matches according to cursor movement', async function () {
await EditPage.cursorToPosition( 3 );
assert.strictEqual( await EditPage.getHighlightedMatchingBrackets(), '{}' );
} );
} );

View file

@ -4,31 +4,34 @@ const assert = require( 'assert' ),
EditPage = require( '../pageobjects/edit.page' ),
FixtureContent = require( '../fixturecontent' ),
LoginPage = require( 'wdio-mediawiki/LoginPage' ),
UserPreferences = require( '../userpreferences' );
UserPreferences = require( '../userpreferences' ),
Util = require( 'wdio-mediawiki/Util' );
describe( 'CodeMirror bracket match highlighting for the wikitext 2017 editor', function () {
before( function () {
LoginPage.loginAdmin();
this.title = FixtureContent.createFixturePage();
UserPreferences.enableWikitext2017EditorWithCodeMirror();
// Disable as test is consistently failing on CI.
describe.skip( 'CodeMirror bracket match highlighting for the wikitext 2017 editor', function () {
let title;
before( async function () {
title = Util.getTestString( 'CodeMirror-fixture1-' );
await LoginPage.loginAdmin();
await FixtureContent.createFixturePage( title );
await UserPreferences.enableWikitext2017EditorWithCodeMirror();
} );
beforeEach( function () {
EditPage.openForEditing( this.title );
EditPage.visualEditorSave.waitForDisplayed();
assert( !EditPage.wikiEditorToolbar.isDisplayed() );
EditPage.clickText();
beforeEach( async function () {
await EditPage.openForEditing( title );
await EditPage.visualEditorSave.waitForDisplayed();
assert( !( await EditPage.wikiEditorToolbar.isDisplayed() ) );
await EditPage.clickText();
} );
it( 'highlights matching bracket', function () {
EditPage.cursorToPosition( 0 );
assert.strictEqual( EditPage.getHighlightedMatchingBrackets(), '[]' );
it( 'highlights matching bracket', async function () {
await EditPage.cursorToPosition( 0 );
assert.strictEqual( await EditPage.getHighlightedMatchingBrackets(), '[]' );
} );
it( 'matches according to cursor movement', function () {
EditPage.cursorToPosition( 3 );
// FIXME: wait for hook to fire
browser.pause( 100 );
assert.strictEqual( EditPage.getHighlightedMatchingBrackets(), '{}' );
it( 'matches according to cursor movement', async function () {
await EditPage.cursorToPosition( 3 );
assert.strictEqual( await EditPage.getHighlightedMatchingBrackets(), '{}' );
} );
} );

View file

@ -1,22 +1,31 @@
'use strict';
const BlankPage = require( 'wdio-mediawiki/BlankPage' );
const Util = require( 'wdio-mediawiki/Util' );
const Api = require( 'wdio-mediawiki/Api' ),
BlankPage = require( 'wdio-mediawiki/BlankPage' ),
LoginPage = require( 'wdio-mediawiki/LoginPage' ),
Util = require( 'wdio-mediawiki/Util' );
class UserPreferences {
setPreferences( preferences ) {
BlankPage.open();
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' );
return browser.execute( function ( prefs ) {
return await browser.execute( function ( prefs ) {
return mw.loader.using( 'mediawiki.api' ).then( function () {
return new mw.Api().saveOptions( prefs );
} );
}, preferences );
}
enableWikitext2010EditorWithCodeMirror() {
this.setPreferences( {
async enableWikitext2010EditorWithCodeMirror() {
await this.setPreferences( {
usebetatoolbar: '1',
usecodemirror: '1',
'visualeditor-enable': '0',
@ -24,8 +33,8 @@ class UserPreferences {
} );
}
enableWikitext2017EditorWithCodeMirror() {
this.setPreferences( {
async enableWikitext2017EditorWithCodeMirror() {
await this.setPreferences( {
usebetatoolbar: null,
usecodemirror: '1',
'visualeditor-enable': '1',

View file

@ -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
};