1 import { go } from '../utils'
3 export class LoginPage {
5 constructor (private isMobileDevice: boolean) {
9 async login (username: string, password: string, url = '/login') {
12 await browser.execute(`window.localStorage.setItem('no_account_setup_warning_modal', 'true')`)
13 await browser.execute(`window.localStorage.setItem('no_instance_config_warning_modal', 'true')`)
14 await browser.execute(`window.localStorage.setItem('no_welcome_modal', 'true')`)
16 await $('input#username').setValue(username)
17 await $('input#password').setValue(password)
19 await browser.pause(1000)
21 await $('form input[type=submit]').click()
23 if (this.isMobileDevice) {
24 const menuToggle = $('.top-left-block span[role=button]')
26 await $('h2=Our content selection').waitForDisplayed()
28 await menuToggle.click()
30 await this.ensureIsLoggedInAs(username)
32 await menuToggle.click()
34 await this.ensureIsLoggedInAs(username)
38 async loginAsRootUser () {
39 return this.login('root', 'test' + this.getSuffix())
43 return this.login('e2e', process.env.PEERTUBE2_E2E_PASSWORD, 'https://peertube2.cpy.re/login')
47 const loggedInMore = $('.logged-in-more')
49 await loggedInMore.waitForClickable()
50 await loggedInMore.click()
52 const logout = $('.dropdown-item*=Log out')
54 await logout.waitForClickable()
57 await browser.waitUntil(() => {
58 return $('.login-buttons-block, my-error-page a[href="/login"]').isDisplayed()
62 async ensureIsLoggedInAs (displayName: string) {
63 await this.getLoggedInInfoElem().waitForExist()
65 await expect(this.getLoggedInInfoElem()).toHaveText(displayName)
68 private getLoggedInInfoElem () {
69 return $('.logged-in-display-name')
72 private getSuffix () {
73 return browser.config.baseUrl
74 ? browser.config.baseUrl.slice(-1)