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 } diff --git a/client/package.json b/client/package.json index 53fb02d12..9bad50362 100644 --- a/client/package.json +++ b/client/package.json @@ -86,7 +86,7 @@ "cache-chunk-store": "^3.0.0", "chart.js": "^3.8.0", "chartjs-plugin-zoom": "~1.2.1", - "chromedriver": "^107.0.3", + "chromedriver": "^110.0.0", "core-js": "^3.22.8", "css-loader": "^6.2.0", "debug": "^4.3.1", diff --git a/client/yarn.lock b/client/yarn.lock index 227f6b522..d9cd8a7ef 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -3278,10 +3278,10 @@ aws4@^1.8.0: resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.12.0.tgz#ce1c9d143389679e253b314241ea9aa5cec980d3" integrity sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg== -axios@^1.1.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/axios/-/axios-1.3.3.tgz#e7011384ba839b885007c9c9fae1ff23dceb295b" - integrity sha512-eYq77dYIFS77AQlhzEL937yUBSepBfPIe8FcgEDN35vMNZKMrs81pgnyrQpwfy4NF4b4XWX1Zgx7yX+25w8QJA== +axios@^1.2.1: + version "1.3.4" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.3.4.tgz#f5760cefd9cfb51fd2481acf88c05f67c4523024" + integrity sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ== dependencies: follow-redirects "^1.15.0" form-data "^4.0.0" @@ -3946,13 +3946,13 @@ chrome-trace-event@^1.0.2: resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz#1015eced4741e15d06664a957dbbf50d041e26ac" integrity sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg== -chromedriver@^107.0.3: - version "107.0.3" - resolved "https://registry.yarnpkg.com/chromedriver/-/chromedriver-107.0.3.tgz#330c0808bb14a53f13ab7e2b0c78adf3cdb4c14b" - integrity sha512-jmzpZgctCRnhYAn0l/NIjP4vYN3L8GFVbterTrRr2Ly3W5rFMb9H8EKGuM5JCViPKSit8FbE718kZTEt3Yvffg== +chromedriver@^110.0.0: + version "110.0.0" + resolved "https://registry.yarnpkg.com/chromedriver/-/chromedriver-110.0.0.tgz#d00a1a2976592d933faa8e9839e97692922834a4" + integrity sha512-Le6q8xrA/3fAt+g8qiN0YjsYxINIhQMC6wj9X3W5L77uN4NspEzklDrqYNwBcEVn7PcAEJ73nLlS7mTyZRspHA== dependencies: "@testim/chrome-version" "^1.1.3" - axios "^1.1.3" + axios "^1.2.1" compare-versions "^5.0.1" extract-zip "^2.0.1" https-proxy-agent "^5.0.1" diff --git a/server/tests/shared/mock-servers/mock-email.ts b/server/tests/shared/mock-servers/mock-email.ts index c518679c9..79bc22d58 100644 --- a/server/tests/shared/mock-servers/mock-email.ts +++ b/server/tests/shared/mock-servers/mock-email.ts @@ -1,4 +1,3 @@ -import { ChildProcess } from 'child_process' import MailDev from '@peertube/maildev' import { parallelTests, randomInt } from '@shared/core-utils' @@ -6,7 +5,7 @@ class MockSmtpServer { private static instance: MockSmtpServer private started = false - private emailChildProcess: ChildProcess + private maildev: any private emails: object[] private constructor () { } @@ -20,18 +19,18 @@ 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) }) - maildev.listen(err => { + this.maildev.listen(err => { if (err) return rej(err) this.started = true @@ -42,11 +41,11 @@ class MockSmtpServer { } kill () { - if (!this.emailChildProcess) return + if (!this.maildev) return - process.kill(this.emailChildProcess.pid) + this.maildev.shutdown() - this.emailChildProcess = null + this.maildev = null MockSmtpServer.instance = null } diff --git a/support/doc/development/tests.md b/support/doc/development/tests.md index 207d4f984..6eb499f0c 100644 --- a/support/doc/development/tests.md +++ b/support/doc/development/tests.md @@ -100,7 +100,7 @@ tail -f test1/logs/peertube.log | npm run parse-log -- --level debug --files - To run tests on local web browsers (comment web browsers you don't have in `client/e2e/wdio.local.conf.ts`): ```bash -$ npm run e2e:local +$ PEERTUBE2_E2E_PASSWORD=password npm run e2e:local ``` ### Browserstack tests