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 browser
.deleteAllCookies();
13 // Enable rollback confirmation for admin user
14 // Requires user to log in again, handled by deleteCookie() call in beforeEach function
15 UserLoginPage
.loginAdmin();
16 HistoryPage
.toggleRollbackConfirmationSetting( true );
19 beforeEach( function () {
20 browser
.deleteAllCookies();
22 content
= Util
.getTestString( 'beforeEach-content-' );
23 name
= Util
.getTestString( 'BeforeEach-name-' );
25 HistoryPage
.vandalizePage( name
, content
);
27 UserLoginPage
.loginAdmin();
28 HistoryPage
.open( name
);
31 it
.skip( 'should offer rollback options for admin users', function () {
32 assert
.strictEqual( HistoryPage
.rollback
.getText(), 'rollback 1 edit' );
34 HistoryPage
.rollbackLink
.click();
36 assert
.strictEqual( HistoryPage
.rollbackConfirmable
.getText(), 'Please confirm:' );
37 assert
.strictEqual( HistoryPage
.rollbackConfirmableYes
.getText(), 'Rollback' );
38 assert
.strictEqual( HistoryPage
.rollbackConfirmableNo
.getText(), 'Cancel' );
41 it
.skip( 'should offer a way to cancel rollbacks', function () {
42 HistoryPage
.rollback
.click();
44 HistoryPage
.rollbackConfirmableNo
.waitForDisplayed( 5000 );
46 HistoryPage
.rollbackConfirmableNo
.click();
48 browser
.pause( 1000 ); // Waiting to ensure we are NOT redirected and stay on the same page
50 assert
.strictEqual( HistoryPage
.heading
.getText(), 'Revision history of "' + name
+ '"' );
53 it
.skip( 'should perform rollbacks after confirming intention', function () {
54 HistoryPage
.rollback
.click();
56 HistoryPage
.rollbackConfirmableYes
.waitForDisplayed( 5000 );
58 HistoryPage
.rollbackConfirmableYes
.click();
60 // waitUntil indirectly asserts that the content we are looking for is present
61 browser
.waitUntil( function () {
62 return browser
.getText( '#firstHeading' ) === 'Action complete';
63 }, 5000, 'Expected rollback page to appear.' );
66 it
.skip( 'should verify rollbacks via GET requests are confirmed on a follow-up page', function () {
67 var rollbackActionUrl
= HistoryPage
.rollbackLink
.getAttribute( 'href' );
68 browser
.url( rollbackActionUrl
);
70 browser
.waitUntil( function () {
71 return HistoryPage
.rollbackNonJsConfirmable
.getText() === 'Revert edits to this page?';
72 }, 5000, 'Expected rollback confirmation page to appear for GET-based rollbacks.' );
74 HistoryPage
.rollbackNonJsConfirmableYes
.click();
76 browser
.waitUntil( function () {
77 return browser
.getText( '#firstHeading' ) === 'Action complete';
78 }, 5000, 'Expected rollback page to appear.' );
83 describe( 'Rollback without confirmation', function () {
88 browser
.deleteAllCookies();
90 // Disable rollback confirmation for admin user
91 // Requires user to log in again, handled by deleteCookie() call in beforeEach function
92 UserLoginPage
.loginAdmin();
93 HistoryPage
.toggleRollbackConfirmationSetting( false );
96 beforeEach( function () {
97 browser
.deleteAllCookies();
99 content
= Util
.getTestString( 'beforeEach-content-' );
100 name
= Util
.getTestString( 'BeforeEach-name-' );
102 HistoryPage
.vandalizePage( name
, content
);
104 UserLoginPage
.loginAdmin();
105 HistoryPage
.open( name
);
108 it( 'should perform rollback via POST request without asking the user to confirm', function () {
109 HistoryPage
.rollback
.click();
111 // waitUntil indirectly asserts that the content we are looking for is present
112 browser
.waitUntil( function () {
113 return HistoryPage
.heading
.getText() === 'Action complete';
114 }, 5000, 'Expected rollback page to appear.' );
117 it
.skip( 'should perform rollback via GET request without asking the user to confirm', function () {
118 var rollbackActionUrl
= HistoryPage
.rollbackLink
.getAttribute( 'href' );
119 browser
.url( rollbackActionUrl
);
121 browser
.waitUntil( function () {
122 return browser
.getText( '#firstHeading' ) === 'Action complete';
123 }, 5000, 'Expected rollback page to appear.' );