mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
synced 2024-12-19 01:00:36 +00:00
Merge "[selenium] Update REL1_39 to current master tests" into REL1_39
This commit is contained in:
commit
6ed0eab1fa
4278
package-lock.json
generated
4278
package-lock.json
generated
File diff suppressed because it is too large
Load diff
14
package.json
14
package.json
|
@ -6,12 +6,11 @@
|
||||||
"selenium-test": "wdio tests/selenium/wdio.conf.js"
|
"selenium-test": "wdio tests/selenium/wdio.conf.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@wdio/cli": "7.4.6",
|
"@wdio/cli": "7.30.1",
|
||||||
"@wdio/dot-reporter": "7.4.2",
|
"@wdio/junit-reporter": "7.29.1",
|
||||||
"@wdio/junit-reporter": "7.4.2",
|
"@wdio/local-runner": "7.30.1",
|
||||||
"@wdio/local-runner": "7.4.6",
|
"@wdio/mocha-framework": "7.26.0",
|
||||||
"@wdio/mocha-framework": "7.13.2",
|
"@wdio/spec-reporter": "7.29.1",
|
||||||
"@wdio/sync": "6.10.11",
|
|
||||||
"dotenv": "8.2.0",
|
"dotenv": "8.2.0",
|
||||||
"eslint-config-wikimedia": "0.22.1",
|
"eslint-config-wikimedia": "0.22.1",
|
||||||
"grunt": "1.5.3",
|
"grunt": "1.5.3",
|
||||||
|
@ -19,7 +18,6 @@
|
||||||
"grunt-eslint": "24.0.0",
|
"grunt-eslint": "24.0.0",
|
||||||
"grunt-stylelint": "0.17.0",
|
"grunt-stylelint": "0.17.0",
|
||||||
"stylelint-config-wikimedia": "0.13.0",
|
"stylelint-config-wikimedia": "0.13.0",
|
||||||
"wdio-mediawiki": "1.2.0",
|
"wdio-mediawiki": "2.3.0"
|
||||||
"webdriverio": "7.4.6"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const Api = require( 'wdio-mediawiki/Api' );
|
const Api = require( 'wdio-mediawiki/Api' );
|
||||||
const Util = require( 'wdio-mediawiki/Util' );
|
|
||||||
|
|
||||||
const fixture1 = '[]{{template}}';
|
const fixture1 = '[]{{template}}';
|
||||||
|
|
||||||
|
@ -9,14 +8,11 @@ class FixtureContent {
|
||||||
/**
|
/**
|
||||||
* Create a new fixture for testing syntax highlighting.
|
* Create a new fixture for testing syntax highlighting.
|
||||||
*
|
*
|
||||||
* @return {string} Page title
|
* @param {string} title
|
||||||
*/
|
*/
|
||||||
createFixturePage() {
|
async createFixturePage( title ) {
|
||||||
const title = Util.getTestString( 'CodeMirror-fixture1-' );
|
const bot = await Api.bot();
|
||||||
|
await bot.edit( title, fixture1 );
|
||||||
browser.call( () => Api.bot().then( ( bot ) => bot.edit( title, fixture1 ) ) );
|
|
||||||
|
|
||||||
return title;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,41 +4,75 @@ const Page = require( 'wdio-mediawiki/Page' );
|
||||||
|
|
||||||
// Copied from mediawiki-core edit.page.js
|
// Copied from mediawiki-core edit.page.js
|
||||||
class EditPage extends Page {
|
class EditPage extends Page {
|
||||||
openForEditing( title ) {
|
async openForEditing( title, cm6enable = false ) {
|
||||||
super.openTitle( title, { action: 'edit', vehidebetadialog: 1, hidewelcomedialog: 1 } );
|
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 wikiEditorToolbar() {
|
||||||
get legacyTextInput() { return $( '#wpTextbox1' ); }
|
return $( '#wikiEditor-ui-toolbar' );
|
||||||
clickText() {
|
}
|
||||||
if ( this.visualEditorSave.isDisplayed() ) {
|
|
||||||
this.visualEditorSurface.click();
|
get legacyTextInput() {
|
||||||
} else if ( this.legacyTextInput.isDisplayed() ) {
|
return $( '#wpTextbox1' );
|
||||||
this.legacyTextInput.click();
|
}
|
||||||
|
|
||||||
|
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 {
|
} else {
|
||||||
// Click the container, if using WikiEditor etc.
|
// Click the container, if using WikiEditor etc.
|
||||||
this.legacyTextInput.parentElement().click();
|
await this.legacyTextInput.parentElement().click();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get visualEditorSave() { return $( '.ve-ui-toolbar-saveButton' ); }
|
get visualEditorSave() {
|
||||||
get visualEditorToggle() { return $( '.ve-init-mw-editSwitch' ); }
|
return $( '.ve-ui-toolbar-saveButton' );
|
||||||
get visualEditorSurface() { return $( '.ve-ui-surface-source' ); }
|
}
|
||||||
|
|
||||||
cursorToPosition( index ) {
|
get visualEditorSurface() {
|
||||||
this.clickText();
|
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.
|
// Second "Control" deactivates the modifier.
|
||||||
const keys = [ 'Control', 'Home', 'Control' ];
|
const keys = [ 'Control', 'Home', 'Control' ];
|
||||||
for ( let i = 0; i < index; i++ ) {
|
for ( let i = 0; i < index; i++ ) {
|
||||||
keys.push( 'ArrowRight' );
|
keys.push( 'ArrowRight' );
|
||||||
}
|
}
|
||||||
browser.keys( keys );
|
await browser.keys( keys );
|
||||||
}
|
}
|
||||||
|
|
||||||
getHighlightedMatchingBrackets() {
|
get highlightedBrackets() {
|
||||||
const elements = $$( '.CodeMirror-line .cm-mw-matchingbracket' );
|
return $$( '.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( '' );
|
||||||
|
|
|
@ -3,31 +3,32 @@
|
||||||
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' );
|
||||||
|
|
||||||
describe( 'CodeMirror bracket match highlighting for the wikitext 2010 editor', function () {
|
describe( 'CodeMirror bracket match highlighting for the wikitext 2010 editor', function () {
|
||||||
before( function () {
|
let title;
|
||||||
LoginPage.loginAdmin();
|
|
||||||
this.title = FixtureContent.createFixturePage();
|
before( async function () {
|
||||||
UserPreferences.enableWikitext2010EditorWithCodeMirror();
|
title = Util.getTestString( 'CodeMirror-fixture1-' );
|
||||||
|
await UserPreferences.loginAsOther();
|
||||||
|
await FixtureContent.createFixturePage( title );
|
||||||
|
await UserPreferences.enableWikitext2010EditorWithCodeMirror();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
beforeEach( function () {
|
beforeEach( async function () {
|
||||||
EditPage.openForEditing( this.title );
|
await EditPage.openForEditing( title );
|
||||||
EditPage.wikiEditorToolbar.waitForDisplayed();
|
await EditPage.wikiEditorToolbar.waitForDisplayed();
|
||||||
EditPage.clickText();
|
await EditPage.clickText();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
it( 'highlights matching bracket', function () {
|
it( 'highlights matching bracket', async function () {
|
||||||
EditPage.cursorToPosition( 0 );
|
await EditPage.cursorToPosition( 0 );
|
||||||
assert.strictEqual( EditPage.getHighlightedMatchingBrackets(), '[]' );
|
assert.strictEqual( await EditPage.getHighlightedMatchingBrackets(), '[]' );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
it( 'matches according to cursor movement', function () {
|
it( 'matches according to cursor movement', async function () {
|
||||||
EditPage.cursorToPosition( 3 );
|
await EditPage.cursorToPosition( 3 );
|
||||||
// FIXME: wait for hook to fire
|
assert.strictEqual( await EditPage.getHighlightedMatchingBrackets(), '{}' );
|
||||||
browser.pause( 100 );
|
|
||||||
assert.strictEqual( EditPage.getHighlightedMatchingBrackets(), '{}' );
|
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -4,31 +4,34 @@ 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' ),
|
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 () {
|
// Disable as test is consistently failing on CI.
|
||||||
before( function () {
|
describe.skip( 'CodeMirror bracket match highlighting for the wikitext 2017 editor', function () {
|
||||||
LoginPage.loginAdmin();
|
let title;
|
||||||
this.title = FixtureContent.createFixturePage();
|
|
||||||
UserPreferences.enableWikitext2017EditorWithCodeMirror();
|
before( async function () {
|
||||||
|
title = Util.getTestString( 'CodeMirror-fixture1-' );
|
||||||
|
await LoginPage.loginAdmin();
|
||||||
|
await FixtureContent.createFixturePage( title );
|
||||||
|
await UserPreferences.enableWikitext2017EditorWithCodeMirror();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
beforeEach( function () {
|
beforeEach( async function () {
|
||||||
EditPage.openForEditing( this.title );
|
await EditPage.openForEditing( title );
|
||||||
EditPage.visualEditorSave.waitForDisplayed();
|
await EditPage.visualEditorSave.waitForDisplayed();
|
||||||
assert( !EditPage.wikiEditorToolbar.isDisplayed() );
|
assert( !( await EditPage.wikiEditorToolbar.isDisplayed() ) );
|
||||||
EditPage.clickText();
|
await EditPage.clickText();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
it( 'highlights matching bracket', function () {
|
it( 'highlights matching bracket', async function () {
|
||||||
EditPage.cursorToPosition( 0 );
|
await EditPage.cursorToPosition( 0 );
|
||||||
assert.strictEqual( EditPage.getHighlightedMatchingBrackets(), '[]' );
|
assert.strictEqual( await EditPage.getHighlightedMatchingBrackets(), '[]' );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
it( 'matches according to cursor movement', function () {
|
it( 'matches according to cursor movement', async function () {
|
||||||
EditPage.cursorToPosition( 3 );
|
await EditPage.cursorToPosition( 3 );
|
||||||
// FIXME: wait for hook to fire
|
assert.strictEqual( await EditPage.getHighlightedMatchingBrackets(), '{}' );
|
||||||
browser.pause( 100 );
|
|
||||||
assert.strictEqual( EditPage.getHighlightedMatchingBrackets(), '{}' );
|
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -1,22 +1,31 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const BlankPage = require( 'wdio-mediawiki/BlankPage' );
|
const Api = require( 'wdio-mediawiki/Api' ),
|
||||||
const Util = require( 'wdio-mediawiki/Util' );
|
BlankPage = require( 'wdio-mediawiki/BlankPage' ),
|
||||||
|
LoginPage = require( 'wdio-mediawiki/LoginPage' ),
|
||||||
|
Util = require( 'wdio-mediawiki/Util' );
|
||||||
|
|
||||||
class UserPreferences {
|
class UserPreferences {
|
||||||
setPreferences( preferences ) {
|
async loginAsOther() {
|
||||||
BlankPage.open();
|
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' );
|
Util.waitForModuleState( 'mediawiki.base' );
|
||||||
|
|
||||||
return browser.execute( function ( prefs ) {
|
return await browser.execute( function ( prefs ) {
|
||||||
return mw.loader.using( 'mediawiki.api' ).then( function () {
|
return mw.loader.using( 'mediawiki.api' ).then( function () {
|
||||||
return new mw.Api().saveOptions( prefs );
|
return new mw.Api().saveOptions( prefs );
|
||||||
} );
|
} );
|
||||||
}, preferences );
|
}, preferences );
|
||||||
}
|
}
|
||||||
|
|
||||||
enableWikitext2010EditorWithCodeMirror() {
|
async enableWikitext2010EditorWithCodeMirror() {
|
||||||
this.setPreferences( {
|
await this.setPreferences( {
|
||||||
usebetatoolbar: '1',
|
usebetatoolbar: '1',
|
||||||
usecodemirror: '1',
|
usecodemirror: '1',
|
||||||
'visualeditor-enable': '0',
|
'visualeditor-enable': '0',
|
||||||
|
@ -24,8 +33,8 @@ class UserPreferences {
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
enableWikitext2017EditorWithCodeMirror() {
|
async enableWikitext2017EditorWithCodeMirror() {
|
||||||
this.setPreferences( {
|
await this.setPreferences( {
|
||||||
usebetatoolbar: null,
|
usebetatoolbar: null,
|
||||||
usecodemirror: '1',
|
usecodemirror: '1',
|
||||||
'visualeditor-enable': '1',
|
'visualeditor-enable': '1',
|
||||||
|
|
|
@ -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
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue