X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fe2e%2Fsrc%2Fpo%2Flogin.po.ts;h=91bf46e302225a9103f216931f91c372bb01a5ac;hb=57702d2537db0e1bbefd58d87b5097baad6acde7;hp=2c4561b7de08853f9247fca54d6ec50be24ed3fa;hpb=371d4c60639e405ce8a503bea1395e9102fbba84;p=github%2FChocobozzz%2FPeerTube.git 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' export class LoginPage { - async loginAsRootUser () { - await go('/login') + constructor (private isMobileDevice: boolean) { + + } + + async login (username: string, password: string, url = '/login') { + await go(url) + await browser.execute(`window.localStorage.setItem('no_account_setup_warning_modal', 'true')`) await browser.execute(`window.localStorage.setItem('no_instance_config_warning_modal', 'true')`) await browser.execute(`window.localStorage.setItem('no_welcome_modal', 'true')`) - await $('input#username').setValue('root') - await $('input#password').setValue('test' + this.getSuffix()) + await $('input#username').setValue(username) + await $('input#password').setValue(password) await browser.pause(1000) await $('form input[type=submit]').click() - await this.ensureIsLoggedInAs('root') + const menuToggle = $('.top-left-block span[role=button]') + + if (this.isMobileDevice) { + await browser.pause(1000) + + await menuToggle.click() + } + + await this.ensureIsLoggedInAs(username) + + if (this.isMobileDevice) { + await menuToggle.click() + } + } + + async loginAsRootUser () { + return this.login('root', 'test' + this.getSuffix()) + } + + loginOnPeerTube2 () { + return this.login('e2e', process.env.PEERTUBE2_E2E_PASSWORD, 'https://peertube2.cpy.re/login') } async logout () { - await $('.logged-in-more').click() + const loggedInMore = $('.logged-in-more') + + await loggedInMore.waitForClickable() + await loggedInMore.click() - const logout = () => $('.dropdown-item*=Log out') + const logout = $('.dropdown-item*=Log out') - await logout().waitForDisplayed() - await logout().click() + await logout.waitForClickable() + await logout.click() - await $('.login-buttons-block').waitForDisplayed() + await browser.waitUntil(() => { + return $('.login-buttons-block, my-error-page a[href="/login"]').isDisplayed() + }) } async ensureIsLoggedInAs (displayName: string) {