From 5bdfa604f102a5e51b5152457cd1a16d79177e26 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 19 Jan 2023 09:30:05 +0100 Subject: Add E2E client tests for signup approval --- client/e2e/src/po/login.po.ts | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'client/e2e/src/po/login.po.ts') diff --git a/client/e2e/src/po/login.po.ts b/client/e2e/src/po/login.po.ts index bc1854dbc..f1d13a2b0 100644 --- a/client/e2e/src/po/login.po.ts +++ b/client/e2e/src/po/login.po.ts @@ -6,7 +6,14 @@ export class LoginPage { } - async login (username: string, password: string, url = '/login') { + async login (options: { + username: string + password: string + displayName?: string + url?: string + }) { + const { username, password, url = '/login', displayName = username } = options + await go(url) await browser.execute(`window.localStorage.setItem('no_account_setup_warning_modal', 'true')`) @@ -27,27 +34,40 @@ export class LoginPage { await menuToggle.click() - await this.ensureIsLoggedInAs(username) + await this.ensureIsLoggedInAs(displayName) await menuToggle.click() } else { - await this.ensureIsLoggedInAs(username) + await this.ensureIsLoggedInAs(displayName) } } + async getLoginError (username: string, password: string) { + await go('/login') + + await $('input#username').setValue(username) + await $('input#password').setValue(password) + + await browser.pause(1000) + + await $('form input[type=submit]').click() + + return $('.alert-danger').getText() + } + async loginAsRootUser () { - return this.login('root', 'test' + this.getSuffix()) + return this.login({ username: 'root', password: 'test' + this.getSuffix() }) } loginOnPeerTube2 () { - return this.login('e2e', process.env.PEERTUBE2_E2E_PASSWORD, 'https://peertube2.cpy.re/login') + return this.login({ username: 'e2e', password: process.env.PEERTUBE2_E2E_PASSWORD, url: 'https://peertube2.cpy.re/login' }) } async logout () { - const loggedInMore = $('.logged-in-more') + const loggedInDropdown = $('.logged-in-more .logged-in-info') - await loggedInMore.waitForClickable() - await loggedInMore.click() + await loggedInDropdown.waitForClickable() + await loggedInDropdown.click() const logout = $('.dropdown-item*=Log out') -- cgit v1.2.3