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