]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix e2e tests
authorChocobozzz <me@florianbigard.com>
Thu, 13 Jul 2023 13:49:47 +0000 (15:49 +0200)
committerChocobozzz <me@florianbigard.com>
Mon, 17 Jul 2023 09:31:46 +0000 (11:31 +0200)
client/e2e/src/po/login.po.ts
client/e2e/src/po/player.po.ts
client/e2e/src/utils/common.ts
client/e2e/tsconfig.json
client/e2e/wdio.browserstack.conf.ts
client/src/assets/player/shared/peertube/peertube-plugin.ts

index e2362ef5175e61b003c5c47337f294ef47e04ae5..a8606dbd232949c403ee95ce8aa8fb1f029482af 100644 (file)
@@ -1,4 +1,4 @@
-import { go } from '../utils'
+import { browserSleep, go, isAndroid, isMobileDevice } from '../utils'
 
 export class LoginPage {
 
@@ -23,9 +23,17 @@ export class LoginPage {
     await $('input#username').setValue(username)
     await $('input#password').setValue(password)
 
-    await browser.pause(1000)
+    await browserSleep(1000)
 
-    await $('form input[type=submit]').click()
+    const submit = $('.login-form-and-externals > form input[type=submit]')
+    await submit.click()
+
+    // Have to do this on Android, don't really know why
+    // I think we need to "escape" from the password input, so click twice on the submit button
+    if (isAndroid()) {
+      await browserSleep(2000)
+      await submit.click()
+    }
 
     if (this.isMobileDevice) {
       const menuToggle = $('.top-left-block span[role=button]')
index 33719da250a4bd5649ed74596d1c26a84ad89afa..e41422359744c0716bb104d027b7b1ac7a75eff4 100644 (file)
@@ -29,29 +29,32 @@ export class PlayerPage {
   }
 
   async playAndPauseVideo (isAutoplay: boolean, waitUntilSec: number) {
-    const videojsElem = () => $('div.video-js')
-
-    await videojsElem().waitForExist()
-
-    // Autoplay is disabled on iOS and Safari
-    if (isIOS() || isSafari() || isMobileDevice()) {
-      // We can't play the video if it is not muted
-      await browser.execute(`document.querySelector('video').muted = true`)
-      await this.clickOnPlayButton()
-    } else if (isAutoplay === false) {
-      await this.clickOnPlayButton()
+    // Autoplay is disabled on mobile and Safari
+    if (isIOS() || isSafari() || isMobileDevice() || isAutoplay === false) {
+      await this.playVideo()
     }
 
+    await $('div.video-js.vjs-has-started').waitForExist()
+
     await browserSleep(2000)
 
     await browser.waitUntil(async () => {
       return (await this.getWatchVideoPlayerCurrentTime()) >= waitUntilSec
     })
 
-    await videojsElem().click()
+    // Pause video
+    await $('div.video-js').click()
   }
 
   async playVideo () {
+    await $('div.video-js.vjs-paused').waitForExist()
+
+    // Autoplay is disabled on iOS and Safari
+    if (isIOS() || isSafari() || isMobileDevice()) {
+      // We can't play the video if it is not muted
+      await browser.execute(`document.querySelector('video').muted = true`)
+    }
+
     return this.clickOnPlayButton()
   }
 
index eb5f6b45015854f7de63e9cba12159cedeb3979b..b04fe47f33e913aa8e2cf6fad9087c6ae67689bf 100644 (file)
@@ -8,6 +8,12 @@ function isMobileDevice () {
   return platformName === 'android' || platformName === 'ios'
 }
 
+function isAndroid () {
+  const platformName = (browser.capabilities['platformName'] || '').toLowerCase()
+
+  return platformName === 'android'
+}
+
 function isSafari () {
   return browser.capabilities['browserName'] &&
          browser.capabilities['browserName'].toLowerCase() === 'safari'
@@ -41,6 +47,7 @@ export {
   isMobileDevice,
   isSafari,
   isIOS,
+  isAndroid,
   waitServerUp,
   go,
   browserSleep
index c62ffa9313beb28064a0752d4d58a2e461fbd609..1291601c9e3f15daf0521f8dc6c0a1de2b6a0958 100644 (file)
@@ -6,6 +6,10 @@
     "esModuleInterop": true,
     "module": "commonjs",
     "target": "es5",
+    "typeRoots": [
+      "../node_modules/@types",
+      "../node_modules"
+    ],
     "types": [
       "node",
       "@wdio/globals/types",
index 0d68c8541bb022b27dccda1eb168c8c360459181..ecab74078dea7526e86763cd07c8e59eaa8dfef3 100644 (file)
@@ -17,18 +17,32 @@ function buildMainOptions (sessionName: string) {
   }
 }
 
-function buildBStackDesktopOptions (sessionName: string, resolution: string, os?: string) {
+function buildBStackDesktopOptions (options: {
+  sessionName: string
+  resolution: string
+  os?: string
+  osVersion?: string
+}) {
+  const { sessionName, resolution, os, osVersion } = options
+
   return {
     'bstack:options': {
       ...buildMainOptions(sessionName),
 
       os,
+      osVersion,
       resolution
     }
   }
 }
 
-function buildBStackMobileOptions (sessionName: string, deviceName: string, osVersion: string) {
+function buildBStackMobileOptions (options: {
+  sessionName: string
+  deviceName: string
+  osVersion: string
+}) {
+  const { sessionName, deviceName, osVersion } = options
+
   return {
     'bstack:options': {
       ...buildMainOptions(sessionName),
@@ -53,45 +67,45 @@ module.exports = {
       {
         browserName: 'Chrome',
 
-        ...buildBStackDesktopOptions('Latest Chrome Desktop', '1280x1024')
+        ...buildBStackDesktopOptions({ sessionName: 'Latest Chrome Desktop', resolution: '1280x1024', os: 'Windows', osVersion: '8' })
       },
       {
         browserName: 'Firefox',
         browserVersion: '78', // Very old ESR
 
-        ...buildBStackDesktopOptions('Firefox ESR Desktop', '1280x1024', 'Windows')
+        ...buildBStackDesktopOptions({ sessionName: 'Firefox ESR Desktop', resolution: '1280x1024', os: 'Windows', osVersion: '8' })
       },
       {
         browserName: 'Safari',
         browserVersion: '12.1',
 
-        ...buildBStackDesktopOptions('Safari Desktop', '1280x1024')
+        ...buildBStackDesktopOptions({ sessionName: 'Safari Desktop', resolution: '1280x1024' })
       },
       {
         browserName: 'Firefox',
 
-        ...buildBStackDesktopOptions('Firefox Latest', '1280x1024')
+        ...buildBStackDesktopOptions({ sessionName: 'Firefox Latest', resolution: '1280x1024', os: 'Windows', osVersion: '8' })
       },
       {
         browserName: 'Edge',
 
-        ...buildBStackDesktopOptions('Edge Latest', '1280x1024')
+        ...buildBStackDesktopOptions({ sessionName: 'Edge Latest', resolution: '1280x1024' })
       },
 
       {
         browserName: 'Chrome',
 
-        ...buildBStackMobileOptions('Latest Chrome Android', 'Samsung Galaxy S8', '7.0')
+        ...buildBStackMobileOptions({ sessionName: 'Latest Chrome Android', deviceName: 'Samsung Galaxy S8', osVersion: '7.0' })
       },
       {
         browserName: 'Safari',
 
-        ...buildBStackMobileOptions('Safari iPhone', 'iPhone 8 Plus', '12.4')
+        ...buildBStackMobileOptions({ sessionName: 'Safari iPhone', deviceName: 'iPhone 8 Plus', osVersion: '12.4' })
       },
       {
         browserName: 'Safari',
 
-        ...buildBStackMobileOptions('Safari iPad', 'iPad 7th', '13')
+        ...buildBStackMobileOptions({ sessionName: 'Safari iPad', deviceName: 'iPad 7th', osVersion: '13' })
       }
     ],
 
index 7e5a3ebb6f6946ede2a5e05f058873e914c929f3..c405e37e0f8c32efd36c650e4e5bd1bf9116e770 100644 (file)
@@ -315,7 +315,8 @@ class PeerTubePlugin extends Plugin {
   }
 
   private initCaptions () {
-    debugLogger('Init captions with current subtitle ' + this.currentSubtitle)
+    if (this.currentSubtitle) debugLogger('Init captions with current subtitle ' + this.currentSubtitle)
+    else debugLogger('Init captions without current subtitle')
 
     this.player.tech(true).clearTracks('text')