2020-12-18 16:32:22 +00:00
|
|
|
'use strict';
|
|
|
|
|
2024-05-10 21:59:07 +00:00
|
|
|
const Api = require( 'wdio-mediawiki/Api' ),
|
|
|
|
BlankPage = require( 'wdio-mediawiki/BlankPage' ),
|
|
|
|
LoginPage = require( 'wdio-mediawiki/LoginPage' ),
|
|
|
|
Util = require( 'wdio-mediawiki/Util' );
|
2020-12-18 16:32:22 +00:00
|
|
|
|
|
|
|
class UserPreferences {
|
2024-05-10 21:59:07 +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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
async setPreferences( preferences ) {
|
|
|
|
await BlankPage.open();
|
2020-12-18 16:32:22 +00:00
|
|
|
Util.waitForModuleState( 'mediawiki.base' );
|
|
|
|
|
2024-05-10 21:59:07 +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 );
|
|
|
|
}
|
|
|
|
|
2024-05-10 21:59:07 +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'
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
2024-05-10 21:59:07 +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();
|