aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/e2e/src/po/login.po.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/e2e/src/po/login.po.ts')
-rw-r--r--client/e2e/src/po/login.po.ts50
1 files changed, 40 insertions, 10 deletions
diff --git a/client/e2e/src/po/login.po.ts b/client/e2e/src/po/login.po.ts
index 2c4561b7d..91bf46e30 100644
--- a/client/e2e/src/po/login.po.ts
+++ b/client/e2e/src/po/login.po.ts
@@ -2,31 +2,61 @@ import { go } from '../utils'
2 2
3export class LoginPage { 3export class LoginPage {
4 4
5 async loginAsRootUser () { 5 constructor (private isMobileDevice: boolean) {
6 await go('/login') 6
7 }
8
9 async login (username: string, password: string, url = '/login') {
10 await go(url)
7 11
12 await browser.execute(`window.localStorage.setItem('no_account_setup_warning_modal', 'true')`)
8 await browser.execute(`window.localStorage.setItem('no_instance_config_warning_modal', 'true')`) 13 await browser.execute(`window.localStorage.setItem('no_instance_config_warning_modal', 'true')`)
9 await browser.execute(`window.localStorage.setItem('no_welcome_modal', 'true')`) 14 await browser.execute(`window.localStorage.setItem('no_welcome_modal', 'true')`)
10 15
11 await $('input#username').setValue('root') 16 await $('input#username').setValue(username)
12 await $('input#password').setValue('test' + this.getSuffix()) 17 await $('input#password').setValue(password)
13 18
14 await browser.pause(1000) 19 await browser.pause(1000)
15 20
16 await $('form input[type=submit]').click() 21 await $('form input[type=submit]').click()
17 22
18 await this.ensureIsLoggedInAs('root') 23 const menuToggle = $('.top-left-block span[role=button]')
24
25 if (this.isMobileDevice) {
26 await browser.pause(1000)
27
28 await menuToggle.click()
29 }
30
31 await this.ensureIsLoggedInAs(username)
32
33 if (this.isMobileDevice) {
34 await menuToggle.click()
35 }
36 }
37
38 async loginAsRootUser () {
39 return this.login('root', 'test' + this.getSuffix())
40 }
41
42 loginOnPeerTube2 () {
43 return this.login('e2e', process.env.PEERTUBE2_E2E_PASSWORD, 'https://peertube2.cpy.re/login')
19 } 44 }
20 45
21 async logout () { 46 async logout () {
22 await $('.logged-in-more').click() 47 const loggedInMore = $('.logged-in-more')
48
49 await loggedInMore.waitForClickable()
50 await loggedInMore.click()
23 51
24 const logout = () => $('.dropdown-item*=Log out') 52 const logout = $('.dropdown-item*=Log out')
25 53
26 await logout().waitForDisplayed() 54 await logout.waitForClickable()
27 await logout().click() 55 await logout.click()
28 56
29 await $('.login-buttons-block').waitForDisplayed() 57 await browser.waitUntil(() => {
58 return $('.login-buttons-block, my-error-page a[href="/login"]').isDisplayed()
59 })
30 } 60 }
31 61
32 async ensureIsLoggedInAs (displayName: string) { 62 async ensureIsLoggedInAs (displayName: string) {