From 814e9e07ba65446af8446dbbd2f0d70c85fd1b33 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 28 Oct 2022 11:19:54 +0200 Subject: Improve E2E tests Add tests for private video static endpoints Fix tests for local firefox --- client/e2e/src/po/admin-config.po.ts | 14 ++++++++-- client/e2e/src/po/login.po.ts | 50 ++++++++++++++++++++++++++++-------- client/e2e/src/po/my-account.po.ts | 4 +++ client/e2e/src/po/signup.po.ts | 3 ++- client/e2e/src/po/video-upload.po.ts | 10 +++++--- client/e2e/src/po/video-watch.po.ts | 6 ++++- 6 files changed, 70 insertions(+), 17 deletions(-) (limited to 'client/e2e/src/po') diff --git a/client/e2e/src/po/admin-config.po.ts b/client/e2e/src/po/admin-config.po.ts index 6d48a0fd7..27957a71f 100644 --- a/client/e2e/src/po/admin-config.po.ts +++ b/client/e2e/src/po/admin-config.po.ts @@ -14,8 +14,14 @@ export class AdminConfigPage { await $('.inner-form-title=' + waitTitles[tab]).waitForDisplayed() } - updateNSFWSetting (newValue: 'do_not_list' | 'blur' | 'display') { - return $('#instanceDefaultNSFWPolicy').selectByAttribute('value', newValue) + async updateNSFWSetting (newValue: 'do_not_list' | 'blur' | 'display') { + const elem = $('#instanceDefaultNSFWPolicy') + + await elem.waitForDisplayed() + await elem.scrollIntoView(false) // Avoid issues with fixed header on firefox + await elem.waitForClickable() + + return elem.selectByAttribute('value', newValue) } updateHomepage (newValue: string) { @@ -24,11 +30,15 @@ export class AdminConfigPage { async toggleSignup () { const checkbox = await getCheckbox('signupEnabled') + + await checkbox.waitForClickable() await checkbox.click() } async save () { const button = $('input[type=submit]') + + await button.waitForClickable() await button.click() } } 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) { diff --git a/client/e2e/src/po/my-account.po.ts b/client/e2e/src/po/my-account.po.ts index 8d5d878ce..222dbb569 100644 --- a/client/e2e/src/po/my-account.po.ts +++ b/client/e2e/src/po/my-account.po.ts @@ -25,6 +25,8 @@ export class MyAccountPage { await nsfw.waitForDisplayed() await nsfw.scrollIntoView(false) // Avoid issues with fixed header on firefox + await nsfw.waitForClickable() + await nsfw.selectByAttribute('value', newValue) await this.submitVideoSettings() @@ -43,6 +45,8 @@ export class MyAccountPage { private async submitVideoSettings () { const submit = $('my-user-video-settings input[type=submit]') + + await submit.waitForClickable() await submit.scrollIntoView(false) await submit.click() } diff --git a/client/e2e/src/po/signup.po.ts b/client/e2e/src/po/signup.po.ts index ef36dbcc4..7a17198cc 100644 --- a/client/e2e/src/po/signup.po.ts +++ b/client/e2e/src/po/signup.po.ts @@ -9,7 +9,7 @@ export class SignupPage { async clickOnRegisterInMenu () { const button = this.getRegisterMenuButton() - await button.waitForDisplayed() + await button.waitForClickable() await button.click() } @@ -22,6 +22,7 @@ export class SignupPage { async checkTerms () { const terms = await getCheckbox('terms') + await terms.waitForClickable() return terms.click() } diff --git a/client/e2e/src/po/video-upload.po.ts b/client/e2e/src/po/video-upload.po.ts index 8605139c9..7e7989763 100644 --- a/client/e2e/src/po/video-upload.po.ts +++ b/client/e2e/src/po/video-upload.po.ts @@ -11,8 +11,8 @@ export class VideoUploadPage { await $('.upload-video-container').waitForDisplayed() } - async uploadVideo () { - const fileToUpload = join(__dirname, '../../fixtures/video.mp4') + async uploadVideo (fixtureName: 'video.mp4' | 'video2.mp4' | 'video3.mp4') { + const fileToUpload = join(__dirname, '../../fixtures/' + fixtureName) const fileInputSelector = '.upload-video-container input[type=file]' const parentFileInput = '.upload-video-container .button-file' @@ -36,6 +36,7 @@ export class VideoUploadPage { async setAsNSFW () { const checkbox = await getCheckbox('nsfw') + await checkbox.waitForClickable() return checkbox.click() } @@ -45,7 +46,10 @@ export class VideoUploadPage { await nameInput.clearValue() await nameInput.setValue(videoName) - await this.getSecondStepSubmitButton().click() + const button = this.getSecondStepSubmitButton() + await button.waitForClickable() + + await button.click() return browser.waitUntil(async () => { return (await browser.getUrl()).includes('/w/') diff --git a/client/e2e/src/po/video-watch.po.ts b/client/e2e/src/po/video-watch.po.ts index 65bf21837..982c90908 100644 --- a/client/e2e/src/po/video-watch.po.ts +++ b/client/e2e/src/po/video-watch.po.ts @@ -49,7 +49,11 @@ export class VideoWatchPage { url = url.replace(':3333', ':9001') await go(url) - await $('.vjs-big-play-button').waitForDisplayed() + await this.waitEmbedForDisplayed() + } + + waitEmbedForDisplayed () { + return $('.vjs-big-play-button').waitForDisplayed() } isEmbedWarningDisplayed () { -- cgit v1.2.3