Selenium: Hide VE welcome and beta dialogs
[lhc/web/wiklou.git] / tests / selenium / specs / rollback.js
1 const assert = require( 'assert' ),
2 HistoryPage = require( '../pageobjects/history.page' ),
3 UserLoginPage = require( 'wdio-mediawiki/LoginPage' ),
4 Util = require( 'wdio-mediawiki/Util' );
5
6 describe( 'Rollback with confirmation', function () {
7 var content,
8 name;
9
10 before( function () {
11 browser.deleteAllCookies();
12
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 );
17 } );
18
19 beforeEach( function () {
20 browser.deleteAllCookies();
21
22 content = Util.getTestString( 'beforeEach-content-' );
23 name = Util.getTestString( 'BeforeEach-name-' );
24
25 HistoryPage.vandalizePage( name, content );
26
27 UserLoginPage.loginAdmin();
28 HistoryPage.open( name );
29 } );
30
31 it.skip( 'should offer rollback options for admin users', function () {
32 assert.strictEqual( HistoryPage.rollback.getText(), 'rollback 1 edit' );
33
34 HistoryPage.rollbackLink.click();
35
36 assert.strictEqual( HistoryPage.rollbackConfirmable.getText(), 'Please confirm:' );
37 assert.strictEqual( HistoryPage.rollbackConfirmableYes.getText(), 'Rollback' );
38 assert.strictEqual( HistoryPage.rollbackConfirmableNo.getText(), 'Cancel' );
39 } );
40
41 it.skip( 'should offer a way to cancel rollbacks', function () {
42 HistoryPage.rollback.click();
43
44 HistoryPage.rollbackConfirmableNo.waitForDisplayed( 5000 );
45
46 HistoryPage.rollbackConfirmableNo.click();
47
48 browser.pause( 1000 ); // Waiting to ensure we are NOT redirected and stay on the same page
49
50 assert.strictEqual( HistoryPage.heading.getText(), 'Revision history of "' + name + '"' );
51 } );
52
53 it.skip( 'should perform rollbacks after confirming intention', function () {
54 HistoryPage.rollback.click();
55
56 HistoryPage.rollbackConfirmableYes.waitForDisplayed( 5000 );
57
58 HistoryPage.rollbackConfirmableYes.click();
59
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.' );
64 } );
65
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 );
69
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.' );
73
74 HistoryPage.rollbackNonJsConfirmableYes.click();
75
76 browser.waitUntil( function () {
77 return browser.getText( '#firstHeading' ) === 'Action complete';
78 }, 5000, 'Expected rollback page to appear.' );
79 } );
80
81 } );
82
83 describe( 'Rollback without confirmation', function () {
84 var content,
85 name;
86
87 before( function () {
88 browser.deleteAllCookies();
89
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 );
94 } );
95
96 beforeEach( function () {
97 browser.deleteAllCookies();
98
99 content = Util.getTestString( 'beforeEach-content-' );
100 name = Util.getTestString( 'BeforeEach-name-' );
101
102 HistoryPage.vandalizePage( name, content );
103
104 UserLoginPage.loginAdmin();
105 HistoryPage.open( name );
106 } );
107
108 it( 'should perform rollback via POST request without asking the user to confirm', function () {
109 HistoryPage.rollback.click();
110
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.' );
115 } );
116
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 );
120
121 browser.waitUntil( function () {
122 return browser.getText( '#firstHeading' ) === 'Action complete';
123 }, 5000, 'Expected rollback page to appear.' );
124 } );
125 } );