Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix E2E tests

Chocobozzzcaa926248e4d
diff --git a/client/e2e/src/po/my-account.po.ts b/client/e2e/src/po/my-account.po.ts
index 360e546e67..b3f0da0923 100644
--- a/client/e2e/src/po/my-account.po.ts
+++ b/client/e2e/src/po/my-account.po.ts
@@ -76,8 +76,8 @@ export class MyAccountPage {
await passwordInput.setValue(password)
const submit = $('my-account-change-email input[type=submit]')
- await submit.waitForClickable()
await submit.scrollIntoView({ block: 'center' }) // Avoid issues with fixed header
+ await submit.waitForClickable()
await submit.click()
}
diff --git a/client/e2e/src/po/player.po.ts b/client/e2e/src/po/player.po.ts
index d00be8c98e..4fc0343b67 100644
--- a/client/e2e/src/po/player.po.ts
+++ b/client/e2e/src/po/player.po.ts
@@ -84,9 +84,9 @@ export class PlayerPage {
}
async hasPoster () {
- const property = await $('.video-js .vjs-poster').getCSSProperty('background-image')
+ const img = $('.video-js .vjs-poster img')
- return property.value.startsWith('url(')
+ return await img.isDisplayed() && (await img.getAttribute('src')).startsWith('http')
}
private async clickOnPlayButton () {
diff --git a/client/e2e/src/po/signup.po.ts b/client/e2e/src/po/signup.po.ts
index 3ee21db52e..b52b5da2d9 100644
--- a/client/e2e/src/po/signup.po.ts
+++ b/client/e2e/src/po/signup.po.ts
@@ -15,6 +15,7 @@ export class SignupPage {
async validateStep () {
const next = $('button[type=submit]')
+ await next.scrollIntoView({ block: 'center' })
await next.waitForClickable()
await next.click()
}
diff --git a/client/e2e/src/po/video-watch.po.ts b/client/e2e/src/po/video-watch.po.ts
index 390280e991..c8dcb6e68f 100644
--- a/client/e2e/src/po/video-watch.po.ts
+++ b/client/e2e/src/po/video-watch.po.ts
@@ -82,31 +82,14 @@ export class VideoWatchPage {
return $('.modal-content .modal-footer .primary-button').click()
}
- private async getVideoNameElement () {
- // We have 2 video info name block, pick the first that is not empty
- const elem = async () => {
- const elems = await $$('.video-info-first-row .video-info-name').filter(e => e.isDisplayed())
-
- return elems[0]
- }
-
- await browser.waitUntil(async () => {
- const e = await elem()
-
- return e?.isDisplayed()
- })
-
- return elem()
+ private getVideoNameElement () {
+ return $('.video-info-first-row .video-info-name')
}
// ---------------------------------------------------------------------------
// Video password
// ---------------------------------------------------------------------------
- isPasswordProtected () {
- return $('#confirmInput').isExisting()
- }
-
async fillVideoPassword (videoPassword: string) {
const videoPasswordInput = $('input#confirmInput')
await videoPasswordInput.waitForClickable()
@@ -151,7 +134,7 @@ export class VideoWatchPage {
await this.clickOnMoreDropdownIcon()
// We need the await expression
- return $$('.dropdown-menu.show .dropdown-item').mapSeries(async item => {
+ return $$('.dropdown-menu.show .dropdown-item').forEach(async item => {
const content = await item.getText()
if (content.includes('Manage')) {
diff --git a/client/e2e/src/suites-local/custom-server-defaults.e2e-spec.ts b/client/e2e/src/suites-local/custom-server-defaults.e2e-spec.ts
index 34cf82fded..1654db02b1 100644
--- a/client/e2e/src/suites-local/custom-server-defaults.e2e-spec.ts
+++ b/client/e2e/src/suites-local/custom-server-defaults.e2e-spec.ts
@@ -1,7 +1,7 @@
import { LoginPage } from '../po/login.po'
import { VideoPublishPage } from '../po/video-publish.po'
import { VideoWatchPage } from '../po/video-watch.po'
-import { getScreenshotPath, go, isMobileDevice, isSafari, prepareWebBrowser, waitServerUp } from '../utils'
+import { go, isMobileDevice, isSafari, prepareWebBrowser, waitServerUp } from '../utils'
describe('Custom server defaults', () => {
let videoPublishPage: VideoPublishPage
@@ -15,7 +15,7 @@ describe('Custom server defaults', () => {
videoPublishPage = new VideoPublishPage()
videoWatchPage = new VideoWatchPage(isMobileDevice(), isSafari())
- await prepareWebBrowser()
+ await prepareWebBrowser({ hidePrivacyConcerns: false })
})
describe('Publish default values', function () {
@@ -92,8 +92,4 @@ describe('Custom server defaults', () => {
await checkP2P(false)
})
})
-
- after(async () => {
- await browser.saveScreenshot(getScreenshotPath('after-test.png'))
- })
})
diff --git a/client/e2e/src/suites-local/nsfw.e2e-spec.ts b/client/e2e/src/suites-local/nsfw.e2e-spec.ts
index 2be7c0ca92..4d34ad632c 100644
--- a/client/e2e/src/suites-local/nsfw.e2e-spec.ts
+++ b/client/e2e/src/suites-local/nsfw.e2e-spec.ts
@@ -95,7 +95,7 @@ describe('NSFW', () => {
await goOnPage()
for (const video of videos) {
- await browser.saveScreenshot(getScreenshotPath('before-test.png'))
+ await browser.saveScreenshot(getScreenshotPath('before-nsfw-test.png'))
await checkVideo({ policy, videoName: video, nsfwTooltip })
}
}
@@ -103,7 +103,7 @@ describe('NSFW', () => {
for (const video of videos) {
await videoSearchPage.search(video)
- await browser.saveScreenshot(getScreenshotPath('before-test.png'))
+ await browser.saveScreenshot(getScreenshotPath('before-nsfw-test.png'))
await checkVideo({ policy, videoName: video, nsfwTooltip })
}
}
diff --git a/client/e2e/src/suites-local/player-settings.e2e-spec.ts b/client/e2e/src/suites-local/player-settings.e2e-spec.ts
index f3039e57c5..65f1278e8f 100644
--- a/client/e2e/src/suites-local/player-settings.e2e-spec.ts
+++ b/client/e2e/src/suites-local/player-settings.e2e-spec.ts
@@ -3,7 +3,7 @@ import { LoginPage } from '../po/login.po'
import { MyAccountPage } from '../po/my-account.po'
import { VideoPublishPage } from '../po/video-publish.po'
import { VideoWatchPage } from '../po/video-watch.po'
-import { getScreenshotPath, go, isMobileDevice, isSafari, prepareWebBrowser, waitServerUp } from '../utils'
+import { go, isMobileDevice, isSafari, prepareWebBrowser, waitServerUp } from '../utils'
describe('Player settings', () => {
let videoPublishPage: VideoPublishPage
@@ -21,7 +21,7 @@ describe('Player settings', () => {
myAccountPage = new MyAccountPage()
anonymousSettingsPage = new AnonymousSettingsPage()
- await prepareWebBrowser()
+ await prepareWebBrowser({ hidePrivacyConcerns: false })
})
describe('P2P', function () {
@@ -80,8 +80,4 @@ describe('Player settings', () => {
await checkP2P(false)
})
})
-
- after(async () => {
- await browser.saveScreenshot(getScreenshotPath('after-test.png'))
- })
})
diff --git a/client/e2e/src/suites-local/plugins.e2e-spec.ts b/client/e2e/src/suites-local/plugins.e2e-spec.ts
index 8f45ed1645..e3fede40ea 100644
--- a/client/e2e/src/suites-local/plugins.e2e-spec.ts
+++ b/client/e2e/src/suites-local/plugins.e2e-spec.ts
@@ -1,7 +1,7 @@
import { AdminPluginPage } from '../po/admin-plugin.po'
import { LoginPage } from '../po/login.po'
import { VideoPublishPage } from '../po/video-publish.po'
-import { getCheckbox, getScreenshotPath, isMobileDevice, prepareWebBrowser, waitServerUp } from '../utils'
+import { getCheckbox, isMobileDevice, prepareWebBrowser, waitServerUp } from '../utils'
describe('Plugins', () => {
let videoPublishPage: VideoPublishPage
@@ -83,8 +83,4 @@ describe('Plugins', () => {
await expectSubmitError(false)
})
-
- after(async () => {
- await browser.saveScreenshot(getScreenshotPath('after-test.png'))
- })
})
diff --git a/client/e2e/src/suites-local/publish-live.e2e-spec.ts b/client/e2e/src/suites-local/publish-live.e2e-spec.ts
index 555d827a04..d8390a5379 100644
--- a/client/e2e/src/suites-local/publish-live.e2e-spec.ts
+++ b/client/e2e/src/suites-local/publish-live.e2e-spec.ts
@@ -2,7 +2,7 @@ import { AdminConfigPage } from '../po/admin-config.po'
import { LoginPage } from '../po/login.po'
import { VideoPublishPage } from '../po/video-publish.po'
import { VideoWatchPage } from '../po/video-watch.po'
-import { getScreenshotPath, isMobileDevice, isSafari, prepareWebBrowser, waitServerUp } from '../utils'
+import { isMobileDevice, isSafari, prepareWebBrowser, waitServerUp } from '../utils'
describe('Publish live', function () {
let videoPublishPage: VideoPublishPage
@@ -54,8 +54,4 @@ describe('Publish live', function () {
expect(await videoPublishPage.getLiveState()).toEqual('normal')
})
-
- after(async () => {
- await browser.saveScreenshot(getScreenshotPath('after-test.png'))
- })
})
diff --git a/client/e2e/src/suites-local/publish.e2e-spec.ts b/client/e2e/src/suites-local/publish.e2e-spec.ts
index 125a2a4f06..3a9e434d3f 100644
--- a/client/e2e/src/suites-local/publish.e2e-spec.ts
+++ b/client/e2e/src/suites-local/publish.e2e-spec.ts
@@ -76,8 +76,4 @@ describe('Publish video', () => {
await videoPublishPage.refresh('second video')
})
})
-
- after(async () => {
- await browser.saveScreenshot(getScreenshotPath('after-test.png'))
- })
})
diff --git a/client/e2e/src/suites-local/user-settings.e2e-spec.ts b/client/e2e/src/suites-local/user-settings.e2e-spec.ts
index 50578b086f..2b98993fe9 100644
--- a/client/e2e/src/suites-local/user-settings.e2e-spec.ts
+++ b/client/e2e/src/suites-local/user-settings.e2e-spec.ts
@@ -73,7 +73,5 @@ describe('User settings', () => {
after(async () => {
MockSMTPServer.Instance.kill()
-
- await browser.saveScreenshot(getScreenshotPath('after-test.png'))
})
})
diff --git a/client/e2e/src/suites-local/video-password.e2e-spec.ts b/client/e2e/src/suites-local/video-password.e2e-spec.ts
index fa3d838f9a..90f0d1368d 100644
--- a/client/e2e/src/suites-local/video-password.e2e-spec.ts
+++ b/client/e2e/src/suites-local/video-password.e2e-spec.ts
@@ -4,7 +4,7 @@ import { PlayerPage } from '../po/player.po'
import { SignupPage } from '../po/signup.po'
import { VideoPublishPage } from '../po/video-publish.po'
import { VideoWatchPage } from '../po/video-watch.po'
-import { getScreenshotPath, go, isMobileDevice, isSafari, prepareWebBrowser, waitServerUp } from '../utils'
+import { go, isMobileDevice, isSafari, prepareWebBrowser, waitServerUp } from '../utils'
describe('Password protected videos', () => {
let videoPublishPage: VideoPublishPage
@@ -106,8 +106,6 @@ describe('Password protected videos', () => {
it('Should play video without password', async function () {
await go(passwordProtectedVideoUrl)
- expect(!await videoWatchPage.isPasswordProtected())
-
await videoWatchPage.waitWatchVideoName(passwordProtectedVideoName)
expect(await videoWatchPage.getPrivacy()).toBe('Password protected')
@@ -176,8 +174,6 @@ describe('Password protected videos', () => {
it('Should requires password to play video', async function () {
await go(passwordProtectedVideoUrl)
- expect(await videoWatchPage.isPasswordProtected())
-
await videoWatchPage.fillVideoPassword(videoPassword)
await videoWatchPage.waitWatchVideoName(passwordProtectedVideoName)
@@ -208,8 +204,6 @@ describe('Password protected videos', () => {
it('Should requires password to play video', async function () {
await go(passwordProtectedVideoUrl)
- expect(await videoWatchPage.isPasswordProtected())
-
await videoWatchPage.fillVideoPassword(videoPassword)
await videoWatchPage.waitWatchVideoName(passwordProtectedVideoName)
@@ -229,8 +223,4 @@ describe('Password protected videos', () => {
await videoWatchPage.waitWatchVideoName(publicVideoName2, 40 * 1000)
})
})
-
- after(async () => {
- await browser.saveScreenshot(getScreenshotPath('after-test.png'))
- })
})
diff --git a/client/e2e/src/utils/common.ts b/client/e2e/src/utils/common.ts
index 693a58131d..72a5aaf7fe 100644
--- a/client/e2e/src/utils/common.ts
+++ b/client/e2e/src/utils/common.ts
@@ -37,15 +37,24 @@ export async function go (url: string) {
// ---------------------------------------------------------------------------
-export async function prepareWebBrowser () {
- if (isMobileDevice()) return
+export async function prepareWebBrowser (options: {
+ hidePrivacyConcerns?: boolean // default true
+} = {}) {
+ const { hidePrivacyConcerns = true } = options
- // Window size on chromium doesn't seem to work in "new" headless mode
- if (process.env.MOZ_HEADLESS_WIDTH) {
- await browser.setWindowSize(+process.env.MOZ_HEADLESS_WIDTH, +process.env.MOZ_HEADLESS_HEIGHT)
+ if (hidePrivacyConcerns) {
+ try {
+ await browser.execute(() => {
+ localStorage.setItem('video-watch-privacy-concern', 'true')
+ })
+ } catch {
+ console.log('Cannot set local storage to hide privacy concerns')
+ }
}
- await browser.maximizeWindow()
+ if (!isMobileDevice() && process.env.MOZ_HEADLESS_WIDTH) {
+ await browser.setWindowSize(+process.env.MOZ_HEADLESS_WIDTH, +process.env.MOZ_HEADLESS_HEIGHT)
+ }
}
export async function waitServerUp () {
diff --git a/client/e2e/src/utils/elements.ts b/client/e2e/src/utils/elements.ts
index 4bd35062b0..d57f0a399d 100644
--- a/client/e2e/src/utils/elements.ts
+++ b/client/e2e/src/utils/elements.ts
@@ -14,6 +14,7 @@ export async function setCheckboxEnabled (name: string, enabled: boolean) {
const checkbox = await getCheckbox(name)
+ await checkbox.scrollIntoView({ block: 'center' })
await checkbox.waitForClickable()
await checkbox.click()
}
diff --git a/client/e2e/src/utils/hooks.ts b/client/e2e/src/utils/hooks.ts
index aa91d12e63..473ea4f2a9 100644
--- a/client/e2e/src/utils/hooks.ts
+++ b/client/e2e/src/utils/hooks.ts
@@ -1,7 +1,7 @@
+import { setValue } from '@wdio/shared-store-service'
import { ChildProcessWithoutNullStreams } from 'node:child_process'
import { basename } from 'node:path'
-import { setValue } from '@wdio/shared-store-service'
-import { createScreenshotsDirectory } from './files'
+import { createScreenshotsDirectory, getScreenshotPath } from './files'
import { runCommand, runServer } from './server'
let appInstance: number
@@ -21,6 +21,12 @@ function afterLocalSuite () {
app = undefined
}
+async function afterLocalTest (test: { file: string }) {
+ const filename = basename(test.file).replace(/\.ts$/, '')
+
+ await browser.saveScreenshot(getScreenshotPath(`${filename}-after-test.png`))
+}
+
async function beforeLocalSession (config: { baseUrl: string }, capabilities: { browserName: string }) {
createScreenshotsDirectory()
@@ -48,11 +54,12 @@ function onBrowserStackComplete () {
}
export {
- beforeLocalSession,
afterLocalSuite,
+ afterLocalTest,
+ beforeLocalSession,
beforeLocalSuite,
- onBrowserStackPrepare,
- onBrowserStackComplete
+ onBrowserStackComplete,
+ onBrowserStackPrepare
}
// ---------------------------------------------------------------------------
diff --git a/client/e2e/wdio.local-test.conf.ts b/client/e2e/wdio.local-test.conf.ts
index c837ab534e..667e674872 100644
--- a/client/e2e/wdio.local-test.conf.ts
+++ b/client/e2e/wdio.local-test.conf.ts
@@ -1,4 +1,4 @@
-import { afterLocalSuite, beforeLocalSuite, beforeLocalSession } from './src/utils'
+import { afterLocalSuite, afterLocalTest, beforeLocalSession, beforeLocalSuite } from './src/utils'
import { config as mainConfig } from './wdio.main.conf'
const prefs = {
@@ -28,7 +28,7 @@ module.exports = {
'browserName': 'chrome',
'acceptInsecureCerts': true,
'goog:chromeOptions': {
- args: [ '--headless', '--disable-gpu', windowSizeArg ],
+ args: [ '--disable-gpu', windowSizeArg ],
prefs
}
}
@@ -47,6 +47,7 @@ module.exports = {
beforeSession: beforeLocalSession,
beforeSuite: beforeLocalSuite,
- afterSuite: afterLocalSuite
+ afterSuite: afterLocalSuite,
+ afterTest: afterLocalTest
} as WebdriverIO.Config
}
diff --git a/client/e2e/wdio.local.conf.ts b/client/e2e/wdio.local.conf.ts
index b6807cb771..6dfbf6faf8 100644
--- a/client/e2e/wdio.local.conf.ts
+++ b/client/e2e/wdio.local.conf.ts
@@ -1,4 +1,4 @@
-import { afterLocalSuite, beforeLocalSession, beforeLocalSuite } from './src/utils'
+import { afterLocalSuite, afterLocalTest, beforeLocalSession, beforeLocalSuite } from './src/utils'
import { config as mainConfig } from './wdio.main.conf'
const prefs = { 'intl.accept_languages': 'en' }
@@ -42,6 +42,7 @@ module.exports = {
beforeSession: beforeLocalSession,
beforeSuite: beforeLocalSuite,
- afterSuite: afterLocalSuite
+ afterSuite: afterLocalSuite,
+ afterTest: afterLocalTest
} as WebdriverIO.Config
}