selenium: Create local ./log directory if needed
[lhc/web/wiklou.git] / tests / selenium / specs / user.js
1 const assert = require( 'assert' ),
2 CreateAccountPage = require( '../pageobjects/createaccount.page' ),
3 PreferencesPage = require( '../pageobjects/preferences.page' ),
4 UserLoginPage = require( '../pageobjects/userlogin.page' );
5
6 describe( 'User', function () {
7 var password,
8 username;
9
10 before( function () {
11 // disable VisualEditor welcome dialog
12 UserLoginPage.open();
13 browser.localStorage( 'POST', { key: 've-beta-welcome-dialog', value: '1' } );
14 } );
15
16 beforeEach( function () {
17 browser.deleteCookie();
18 username = `User-${Math.random().toString()}`;
19 password = Math.random().toString();
20 } );
21
22 it( 'should be able to create account', function () {
23 // create
24 CreateAccountPage.createAccount( username, password );
25
26 // check
27 assert.equal( CreateAccountPage.heading.getText(), `Welcome, ${username}!` );
28 } );
29
30 it( 'should be able to log in', function () {
31 // create
32 browser.call( function () {
33 return CreateAccountPage.apiCreateAccount( username, password );
34 } );
35
36 // log in
37 UserLoginPage.login( username, password );
38
39 // check
40 assert.equal( UserLoginPage.userPage.getText(), username );
41 } );
42
43 it( 'should be able to change preferences', function () {
44 var realName = Math.random().toString();
45
46 // create
47 browser.call( function () {
48 return CreateAccountPage.apiCreateAccount( username, password );
49 } );
50
51 // log in
52 UserLoginPage.login( username, password );
53
54 // change
55 PreferencesPage.changeRealName( realName );
56
57 // check
58 assert.equal( PreferencesPage.realName.getValue(), realName );
59 } );
60 } );