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();
19 HistoryPage
.toggleRollbackConfirmationSetting( true );
22 beforeEach( function () {
23 browser
.deleteCookie();
25 content
= Util
.getTestString( 'beforeEach-content-' );
26 name
= Util
.getTestString( 'BeforeEach-name-' );
28 HistoryPage
.vandalizePage( name
, content
);
30 UserLoginPage
.loginAdmin();
31 HistoryPage
.open( name
);
34 it( 'should offer rollback options for admin users', function () {
35 assert
.strictEqual( HistoryPage
.rollback
.getText(), 'rollback 1 edit' );
37 HistoryPage
.rollback
.click();
39 assert
.strictEqual( HistoryPage
.rollbackConfirmable
.getText(), 'Please confirm:' );
40 assert
.strictEqual( HistoryPage
.rollbackConfirmableYes
.getText(), 'Rollback' );
41 assert
.strictEqual( HistoryPage
.rollbackConfirmableNo
.getText(), 'Cancel' );
44 it
.skip( 'should offer a way to cancel rollbacks', function () {
45 HistoryPage
.rollback
.click();
47 HistoryPage
.rollbackConfirmableNo
.waitForVisible( 5000 );
49 HistoryPage
.rollbackConfirmableNo
.click();
51 browser
.pause( 1000 ); // Waiting to ensure we are NOT redirected and stay on the same page
53 assert
.strictEqual( HistoryPage
.heading
.getText(), 'Revision history of "' + name
+ '"' );
56 it
.skip( 'should perform rollbacks after confirming intention', function () {
57 HistoryPage
.rollback
.click();
59 HistoryPage
.rollbackConfirmableYes
.waitForVisible( 5000 );
61 HistoryPage
.rollbackConfirmableYes
.click();
63 // waitUntil indirectly asserts that the content we are looking for is present
64 browser
.waitUntil( function () {
65 return browser
.getText( '#firstHeading' ) === 'Action complete';
66 }, 5000, 'Expected rollback page to appear.' );
69 it
.skip( 'should verify rollbacks via GET requests are confirmed on a follow-up page', function () {
70 var rollbackActionUrl
= HistoryPage
.rollbackLink
.getAttribute( 'href' );
71 browser
.url( rollbackActionUrl
);
73 browser
.waitUntil( function () {
74 return HistoryPage
.rollbackNonJsConfirmable
.getText() === 'Revert edits to this page?';
75 }, 5000, 'Expected rollback confirmation page to appear for GET-based rollbacks.' );
77 HistoryPage
.rollbackNonJsConfirmableYes
.click();
79 browser
.waitUntil( function () {
80 return browser
.getText( '#firstHeading' ) === 'Action complete';
81 }, 5000, 'Expected rollback page to appear.' );
86 describe( 'Rollback without confirmation', function () {
91 // disable VisualEditor welcome dialog
92 browser
.deleteCookie();
94 browser
.localStorage( 'POST', { key
: 've-beta-welcome-dialog', value
: '1' } );
96 // Disable rollback confirmation for admin user
97 // Requires user to log in again, handled by deleteCookie() call in beforeEach function
98 UserLoginPage
.loginAdmin();
99 HistoryPage
.toggleRollbackConfirmationSetting( false );
102 beforeEach( function () {
103 browser
.deleteCookie();
105 content
= Util
.getTestString( 'beforeEach-content-' );
106 name
= Util
.getTestString( 'BeforeEach-name-' );
108 HistoryPage
.vandalizePage( name
, content
);
110 UserLoginPage
.loginAdmin();
111 HistoryPage
.open( name
);
114 it( 'should perform rollback via POST request without asking the user to confirm', function () {
115 HistoryPage
.rollback
.click();
117 // waitUntil indirectly asserts that the content we are looking for is present
118 browser
.waitUntil( function () {
119 return HistoryPage
.headingText
=== 'Action complete';
120 }, 5000, 'Expected rollback page to appear.' );
123 it( 'should perform rollback via GET request without asking the user to confirm', function () {
124 var rollbackActionUrl
= HistoryPage
.rollbackLink
.getAttribute( 'href' );
125 browser
.url( rollbackActionUrl
);
127 browser
.waitUntil( function () {
128 return browser
.getText( '#firstHeading' ) === 'Action complete';
129 }, 5000, 'Expected rollback page to appear.' );