]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/e2e/src/po/player.po.ts
Use round for views stats
[github/Chocobozzz/PeerTube.git] / client / e2e / src / po / player.po.ts
index 9d6e210093c3047b15f015fe4eaaf045dbbddc98..a20e683bceb33767a13b0cb4c10c8a28b0a96105 100644 (file)
@@ -5,17 +5,19 @@ export class PlayerPage {
   getWatchVideoPlayerCurrentTime () {
     const elem = $('video')
 
-    if (isIOS()) {
-      return elem.getAttribute('currentTime')
-        .then(t => parseInt(t, 10))
-        .then(t => Math.round(t))
-    }
+    const p = isIOS()
+      ? elem.getAttribute('currentTime')
+      : elem.getProperty('currentTime')
 
-    return elem.getProperty('currentTime')
+    return p.then(t => parseInt(t + '', 10))
+            .then(t => Math.ceil(t))
   }
 
   waitUntilPlaylistInfo (text: string, maxTime: number) {
     return browser.waitUntil(async () => {
+      // Without this we have issues on iphone
+      await $('.video-js').click()
+
       return (await $('.video-js .vjs-playlist-info').getText()).includes(text)
     }, { timeout: maxTime })
   }
@@ -26,14 +28,14 @@ export class PlayerPage {
     })
   }
 
-  async playAndPauseVideo (isAutoplay: boolean) {
+  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 using protractor if it is not muted
+      // 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) {
@@ -43,10 +45,8 @@ export class PlayerPage {
     await browserSleep(2000)
 
     await browser.waitUntil(async () => {
-      return !await $('.vjs-loading-spinner').isDisplayedInViewport()
-    }, { timeout: 20 * 1000 })
-
-    await browserSleep(4000)
+      return (await this.getWatchVideoPlayerCurrentTime()) >= waitUntilSec
+    })
 
     await videojsElem().click()
   }