]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/e2e/src/po/video-watch.po.ts
Increase timeout
[github/Chocobozzz/PeerTube.git] / client / e2e / src / po / video-watch.po.ts
CommitLineData
6d210220 1import { browserSleep, FIXTURE_URLS, go } from '../utils'
5f92c4dc
C
2
3export class VideoWatchPage {
5f92c4dc 4
6d210220 5 constructor (private isMobileDevice: boolean, private isSafari: boolean) {
3419e0e1 6
5f92c4dc
C
7 }
8
6d210220
C
9 waitWatchVideoName (videoName: string) {
10 if (this.isSafari) return browserSleep(5000)
ee68bbc4 11
6247b205 12 // On mobile we display the first node, on desktop the second
6d210220 13 const index = this.isMobileDevice ? 0 : 1
6247b205 14
3419e0e1
C
15 return browser.waitUntil(async () => {
16 return (await $$('.video-info .video-info-name')[index].getText()).includes(videoName)
17 })
5f92c4dc
C
18 }
19
e69cb173 20 getVideoName () {
3419e0e1 21 return this.getVideoNameElement().then(e => e.getText())
e69cb173
C
22 }
23
7f90579c 24 async goOnAssociatedEmbed () {
3419e0e1 25 let url = await browser.getUrl()
18305950 26 url = url.replace('/w/', '/videos/embed/')
7f90579c 27 url = url.replace(':3333', ':9001')
ee68bbc4 28
3419e0e1 29 return go(url)
7f90579c 30 }
91d95589 31
3419e0e1 32 goOnP2PMediaLoaderEmbed () {
12d6b873 33 return go(FIXTURE_URLS.HLS_EMBED)
7f90579c 34 }
cd4d7a2c 35
3419e0e1 36 goOnP2PMediaLoaderPlaylistEmbed () {
12d6b873 37 return go(FIXTURE_URLS.HLS_PLAYLIST_EMBED)
5f92c4dc
C
38 }
39
e69cb173 40 async clickOnUpdate () {
3419e0e1 41 const dropdown = $('my-video-actions-dropdown .action-button')
e69cb173
C
42 await dropdown.click()
43
3419e0e1
C
44 await $('.dropdown-menu.show .dropdown-item').waitForDisplayed()
45 const items = await $$('.dropdown-menu.show .dropdown-item')
e69cb173
C
46
47 for (const item of items) {
48 const href = await item.getAttribute('href')
49
3419e0e1 50 if (href?.includes('/update/')) {
e69cb173
C
51 await item.click()
52 return
53 }
54 }
55 }
56
3419e0e1
C
57 clickOnSave () {
58 return $('.action-button-save').click()
e69cb173
C
59 }
60
bbe078ba 61 async createPlaylist (name: string) {
3419e0e1
C
62 const newPlaylistButton = () => $('.new-playlist-button')
63
64 await newPlaylistButton().waitForClickable()
65 await newPlaylistButton().click()
66
67 const displayName = () => $('#displayName')
bbe078ba 68
3419e0e1
C
69 await displayName().waitForDisplayed()
70 await displayName().setValue(name)
bbe078ba 71
3419e0e1 72 return $('.new-playlist-block input[type=submit]').click()
bbe078ba
C
73 }
74
75 async saveToPlaylist (name: string) {
3419e0e1
C
76 const playlist = () => $('my-video-add-to-playlist').$(`.playlist=${name}`)
77
78 await playlist().waitForDisplayed()
79
80 return playlist().click()
e69cb173
C
81 }
82
83 waitUntilVideoName (name: string, maxTime: number) {
3419e0e1
C
84 return browser.waitUntil(async () => {
85 return (await this.getVideoName()) === name
86 }, { timeout: maxTime })
e69cb173
C
87 }
88
3419e0e1 89 private async getVideoNameElement () {
e69cb173 90 // We have 2 video info name block, pick the first that is not empty
3419e0e1
C
91 const elem = async () => {
92 const elems = await $$('.video-info-first-row .video-info-name').filter(e => e.isDisplayed())
93
94 return elems[0]
95 }
96
97 await browser.waitUntil(async () => {
98 const e = await elem()
99
100 return e?.isDisplayed()
101 })
102
103 return elem()
e69cb173 104 }
5f92c4dc 105}