1 const assert
= require( 'assert' );
2 const HistoryPage
= require( '../pageobjects/history.page' );
3 const UserLoginPage
= require( 'wdio-mediawiki/LoginPage' );
4 const Util
= require( 'wdio-mediawiki/Util' );
6 describe( 'Rollback with confirmation', function () {
10 browser
.deleteAllCookies();
12 // Enable rollback confirmation for admin user
13 // Requires user to log in again, handled by deleteCookie() call in beforeEach function
14 UserLoginPage
.loginAdmin();
15 HistoryPage
.toggleRollbackConfirmationSetting( true );
18 beforeEach( function () {
19 browser
.deleteAllCookies();
21 content
= Util
.getTestString( 'beforeEach-content-' );
22 name
= Util
.getTestString( 'BeforeEach-name-' );
24 HistoryPage
.vandalizePage( name
, content
);
26 UserLoginPage
.loginAdmin();
27 HistoryPage
.open( name
);
30 it
.skip( 'should offer rollback options for admin users', function () {
31 assert
.strictEqual( HistoryPage
.rollback
.getText(), 'rollback 1 edit' );
33 HistoryPage
.rollbackLink
.click();
35 assert
.strictEqual( HistoryPage
.rollbackConfirmable
.getText(), 'Please confirm:' );
36 assert
.strictEqual( HistoryPage
.rollbackConfirmableYes
.getText(), 'Rollback' );
37 assert
.strictEqual( HistoryPage
.rollbackConfirmableNo
.getText(), 'Cancel' );
40 it
.skip( 'should offer a way to cancel rollbacks', function () {
41 HistoryPage
.rollback
.click();
43 HistoryPage
.rollbackConfirmableNo
.waitForDisplayed( 5000 );
45 HistoryPage
.rollbackConfirmableNo
.click();
47 browser
.pause( 1000 ); // Waiting to ensure we are NOT redirected and stay on the same page
49 assert
.strictEqual( HistoryPage
.heading
.getText(), 'Revision history of "' + name
+ '"' );
52 it
.skip( 'should perform rollbacks after confirming intention', function () {
53 HistoryPage
.rollback
.click();
55 HistoryPage
.rollbackConfirmableYes
.waitForDisplayed( 5000 );
57 HistoryPage
.rollbackConfirmableYes
.click();
59 // waitUntil indirectly asserts that the content we are looking for is present
60 browser
.waitUntil( function () {
61 return browser
.getText( '#firstHeading' ) === 'Action complete';
62 }, 5000, 'Expected rollback page to appear.' );
65 it
.skip( 'should verify rollbacks via GET requests are confirmed on a follow-up page', function () {
66 const rollbackActionUrl
= HistoryPage
.rollbackLink
.getAttribute( 'href' );
67 browser
.url( rollbackActionUrl
);
69 browser
.waitUntil( function () {
70 return HistoryPage
.rollbackNonJsConfirmable
.getText() === 'Revert edits to this page?';
71 }, 5000, 'Expected rollback confirmation page to appear for GET-based rollbacks.' );
73 HistoryPage
.rollbackNonJsConfirmableYes
.click();
75 browser
.waitUntil( function () {
76 return browser
.getText( '#firstHeading' ) === 'Action complete';
77 }, 5000, 'Expected rollback page to appear.' );
82 describe( 'Rollback without confirmation', function () {
86 browser
.deleteAllCookies();
88 // Disable rollback confirmation for admin user
89 // Requires user to log in again, handled by deleteCookie() call in beforeEach function
90 UserLoginPage
.loginAdmin();
91 HistoryPage
.toggleRollbackConfirmationSetting( false );
94 beforeEach( function () {
95 browser
.deleteAllCookies();
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
.skip( 'should perform rollback via POST request 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
.heading
.getText() === 'Action complete';
112 }, 5000, 'Expected rollback page to appear.' );
115 it
.skip( 'should perform rollback via GET request without asking the user to confirm', function () {
116 const rollbackActionUrl
= HistoryPage
.rollbackLink
.getAttribute( 'href' );
117 browser
.url( rollbackActionUrl
);
119 browser
.waitUntil( function () {
120 return browser
.getText( '#firstHeading' ) === 'Action complete';
121 }, 5000, 'Expected rollback page to appear.' );