Fix E2E with firefox

pull/5665/head
Chocobozzz 2023-02-27 10:44:32 +01:00
parent 2be1fecc99
commit 5b94394a1a
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
10 changed files with 60 additions and 46 deletions

View File

@ -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' })
}

View File

@ -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<number>)
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()
})
})

View File

@ -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 () {

View File

@ -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
}

View File

@ -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' ],

View File

@ -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
}

View File

@ -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",

View File

@ -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"

View File

@ -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
}

View File

@ -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