1 const assert
= require( 'assert' ),
2 HistoryPage
= require( '../pageobjects/history.page' ),
3 UserLoginPage
= require( 'wdio-mediawiki/LoginPage' ),
4 Util
= require( 'wdio-mediawiki/Util' );
6 describe( 'Rollback with confirmation', function () {
11 // disable VisualEditor welcome dialog
12 browser
.deleteCookie();
14 browser
.localStorage( 'POST', { key
: 've-beta-welcome-dialog', value
: '1' } );
16 // Enable rollback confirmation for admin user
17 // Requires user to log in again, handled by deleteCookie() call in beforeEach function
18 UserLoginPage
.loginAdmin();
21 browser
.execute( function () {
22 return ( new mw
.Api() ).saveOption(
23 'showrollbackconfirmation',
29 beforeEach( function () {
30 browser
.deleteCookie();
32 content
= Util
.getTestString( 'beforeEach-content-' );
33 name
= Util
.getTestString( 'BeforeEach-name-' );
35 HistoryPage
.vandalizePage( name
, content
);
37 UserLoginPage
.loginAdmin();
38 HistoryPage
.open( name
);
41 it( 'should offer rollback options for admin users', function () {
42 assert
.strictEqual( HistoryPage
.rollback
.getText(), 'rollback 1 edit' );
44 HistoryPage
.rollback
.click();
46 assert
.strictEqual( HistoryPage
.rollbackConfirmable
.getText(), 'Rollback of one edit?' );
47 assert
.strictEqual( HistoryPage
.rollbackConfirmableYes
.getText(), 'Rollback' );
48 assert
.strictEqual( HistoryPage
.rollbackConfirmableNo
.getText(), 'Cancel' );
51 it( 'should offer a way to cancel rollbacks', function () {
52 HistoryPage
.rollback
.click();
53 HistoryPage
.rollbackConfirmableNo
.click();
57 assert
.strictEqual( HistoryPage
.heading
.getText(), 'Revision history of "' + name
+ '"' );
60 it( 'should perform rollbacks after confirming intention', function () {
61 HistoryPage
.rollback
.click();
62 HistoryPage
.rollbackConfirmableYes
.click();
64 // waitUntil indirectly asserts that the content we are looking for is present
65 browser
.waitUntil( function () {
66 return browser
.getText( '#firstHeading' ) === 'Action complete';
67 }, 5000, 'Expected rollback page to appear.' );
71 describe( 'Rollback without confirmation', function () {
76 // disable VisualEditor welcome dialog
77 browser
.deleteCookie();
79 browser
.localStorage( 'POST', { key
: 've-beta-welcome-dialog', value
: '1' } );
81 // Disable rollback confirmation for admin user
82 // Requires user to log in again, handled by deleteCookie() call in beforeEach function
83 UserLoginPage
.loginAdmin();
86 browser
.execute( function () {
87 return ( new mw
.Api() ).saveOption(
88 'showrollbackconfirmation',
94 beforeEach( function () {
95 browser
.deleteCookie();
97 content
= Util
.getTestString( 'beforeEach-content-' );
98 name
= Util
.getTestString( 'BeforeEach-name-' );
100 HistoryPage
.vandalizePage( name
, content
);
102 UserLoginPage
.loginAdmin();
103 HistoryPage
.open( name
);
106 it( 'should perform rollback without asking the user to confirm', function () {
107 HistoryPage
.rollback
.click();
109 // waitUntil indirectly asserts that the content we are looking for is present
110 browser
.waitUntil( function () {
111 return HistoryPage
.headingText
=== 'Action complete';
112 }, 5000, 'Expected rollback page to appear.' );