Debian Codegraph @

tests/selenium/specs/user.js

raw symbols SCIP
1 // This file is used at Selenium/Explanation/Page object pattern
2 // https://www.mediawiki.org/wiki/Selenium/Explanation/Page_object_pattern
3
4 'use strict';
5
6 const CreateAccountPage = require( 'wdio-mediawiki/CreateAccountPage' );
7 const EditPage = require( '../pageobjects/edit.page' );
8 const LoginPage = require( 'wdio-mediawiki/LoginPage' );
9 const Api = require( 'wdio-mediawiki/Api' );
10 const Util = require( 'wdio-mediawiki/Util' );
11
12 describe( 'User', () => {
13 let password, username, bot;
14
15 before( async () => {
16 bot = await Api.bot();
17 } );
18
19 beforeEach( async () => {
20 await browser.deleteAllCookies();
21 username = Util.getTestString( 'User-' );
22 password = Util.getTestString();
23 } );
24
25 it( 'should be able to create account', async () => {
26 // create
27 await CreateAccountPage.createAccount( username, password );
28
29 // check
30 await expect( CreateAccountPage.heading ).toHaveText( `Welcome, ${ username }!` );
31 } );
32
33 it( 'should be able to log in', async () => {
34 // create
35 await Api.createAccount( bot, username, password );
36
37 // log in
38 await LoginPage.login( username, password );
39
40 // check
41 const actualUsername = await LoginPage.getActualUsername();
42 expect( actualUsername ).toBe( username );
43 } );
44
45 it( 'named user should see extra signup form fields when creating an account', async () => {
46 await Api.createAccount( bot, username, password );
47 await LoginPage.login( username, password );
48
49 await CreateAccountPage.open();
50
51 await expect( CreateAccountPage.username ).toExist();
52 await expect( CreateAccountPage.password ).toExist();
53 await expect( CreateAccountPage.tempPasswordInput ).toExist(
54 { message: 'Named users should have the option to have a temporary password sent on signup (T328718)' }
55 );
56 await expect( CreateAccountPage.reasonInput ).toExist(
57 { message: 'Named users should have to provide a reason for their account creation (T328718)' }
58 );
59 } );
60
61 it( 'temporary user should not see signup form fields relevant to named users', async () => {
62 const pageTitle = Util.getTestString( 'TempUserSignup-TestPage-' );
63 const pageText = Util.getTestString();
64
65 await EditPage.edit( pageTitle, pageText );
66 await EditPage.openCreateAccountPageAsTempUser();
67
68 await expect( CreateAccountPage.username ).toExist();
69 await expect( CreateAccountPage.password ).toExist();
70 await expect( CreateAccountPage.tempPasswordInput ).not.toExist(
71 { message: 'Temporary users should not have the option to have a temporary password sent on signup (T328718)' }
72 );
73 await expect( CreateAccountPage.reasonInput ).not.toExist(
74 { message: 'Temporary users should not have to provide a reason for their account creation (T328718)' }
75 );
76 } );
77
78 // NOTE: This test can't run parallel with other account creation tests (T199393)
79 it( 'temporary user should be able to create account', async () => {
80 const pageTitle = Util.getTestString( 'TempUserSignup-TestPage-' );
81 const pageText = Util.getTestString();
82
83 await EditPage.edit( pageTitle, pageText );
84 await EditPage.openCreateAccountPageAsTempUser();
85
86 await CreateAccountPage.submitForm( username, password );
87
88 const actualUsername = await LoginPage.getActualUsername();
89 expect( actualUsername ).toBe( username );
90 await expect( CreateAccountPage.heading ).toHaveText( `Welcome, ${ username }!` );
91 } );
92 } );