]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/e2e/src/po/video-watch.po.ts
Fix CLI default boolean values
[github/Chocobozzz/PeerTube.git] / client / e2e / src / po / video-watch.po.ts
CommitLineData
b528582d 1import { browser, by, element } from 'protractor'
5f92c4dc
C
2
3export class VideoWatchPage {
1fad099d 4 async goOnVideosList (isMobileDevice: boolean, isSafari: boolean) {
0b33c520
C
5 let url: string
6
1fad099d
C
7 // We did not upload a file on a mobile device
8 if (isMobileDevice === true || isSafari === true) {
0b33c520
C
9 url = 'https://peertube2.cpy.re/videos/local'
10 } else {
11 url = '/videos/recently-added'
12 }
5f92c4dc
C
13
14 await browser.get(url)
d1bd87e0
C
15
16 // Waiting the following element does not work on Safari...
17 if (isSafari === true) return browser.sleep(3000)
18
19 const elem = element.all(by.css('.videos .video-miniature .video-miniature-name')).first()
20 return browser.wait(browser.ExpectedConditions.visibilityOf(elem))
5f92c4dc
C
21 }
22
23 getVideosListName () {
d1bd87e0 24 return element.all(by.css('.videos .video-miniature .video-miniature-name'))
0b33c520 25 .getText()
c199c427 26 .then((texts: any) => texts.map((t: any) => t.trim()))
5f92c4dc
C
27 }
28
6247b205
C
29 waitWatchVideoName (videoName: string, isMobileDevice: boolean, isSafari: boolean) {
30 // On mobile we display the first node, on desktop the second
31 const index = isMobileDevice ? 0 : 1
32
33 const elem = element.all(by.css('.video-info .video-info-name')).get(index)
1fad099d
C
34
35 if (isSafari) return browser.sleep(5000)
36
5f92c4dc
C
37 return browser.wait(browser.ExpectedConditions.textToBePresentInElement(elem, videoName))
38 }
39
40 getWatchVideoPlayerCurrentTime () {
41 return element(by.css('.video-js .vjs-current-time-display'))
42 .getText()
43 .then((t: string) => t.split(':')[1])
44 .then(seconds => parseInt(seconds, 10))
45 }
46
84c7cde6 47 async playAndPauseVideo (isAutoplay: boolean, isMobileDevice: boolean) {
d1bd87e0
C
48 if (isAutoplay === false) {
49 const playButton = element(by.css('.vjs-big-play-button'))
50 await browser.wait(browser.ExpectedConditions.elementToBeClickable(playButton))
51 await playButton.click()
52 }
53
d1bd87e0 54 await browser.sleep(1000)
cd4d7a2c
C
55 await browser.wait(browser.ExpectedConditions.invisibilityOf(element(by.css('.vjs-loading-spinner'))))
56
1fad099d
C
57 const videojsEl = element(by.css('div.video-js'))
58 await browser.wait(browser.ExpectedConditions.elementToBeClickable(videojsEl))
5f92c4dc 59
91d95589
C
60 // On Android, we need to click twice on "play" (BrowserStack particularity)
61 if (isMobileDevice) {
62 await browser.sleep(3000)
63 await videojsEl.click()
64 }
65
1fad099d 66 await browser.sleep(7000)
cd4d7a2c 67
1fad099d 68 return videojsEl.click()
5f92c4dc
C
69 }
70
cd4d7a2c
C
71 async clickOnVideo (videoName: string) {
72 const video = element(by.css('.videos .video-miniature .video-thumbnail[title="' + videoName + '"]'))
0b33c520
C
73 await browser.wait(browser.ExpectedConditions.elementToBeClickable(video))
74 await video.click()
75
76 await browser.wait(browser.ExpectedConditions.urlContains('/watch/'))
77 }
78
79 async clickOnFirstVideo () {
1fad099d
C
80 const video = element.all(by.css('.videos .video-miniature .video-thumbnail')).first()
81 const videoName = element.all(by.css('.videos .video-miniature .video-miniature-name')).first()
82
83 // Don't know why but the expectation fails on Safari
0b33c520 84 await browser.wait(browser.ExpectedConditions.elementToBeClickable(video))
5f92c4dc 85
1fad099d 86 const textToReturn = videoName.getText()
5f92c4dc
C
87 await video.click()
88
89 await browser.wait(browser.ExpectedConditions.urlContains('/watch/'))
0b33c520 90 return textToReturn
5f92c4dc
C
91 }
92
d1bd87e0
C
93 async goOnAssociatedEmbed () {
94 let url = await browser.getCurrentUrl()
95 url = url.replace('/watch/', '/embed/')
96 url = url.replace(':3333', ':9001')
97
98 return browser.get(url)
5f92c4dc 99 }
84c7cde6
C
100
101 async goOnP2PMediaLoaderEmbed () {
ac043122 102 return browser.get('https://peertube2.cpy.re/videos/embed/969bf103-7818-43b5-94a0-de159e13de50?mode=p2p-media-loader')
84c7cde6 103 }
5f92c4dc 104}