2020-12-18 16:32:22 +00:00
|
|
|
'use strict';
|
|
|
|
|
2023-06-29 12:27:57 +00:00
|
|
|
const Api = require( 'wdio-mediawiki/Api' ),
|
|
|
|
BlankPage = require( 'wdio-mediawiki/BlankPage' ),
|
|
|
|
LoginPage = require( 'wdio-mediawiki/LoginPage' ),
|
2023-04-03 17:14:23 +00:00
|
|
|
Util = require( 'wdio-mediawiki/Util' );
|
2020-12-18 16:32:22 +00:00
|
|
|
|
|
|
|
class UserPreferences {
|
2023-06-29 12:27:57 +00:00
|
|
|
async loginAsOther() {
|
|
|
|
const username = Util.getTestString( 'User-' );
|
|
|
|
const password = Util.getTestString();
|
|
|
|
await Api.createAccount( await Api.bot(), username, password );
|
|
|
|
await LoginPage.login( username, password );
|
|
|
|
}
|
|
|
|
|
2023-04-03 17:14:23 +00:00
|
|
|
async setPreferences( preferences ) {
|
|
|
|
await BlankPage.open();
|
2020-12-18 16:32:22 +00:00
|
|
|
Util.waitForModuleState( 'mediawiki.base' );
|
|
|
|
|
2023-04-03 17:14:23 +00:00
|
|
|
return await browser.execute( function ( prefs ) {
|
2020-12-18 16:32:22 +00:00
|
|
|
return mw.loader.using( 'mediawiki.api' ).then( function () {
|
|
|
|
return new mw.Api().saveOptions( prefs );
|
|
|
|
} );
|
|
|
|
}, preferences );
|
|
|
|
}
|
|
|
|
|
2023-04-03 17:14:23 +00:00
|
|
|
async enableWikitext2010EditorWithCodeMirror() {
|
|
|
|
await this.setPreferences( {
|
2020-12-18 16:32:22 +00:00
|
|
|
usebetatoolbar: '1',
|
|
|
|
usecodemirror: '1',
|
|
|
|
'visualeditor-enable': '0',
|
|
|
|
'visualeditor-newwikitext': '0'
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
2023-04-03 17:14:23 +00:00
|
|
|
async enableWikitext2017EditorWithCodeMirror() {
|
|
|
|
await this.setPreferences( {
|
2021-01-08 11:14:55 +00:00
|
|
|
usebetatoolbar: null,
|
2020-12-18 16:32:22 +00:00
|
|
|
usecodemirror: '1',
|
|
|
|
'visualeditor-enable': '1',
|
|
|
|
'visualeditor-newwikitext': '1'
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = new UserPreferences();
|