mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
synced 2024-11-24 06:13:31 +00:00
4bb409887d
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
47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
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' );
|
|
|
|
return await browser.execute( function ( prefs ) {
|
|
return mw.loader.using( 'mediawiki.api' ).then( function () {
|
|
return new mw.Api().saveOptions( prefs );
|
|
} );
|
|
}, preferences );
|
|
}
|
|
|
|
async enableWikitext2010EditorWithCodeMirror() {
|
|
await this.setPreferences( {
|
|
usebetatoolbar: '1',
|
|
usecodemirror: '1',
|
|
'visualeditor-enable': '0',
|
|
'visualeditor-newwikitext': '0'
|
|
} );
|
|
}
|
|
|
|
async enableWikitext2017EditorWithCodeMirror() {
|
|
await this.setPreferences( {
|
|
usebetatoolbar: null,
|
|
usecodemirror: '1',
|
|
'visualeditor-enable': '1',
|
|
'visualeditor-newwikitext': '1'
|
|
} );
|
|
}
|
|
}
|
|
|
|
module.exports = new UserPreferences();
|