mediawiki-extensions-CodeMi.../tests/selenium/userpreferences.js
Adam Wight 27f964e240 Browser tests for CodeMirror (wikitext 2017 editor)
Bug: T270240
Change-Id: If1a2530e428122713277fbe87cd015cb729ab550
Depends-On: I2ba889e1a5dd03549d8d7cb00678a30882ff03fe
2021-01-11 12:47:49 +01:00

38 lines
864 B
JavaScript

'use strict';
const BlankPage = require( 'wdio-mediawiki/BlankPage' );
const Util = require( 'wdio-mediawiki/Util' );
class UserPreferences {
setPreferences( preferences ) {
BlankPage.open();
Util.waitForModuleState( 'mediawiki.base' );
return browser.execute( function ( prefs ) {
return mw.loader.using( 'mediawiki.api' ).then( function () {
return new mw.Api().saveOptions( prefs );
} );
}, preferences );
}
enableWikitext2010EditorWithCodeMirror() {
this.setPreferences( {
usebetatoolbar: '1',
usecodemirror: '1',
'visualeditor-enable': '0',
'visualeditor-newwikitext': '0'
} );
}
enableWikitext2017EditorWithCodeMirror() {
this.setPreferences( {
usebetatoolbar: null,
usecodemirror: '1',
'visualeditor-enable': '1',
'visualeditor-newwikitext': '1'
} );
}
}
module.exports = new UserPreferences();