Merge "Add browser test for basic watchlist functionality"
[lhc/web/wiklou.git] / tests / selenium / specs / specialwatchlist.js
1 const assert = require( 'assert' ),
2 Api = require( 'wdio-mediawiki/Api' ),
3 WatchlistPage = require( '../pageobjects/watchlist.page' ),
4 WatchablePage = require( '../pageobjects/watchable.page' ),
5 LoginPage = require( 'wdio-mediawiki/LoginPage' );
6
7 describe( 'Special:Watchlist', function () {
8 let username, password;
9
10 function getTestString( prefix = '' ) {
11 return prefix + Math.random().toString() + '-öäü-♠♣♥♦';
12 }
13
14 before( function () {
15 username = getTestString( 'user-' );
16 password = getTestString( 'password-' );
17
18 browser.call( function () {
19 return Api.createAccount( username, password );
20 } );
21 } );
22
23 beforeEach( function () {
24 browser.deleteCookie();
25 LoginPage.login( username, password );
26 } );
27
28 it( 'should show page with new edit', function () {
29 const title = getTestString( 'Title-' );
30
31 browser.call( function () {
32 return Api.edit( title, getTestString() ); // create
33 } );
34 WatchablePage.watch( title );
35 browser.call( function () {
36 return Api.edit( title, getTestString() ); // edit
37 } );
38
39 WatchlistPage.open();
40
41 assert.strictEqual( WatchlistPage.titles[ 0 ].getText(), title );
42 } );
43
44 } );