]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/e2e/src/po/login.po.ts
Add E2E tests for signup
[github/Chocobozzz/PeerTube.git] / client / e2e / src / po / login.po.ts
1 import { go } from '../utils'
2
3 export class LoginPage {
4
5 async loginAsRootUser () {
6 await go('/login')
7
8 await browser.execute(`window.localStorage.setItem('no_instance_config_warning_modal', 'true')`)
9 await browser.execute(`window.localStorage.setItem('no_welcome_modal', 'true')`)
10
11 await $('input#username').setValue('root')
12 await $('input#password').setValue('test' + this.getSuffix())
13
14 await browser.pause(1000)
15
16 await $('form input[type=submit]').click()
17
18 await this.ensureIsLoggedInAs('root')
19 }
20
21 async logout () {
22 await $('.logged-in-more').click()
23
24 const logout = () => $('.dropdown-item*=Log out')
25
26 await logout().waitForDisplayed()
27 await logout().click()
28
29 await $('.login-buttons-block').waitForDisplayed()
30 }
31
32 async ensureIsLoggedInAs (displayName: string) {
33 await this.getLoggedInInfoElem().waitForExist()
34
35 await expect(this.getLoggedInInfoElem()).toHaveText(displayName)
36 }
37
38 private getLoggedInInfoElem () {
39 return $('.logged-in-display-name')
40 }
41
42 private getSuffix () {
43 return browser.config.baseUrl
44 ? browser.config.baseUrl.slice(-1)
45 : '1'
46 }
47 }