aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-07-13 15:49:47 +0200
committerChocobozzz <me@florianbigard.com>2023-07-17 11:31:46 +0200
commite29221f855a7135bcfb45720e3600c7401939abb (patch)
treeb5c5e98e8c7f5e7c82688da891a723d1357c4a21
parent9684bc959ecc2ec8407aaf36d054c7e000991141 (diff)
downloadPeerTube-e29221f855a7135bcfb45720e3600c7401939abb.tar.gz
PeerTube-e29221f855a7135bcfb45720e3600c7401939abb.tar.zst
PeerTube-e29221f855a7135bcfb45720e3600c7401939abb.zip
Fix e2e tests
-rw-r--r--client/e2e/src/po/login.po.ts14
-rw-r--r--client/e2e/src/po/player.po.ts27
-rw-r--r--client/e2e/src/utils/common.ts7
-rw-r--r--client/e2e/tsconfig.json4
-rw-r--r--client/e2e/wdio.browserstack.conf.ts34
-rw-r--r--client/src/assets/player/shared/peertube/peertube-plugin.ts3
6 files changed, 63 insertions, 26 deletions
diff --git a/client/e2e/src/po/login.po.ts b/client/e2e/src/po/login.po.ts
index e2362ef51..a8606dbd2 100644
--- a/client/e2e/src/po/login.po.ts
+++ b/client/e2e/src/po/login.po.ts
@@ -1,4 +1,4 @@
1import { go } from '../utils' 1import { browserSleep, go, isAndroid, isMobileDevice } from '../utils'
2 2
3export class LoginPage { 3export class LoginPage {
4 4
@@ -23,9 +23,17 @@ export class LoginPage {
23 await $('input#username').setValue(username) 23 await $('input#username').setValue(username)
24 await $('input#password').setValue(password) 24 await $('input#password').setValue(password)
25 25
26 await browser.pause(1000) 26 await browserSleep(1000)
27 27
28 await $('form input[type=submit]').click() 28 const submit = $('.login-form-and-externals > form input[type=submit]')
29 await submit.click()
30
31 // Have to do this on Android, don't really know why
32 // I think we need to "escape" from the password input, so click twice on the submit button
33 if (isAndroid()) {
34 await browserSleep(2000)
35 await submit.click()
36 }
29 37
30 if (this.isMobileDevice) { 38 if (this.isMobileDevice) {
31 const menuToggle = $('.top-left-block span[role=button]') 39 const menuToggle = $('.top-left-block span[role=button]')
diff --git a/client/e2e/src/po/player.po.ts b/client/e2e/src/po/player.po.ts
index 33719da25..e41422359 100644
--- a/client/e2e/src/po/player.po.ts
+++ b/client/e2e/src/po/player.po.ts
@@ -29,29 +29,32 @@ export class PlayerPage {
29 } 29 }
30 30
31 async playAndPauseVideo (isAutoplay: boolean, waitUntilSec: number) { 31 async playAndPauseVideo (isAutoplay: boolean, waitUntilSec: number) {
32 const videojsElem = () => $('div.video-js') 32 // Autoplay is disabled on mobile and Safari
33 33 if (isIOS() || isSafari() || isMobileDevice() || isAutoplay === false) {
34 await videojsElem().waitForExist() 34 await this.playVideo()
35
36 // Autoplay is disabled on iOS and Safari
37 if (isIOS() || isSafari() || isMobileDevice()) {
38 // We can't play the video if it is not muted
39 await browser.execute(`document.querySelector('video').muted = true`)
40 await this.clickOnPlayButton()
41 } else if (isAutoplay === false) {
42 await this.clickOnPlayButton()
43 } 35 }
44 36
37 await $('div.video-js.vjs-has-started').waitForExist()
38
45 await browserSleep(2000) 39 await browserSleep(2000)
46 40
47 await browser.waitUntil(async () => { 41 await browser.waitUntil(async () => {
48 return (await this.getWatchVideoPlayerCurrentTime()) >= waitUntilSec 42 return (await this.getWatchVideoPlayerCurrentTime()) >= waitUntilSec
49 }) 43 })
50 44
51 await videojsElem().click() 45 // Pause video
46 await $('div.video-js').click()
52 } 47 }
53 48
54 async playVideo () { 49 async playVideo () {
50 await $('div.video-js.vjs-paused').waitForExist()
51
52 // Autoplay is disabled on iOS and Safari
53 if (isIOS() || isSafari() || isMobileDevice()) {
54 // We can't play the video if it is not muted
55 await browser.execute(`document.querySelector('video').muted = true`)
56 }
57
55 return this.clickOnPlayButton() 58 return this.clickOnPlayButton()
56 } 59 }
57 60
diff --git a/client/e2e/src/utils/common.ts b/client/e2e/src/utils/common.ts
index eb5f6b450..b04fe47f3 100644
--- a/client/e2e/src/utils/common.ts
+++ b/client/e2e/src/utils/common.ts
@@ -8,6 +8,12 @@ function isMobileDevice () {
8 return platformName === 'android' || platformName === 'ios' 8 return platformName === 'android' || platformName === 'ios'
9} 9}
10 10
11function isAndroid () {
12 const platformName = (browser.capabilities['platformName'] || '').toLowerCase()
13
14 return platformName === 'android'
15}
16
11function isSafari () { 17function isSafari () {
12 return browser.capabilities['browserName'] && 18 return browser.capabilities['browserName'] &&
13 browser.capabilities['browserName'].toLowerCase() === 'safari' 19 browser.capabilities['browserName'].toLowerCase() === 'safari'
@@ -41,6 +47,7 @@ export {
41 isMobileDevice, 47 isMobileDevice,
42 isSafari, 48 isSafari,
43 isIOS, 49 isIOS,
50 isAndroid,
44 waitServerUp, 51 waitServerUp,
45 go, 52 go,
46 browserSleep 53 browserSleep
diff --git a/client/e2e/tsconfig.json b/client/e2e/tsconfig.json
index c62ffa931..1291601c9 100644
--- a/client/e2e/tsconfig.json
+++ b/client/e2e/tsconfig.json
@@ -6,6 +6,10 @@
6 "esModuleInterop": true, 6 "esModuleInterop": true,
7 "module": "commonjs", 7 "module": "commonjs",
8 "target": "es5", 8 "target": "es5",
9 "typeRoots": [
10 "../node_modules/@types",
11 "../node_modules"
12 ],
9 "types": [ 13 "types": [
10 "node", 14 "node",
11 "@wdio/globals/types", 15 "@wdio/globals/types",
diff --git a/client/e2e/wdio.browserstack.conf.ts b/client/e2e/wdio.browserstack.conf.ts
index 0d68c8541..ecab74078 100644
--- a/client/e2e/wdio.browserstack.conf.ts
+++ b/client/e2e/wdio.browserstack.conf.ts
@@ -17,18 +17,32 @@ function buildMainOptions (sessionName: string) {
17 } 17 }
18} 18}
19 19
20function buildBStackDesktopOptions (sessionName: string, resolution: string, os?: string) { 20function buildBStackDesktopOptions (options: {
21 sessionName: string
22 resolution: string
23 os?: string
24 osVersion?: string
25}) {
26 const { sessionName, resolution, os, osVersion } = options
27
21 return { 28 return {
22 'bstack:options': { 29 'bstack:options': {
23 ...buildMainOptions(sessionName), 30 ...buildMainOptions(sessionName),
24 31
25 os, 32 os,
33 osVersion,
26 resolution 34 resolution
27 } 35 }
28 } 36 }
29} 37}
30 38
31function buildBStackMobileOptions (sessionName: string, deviceName: string, osVersion: string) { 39function buildBStackMobileOptions (options: {
40 sessionName: string
41 deviceName: string
42 osVersion: string
43}) {
44 const { sessionName, deviceName, osVersion } = options
45
32 return { 46 return {
33 'bstack:options': { 47 'bstack:options': {
34 ...buildMainOptions(sessionName), 48 ...buildMainOptions(sessionName),
@@ -53,45 +67,45 @@ module.exports = {
53 { 67 {
54 browserName: 'Chrome', 68 browserName: 'Chrome',
55 69
56 ...buildBStackDesktopOptions('Latest Chrome Desktop', '1280x1024') 70 ...buildBStackDesktopOptions({ sessionName: 'Latest Chrome Desktop', resolution: '1280x1024', os: 'Windows', osVersion: '8' })
57 }, 71 },
58 { 72 {
59 browserName: 'Firefox', 73 browserName: 'Firefox',
60 browserVersion: '78', // Very old ESR 74 browserVersion: '78', // Very old ESR
61 75
62 ...buildBStackDesktopOptions('Firefox ESR Desktop', '1280x1024', 'Windows') 76 ...buildBStackDesktopOptions({ sessionName: 'Firefox ESR Desktop', resolution: '1280x1024', os: 'Windows', osVersion: '8' })
63 }, 77 },
64 { 78 {
65 browserName: 'Safari', 79 browserName: 'Safari',
66 browserVersion: '12.1', 80 browserVersion: '12.1',
67 81
68 ...buildBStackDesktopOptions('Safari Desktop', '1280x1024') 82 ...buildBStackDesktopOptions({ sessionName: 'Safari Desktop', resolution: '1280x1024' })
69 }, 83 },
70 { 84 {
71 browserName: 'Firefox', 85 browserName: 'Firefox',
72 86
73 ...buildBStackDesktopOptions('Firefox Latest', '1280x1024') 87 ...buildBStackDesktopOptions({ sessionName: 'Firefox Latest', resolution: '1280x1024', os: 'Windows', osVersion: '8' })
74 }, 88 },
75 { 89 {
76 browserName: 'Edge', 90 browserName: 'Edge',
77 91
78 ...buildBStackDesktopOptions('Edge Latest', '1280x1024') 92 ...buildBStackDesktopOptions({ sessionName: 'Edge Latest', resolution: '1280x1024' })
79 }, 93 },
80 94
81 { 95 {
82 browserName: 'Chrome', 96 browserName: 'Chrome',
83 97
84 ...buildBStackMobileOptions('Latest Chrome Android', 'Samsung Galaxy S8', '7.0') 98 ...buildBStackMobileOptions({ sessionName: 'Latest Chrome Android', deviceName: 'Samsung Galaxy S8', osVersion: '7.0' })
85 }, 99 },
86 { 100 {
87 browserName: 'Safari', 101 browserName: 'Safari',
88 102
89 ...buildBStackMobileOptions('Safari iPhone', 'iPhone 8 Plus', '12.4') 103 ...buildBStackMobileOptions({ sessionName: 'Safari iPhone', deviceName: 'iPhone 8 Plus', osVersion: '12.4' })
90 }, 104 },
91 { 105 {
92 browserName: 'Safari', 106 browserName: 'Safari',
93 107
94 ...buildBStackMobileOptions('Safari iPad', 'iPad 7th', '13') 108 ...buildBStackMobileOptions({ sessionName: 'Safari iPad', deviceName: 'iPad 7th', osVersion: '13' })
95 } 109 }
96 ], 110 ],
97 111
diff --git a/client/src/assets/player/shared/peertube/peertube-plugin.ts b/client/src/assets/player/shared/peertube/peertube-plugin.ts
index 7e5a3ebb6..c405e37e0 100644
--- a/client/src/assets/player/shared/peertube/peertube-plugin.ts
+++ b/client/src/assets/player/shared/peertube/peertube-plugin.ts
@@ -315,7 +315,8 @@ class PeerTubePlugin extends Plugin {
315 } 315 }
316 316
317 private initCaptions () { 317 private initCaptions () {
318 debugLogger('Init captions with current subtitle ' + this.currentSubtitle) 318 if (this.currentSubtitle) debugLogger('Init captions with current subtitle ' + this.currentSubtitle)
319 else debugLogger('Init captions without current subtitle')
319 320
320 this.player.tech(true).clearTracks('text') 321 this.player.tech(true).clearTracks('text')
321 322