Merge "tests: Fix broken assertion in ApiQueryAllPagesTest"
[lhc/web/wiklou.git] / tests / selenium / pageobjects / history.page.js
1 const Page = require( 'wdio-mediawiki/Page' );
2 const Api = require( 'wdio-mediawiki/Api' );
3 const Util = require( 'wdio-mediawiki/Util' );
4
5 class HistoryPage extends Page {
6 get heading() { return $( '#firstHeading' ); }
7 get comment() { return $( '#pagehistory .comment' ); }
8 get rollback() { return $( '.mw-rollback-link' ); }
9 get rollbackLink() { return $( '.mw-rollback-link a' ); }
10 get rollbackConfirmable() { return $( '.mw-rollback-link .jquery-confirmable-text' ); }
11 get rollbackConfirmableYes() { return $( '.mw-rollback-link .jquery-confirmable-button-yes' ); }
12 get rollbackConfirmableNo() { return $( '.mw-rollback-link .jquery-confirmable-button-no' ); }
13 get rollbackNonJsConfirmable() { return $( '.mw-htmlform .oo-ui-fieldsetLayout-header .oo-ui-labelElement-label' ); }
14 get rollbackNonJsConfirmableYes() { return $( '.mw-htmlform .mw-htmlform-submit-buttons button' ); }
15
16 open( title ) {
17 super.openTitle( title, { action: 'history' } );
18 }
19
20 toggleRollbackConfirmationSetting( enable ) {
21 Util.waitForModuleState( 'mediawiki.api', 'ready', 5000 );
22 return browser.execute( function ( enable ) {
23 return new mw.Api().saveOption(
24 'showrollbackconfirmation',
25 enable ? '1' : '0'
26 );
27 }, enable );
28 }
29
30 vandalizePage( name, content ) {
31 const vandalUsername = 'Evil_' + browser.config.mwUser;
32
33 browser.call( function () {
34 return Api.edit( name, content );
35 } );
36
37 browser.call( function () {
38 return Api.createAccount(
39 vandalUsername, browser.config.mwPwd
40 );
41 } );
42
43 browser.call( function () {
44 return Api.edit(
45 name,
46 'Vandalized: ' + content,
47 vandalUsername
48 );
49 } );
50 }
51 }
52
53 module.exports = new HistoryPage();