Merge "resourceloader: Switch Xml::encodeJsCall call in getDeprecationInformation"
[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 // disable VisualEditor welcome dialog
12 browser.deleteCookie();
13 UserLoginPage.open();
14 browser.localStorage( 'POST', { key: 've-beta-welcome-dialog', value: '1' } );
15
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 );
20 } );
21
22 beforeEach( function () {
23 browser.deleteCookie();
24
25 content = Util.getTestString( 'beforeEach-content-' );
26 name = Util.getTestString( 'BeforeEach-name-' );
27
28 HistoryPage.vandalizePage( name, content );
29
30 UserLoginPage.loginAdmin();
31 HistoryPage.open( name );
32 } );
33
34 it( 'should offer rollback options for admin users', function () {
35 assert.strictEqual( HistoryPage.rollback.getText(), 'rollback 1 edit' );
36
37 HistoryPage.rollback.click();
38
39 assert.strictEqual( HistoryPage.rollbackConfirmable.getText(), 'Please confirm:' );
40 assert.strictEqual( HistoryPage.rollbackConfirmableYes.getText(), 'Rollback' );
41 assert.strictEqual( HistoryPage.rollbackConfirmableNo.getText(), 'Cancel' );
42 } );
43
44 it.skip( 'should offer a way to cancel rollbacks', function () {
45 HistoryPage.rollback.click();
46
47 HistoryPage.rollbackConfirmableNo.waitForVisible( 5000 );
48
49 HistoryPage.rollbackConfirmableNo.click();
50
51 browser.pause( 1000 ); // Waiting to ensure we are NOT redirected and stay on the same page
52
53 assert.strictEqual( HistoryPage.heading.getText(), 'Revision history of "' + name + '"' );
54 } );
55
56 it.skip( 'should perform rollbacks after confirming intention', function () {
57 HistoryPage.rollback.click();
58
59 HistoryPage.rollbackConfirmableYes.waitForVisible( 5000 );
60
61 HistoryPage.rollbackConfirmableYes.click();
62
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.' );
67 } );
68
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 );
72
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.' );
76
77 HistoryPage.rollbackNonJsConfirmableYes.click();
78
79 browser.waitUntil( function () {
80 return browser.getText( '#firstHeading' ) === 'Action complete';
81 }, 5000, 'Expected rollback page to appear.' );
82 } );
83
84 } );
85
86 describe( 'Rollback without confirmation', function () {
87 var content,
88 name;
89
90 before( function () {
91 // disable VisualEditor welcome dialog
92 browser.deleteCookie();
93 UserLoginPage.open();
94 browser.localStorage( 'POST', { key: 've-beta-welcome-dialog', value: '1' } );
95
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 );
100 } );
101
102 beforeEach( function () {
103 browser.deleteCookie();
104
105 content = Util.getTestString( 'beforeEach-content-' );
106 name = Util.getTestString( 'BeforeEach-name-' );
107
108 HistoryPage.vandalizePage( name, content );
109
110 UserLoginPage.loginAdmin();
111 HistoryPage.open( name );
112 } );
113
114 it( 'should perform rollback via POST request without asking the user to confirm', function () {
115 HistoryPage.rollback.click();
116
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.' );
121 } );
122
123 it.skip( 'should perform rollback via GET request without asking the user to confirm', function () {
124 var rollbackActionUrl = HistoryPage.rollbackLink.getAttribute( 'href' );
125 browser.url( rollbackActionUrl );
126
127 browser.waitUntil( function () {
128 return browser.getText( '#firstHeading' ) === 'Action complete';
129 }, 5000, 'Expected rollback page to appear.' );
130 } );
131 } );