]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/e2e/src/po/player.po.ts
Fix videos language tests
[github/Chocobozzz/PeerTube.git] / client / e2e / src / po / player.po.ts
1 import { browserSleep, isIOS, isMobileDevice, isSafari } from '../utils'
2
3 export class PlayerPage {
4
5 getWatchVideoPlayerCurrentTime () {
6 const elem = $('video')
7
8 const p = isIOS()
9 ? elem.getAttribute('currentTime')
10 : elem.getProperty('currentTime')
11
12 return p.then(t => parseInt(t + '', 10))
13 .then(t => Math.ceil(t))
14 }
15
16 waitUntilPlaylistInfo (text: string, maxTime: number) {
17 return browser.waitUntil(async () => {
18 // Without this we have issues on iphone
19 await $('.video-js').click()
20
21 return (await $('.video-js .vjs-playlist-info').getText()).includes(text)
22 }, { timeout: maxTime })
23 }
24
25 waitUntilPlayerWrapper () {
26 return browser.waitUntil(async () => {
27 return !!(await $('#placeholder-preview'))
28 })
29 }
30
31 async playAndPauseVideo (isAutoplay: boolean, waitUntilSec: number) {
32 const videojsElem = () => $('div.video-js')
33
34 await videojsElem().waitForExist()
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 }
44
45 await browserSleep(2000)
46
47 await browser.waitUntil(async () => {
48 return (await this.getWatchVideoPlayerCurrentTime()) >= waitUntilSec
49 })
50
51 await videojsElem().click()
52 }
53
54 async playVideo () {
55 return this.clickOnPlayButton()
56 }
57
58 private async clickOnPlayButton () {
59 const playButton = () => $('.vjs-big-play-button')
60
61 await playButton().waitForClickable()
62 await playButton().click()
63 }
64 }