]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/e2e/src/po/login.po.ts
Remove browserstack.err
[github/Chocobozzz/PeerTube.git] / client / e2e / src / po / login.po.ts
CommitLineData
3419e0e1 1import { go } from '../utils'
5f92c4dc
C
2
3export class LoginPage {
6d210220 4
814e9e07
C
5 constructor (private isMobileDevice: boolean) {
6
7 }
8
9 async login (username: string, password: string, url = '/login') {
10 await go(url)
5f92c4dc 11
814e9e07 12 await browser.execute(`window.localStorage.setItem('no_account_setup_warning_modal', 'true')`)
3419e0e1
C
13 await browser.execute(`window.localStorage.setItem('no_instance_config_warning_modal', 'true')`)
14 await browser.execute(`window.localStorage.setItem('no_welcome_modal', 'true')`)
51b66ea7 15
814e9e07
C
16 await $('input#username').setValue(username)
17 await $('input#password').setValue(password)
0b33c520 18
3419e0e1 19 await browser.pause(1000)
5f92c4dc 20
3419e0e1 21 await $('form input[type=submit]').click()
5f92c4dc 22
814e9e07
C
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')
84c7cde6
C
44 }
45
6d210220 46 async logout () {
814e9e07
C
47 const loggedInMore = $('.logged-in-more')
48
49 await loggedInMore.waitForClickable()
50 await loggedInMore.click()
6d210220 51
814e9e07 52 const logout = $('.dropdown-item*=Log out')
6d210220 53
814e9e07
C
54 await logout.waitForClickable()
55 await logout.click()
6d210220 56
814e9e07
C
57 await browser.waitUntil(() => {
58 return $('.login-buttons-block, my-error-page a[href="/login"]').isDisplayed()
59 })
6d210220
C
60 }
61
1db86422
C
62 async ensureIsLoggedInAs (displayName: string) {
63 await this.getLoggedInInfoElem().waitForExist()
64
65 await expect(this.getLoggedInInfoElem()).toHaveText(displayName)
66 }
67
3419e0e1
C
68 private getLoggedInInfoElem () {
69 return $('.logged-in-display-name')
5f92c4dc 70 }
6d210220
C
71
72 private getSuffix () {
73 return browser.config.baseUrl
74 ? browser.config.baseUrl.slice(-1)
75 : '1'
76 }
5f92c4dc 77}