From 5b94394a1a6d471f897d14ac62fe7bec5f9a74c2 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 27 Feb 2023 10:44:32 +0100 Subject: Fix E2E with firefox --- client/e2e/src/po/login.po.ts | 4 ++++ client/e2e/src/suites-local/signup.e2e-spec.ts | 6 +++--- client/e2e/src/utils/hooks.ts | 2 +- client/e2e/src/utils/mock-smtp.ts | 17 +++++++++-------- client/e2e/wdio.local-test.conf.ts | 26 ++++++++++++++++---------- client/e2e/wdio.local.conf.ts | 14 +++++++++----- 6 files changed, 42 insertions(+), 27 deletions(-) (limited to 'client/e2e') diff --git a/client/e2e/src/po/login.po.ts b/client/e2e/src/po/login.po.ts index f1d13a2b0..30469cf1b 100644 --- a/client/e2e/src/po/login.po.ts +++ b/client/e2e/src/po/login.po.ts @@ -60,6 +60,10 @@ export class LoginPage { } loginOnPeerTube2 () { + if (!process.env.PEERTUBE2_E2E_PASSWORD) { + throw new Error('PEERTUBE2_E2E_PASSWORD env is missing for user e2e on peertube2.cpy.re') + } + return this.login({ username: 'e2e', password: process.env.PEERTUBE2_E2E_PASSWORD, url: 'https://peertube2.cpy.re/login' }) } diff --git a/client/e2e/src/suites-local/signup.e2e-spec.ts b/client/e2e/src/suites-local/signup.e2e-spec.ts index 7c822a6e6..ad0cc218e 100644 --- a/client/e2e/src/suites-local/signup.e2e-spec.ts +++ b/client/e2e/src/suites-local/signup.e2e-spec.ts @@ -244,9 +244,9 @@ describe('Signup', () => { before(async () => { // FIXME: typings are wrong, get returns a promise - emailPort = await browser.sharedStore.get('emailPort') as unknown as number + emailPort = await (browser.sharedStore.get(browser.config.baseUrl + '-emailPort') as unknown as Promise) - MockSMTPServer.Instance.collectEmails(emailPort, emails) + await MockSMTPServer.Instance.collectEmails(emailPort, emails) }) describe('Direct registration', function () { @@ -404,7 +404,7 @@ describe('Signup', () => { }) }) - before(() => { + after(() => { MockSMTPServer.Instance.kill() }) }) diff --git a/client/e2e/src/utils/hooks.ts b/client/e2e/src/utils/hooks.ts index e57584b44..1daff5fcc 100644 --- a/client/e2e/src/utils/hooks.ts +++ b/client/e2e/src/utils/hooks.ts @@ -32,7 +32,7 @@ async function beforeLocalSession (config: { baseUrl: string }, capabilities: { config.baseUrl = 'http://localhost:900' + appInstance - await setValue('emailPort', emailPort) + await setValue(config.baseUrl + '-emailPort', emailPort) } async function onBrowserStackPrepare () { diff --git a/client/e2e/src/utils/mock-smtp.ts b/client/e2e/src/utils/mock-smtp.ts index 614477d7d..be6f8b259 100644 --- a/client/e2e/src/utils/mock-smtp.ts +++ b/client/e2e/src/utils/mock-smtp.ts @@ -1,11 +1,10 @@ -import { ChildProcess } from 'child_process' import MailDev from '@peertube/maildev' class MockSMTPServer { private static instance: MockSMTPServer private started = false - private emailChildProcess: ChildProcess + private maildev: any private emails: object[] collectEmails (port: number, emailsCollection: object[]) { @@ -16,18 +15,20 @@ class MockSMTPServer { return res(undefined) } - const maildev = new MailDev({ + this.maildev = new MailDev({ ip: '127.0.0.1', smtp: port, disableWeb: true, silent: true }) - maildev.on('new', email => { + this.maildev.on('new', email => { this.emails.push(email) + + console.log('pushed email', email) }) - maildev.listen(err => { + this.maildev.listen(err => { if (err) return rej(err) this.started = true @@ -38,11 +39,11 @@ class MockSMTPServer { } kill () { - if (!this.emailChildProcess) return + if (!this.maildev) return - process.kill(this.emailChildProcess.pid) + this.maildev.close() - this.emailChildProcess = null + this.maildev = null MockSMTPServer.instance = null } diff --git a/client/e2e/wdio.local-test.conf.ts b/client/e2e/wdio.local-test.conf.ts index bc15123a0..3c19e4e9a 100644 --- a/client/e2e/wdio.local-test.conf.ts +++ b/client/e2e/wdio.local-test.conf.ts @@ -8,6 +8,12 @@ const prefs = { // Chrome headless does not support prefs process.env.LANG = 'en' +// https://github.com/mozilla/geckodriver/issues/1354#issuecomment-479456411 +process.env.MOZ_HEADLESS_WIDTH = '1280' +process.env.MOZ_HEADLESS_HEIGHT = '1024' + +const windowSizeArg = `--window-size=${process.env.MOZ_HEADLESS_WIDTH},${process.env.MOZ_HEADLESS_HEIGHT}` + module.exports = { config: { ...mainConfig, @@ -22,19 +28,19 @@ module.exports = { browserName: 'chrome', acceptInsecureCerts: true, 'goog:chromeOptions': { - args: [ '--disable-gpu', '--window-size=1280,1024' ], + args: [ '--disable-gpu', windowSizeArg ], + prefs + } + }, + { + browserName: 'firefox', + 'moz:firefoxOptions': { + binary: '/usr/bin/firefox-developer-edition', + args: [ '--headless', windowSizeArg ], + prefs } } - // { - // browserName: 'firefox', - // 'moz:firefoxOptions': { - // binary: '/usr/bin/firefox-developer-edition', - // args: [ '--headless', '--window-size=1280,1024' ], - - // prefs - // } - // } ], services: [ 'chromedriver', 'geckodriver', 'shared-store' ], diff --git a/client/e2e/wdio.local.conf.ts b/client/e2e/wdio.local.conf.ts index 27c6e867b..903235b86 100644 --- a/client/e2e/wdio.local.conf.ts +++ b/client/e2e/wdio.local.conf.ts @@ -1,11 +1,15 @@ import { afterLocalSuite, beforeLocalSession, beforeLocalSuite } from './src/utils' import { config as mainConfig } from './wdio.main.conf' -const prefs = { - 'intl.accept_languages': 'en' -} +const prefs = { 'intl.accept_languages': 'en' } process.env.LANG = 'en' +// https://github.com/mozilla/geckodriver/issues/1354#issuecomment-479456411 +process.env.MOZ_HEADLESS_WIDTH = '1280' +process.env.MOZ_HEADLESS_HEIGHT = '1024' + +const windowSizeArg = `--window-size=${process.env.MOZ_HEADLESS_WIDTH},${process.env.MOZ_HEADLESS_HEIGHT}` + module.exports = { config: { ...mainConfig, @@ -18,7 +22,7 @@ module.exports = { { browserName: 'chrome', 'goog:chromeOptions': { - args: [ '--headless', '--disable-gpu', '--window-size=1280,1024' ], + args: [ '--headless', '--disable-gpu', windowSizeArg ], prefs } }, @@ -26,7 +30,7 @@ module.exports = { browserName: 'firefox', 'moz:firefoxOptions': { binary: '/usr/bin/firefox-developer-edition', - args: [ '--headless', '--window-size=1280,1024' ], + args: [ '--headless', windowSizeArg ], prefs } -- cgit v1.2.3