]>
Commit | Line | Data |
---|---|---|
1 | import { browserSleep, FIXTURE_URLS, go } from '../utils' | |
2 | ||
3 | export class VideoWatchPage { | |
4 | ||
5 | constructor (private isMobileDevice: boolean, private isSafari: boolean) { | |
6 | ||
7 | } | |
8 | ||
9 | waitWatchVideoName (videoName: string) { | |
10 | if (this.isSafari) return browserSleep(5000) | |
11 | ||
12 | // On mobile we display the first node, on desktop the second | |
13 | const index = this.isMobileDevice ? 0 : 1 | |
14 | ||
15 | return browser.waitUntil(async () => { | |
16 | return (await $$('.video-info .video-info-name')[index].getText()).includes(videoName) | |
17 | }) | |
18 | } | |
19 | ||
20 | getVideoName () { | |
21 | return this.getVideoNameElement().then(e => e.getText()) | |
22 | } | |
23 | ||
24 | async goOnAssociatedEmbed () { | |
25 | let url = await browser.getUrl() | |
26 | url = url.replace('/w/', '/videos/embed/') | |
27 | url = url.replace(':3333', ':9001') | |
28 | ||
29 | return go(url) | |
30 | } | |
31 | ||
32 | goOnP2PMediaLoaderEmbed () { | |
33 | return go(FIXTURE_URLS.HLS_EMBED) | |
34 | } | |
35 | ||
36 | goOnP2PMediaLoaderPlaylistEmbed () { | |
37 | return go(FIXTURE_URLS.HLS_PLAYLIST_EMBED) | |
38 | } | |
39 | ||
40 | async clickOnUpdate () { | |
41 | const dropdown = $('my-video-actions-dropdown .action-button') | |
42 | await dropdown.click() | |
43 | ||
44 | await $('.dropdown-menu.show .dropdown-item').waitForDisplayed() | |
45 | const items = await $$('.dropdown-menu.show .dropdown-item') | |
46 | ||
47 | for (const item of items) { | |
48 | const href = await item.getAttribute('href') | |
49 | ||
50 | if (href?.includes('/update/')) { | |
51 | await item.click() | |
52 | return | |
53 | } | |
54 | } | |
55 | } | |
56 | ||
57 | clickOnSave () { | |
58 | return $('.action-button-save').click() | |
59 | } | |
60 | ||
61 | async createPlaylist (name: string) { | |
62 | const newPlaylistButton = () => $('.new-playlist-button') | |
63 | ||
64 | await newPlaylistButton().waitForClickable() | |
65 | await newPlaylistButton().click() | |
66 | ||
67 | const displayName = () => $('#displayName') | |
68 | ||
69 | await displayName().waitForDisplayed() | |
70 | await displayName().setValue(name) | |
71 | ||
72 | return $('.new-playlist-block input[type=submit]').click() | |
73 | } | |
74 | ||
75 | async saveToPlaylist (name: string) { | |
76 | const playlist = () => $('my-video-add-to-playlist').$(`.playlist=${name}`) | |
77 | ||
78 | await playlist().waitForDisplayed() | |
79 | ||
80 | return playlist().click() | |
81 | } | |
82 | ||
83 | waitUntilVideoName (name: string, maxTime: number) { | |
84 | return browser.waitUntil(async () => { | |
85 | return (await this.getVideoName()) === name | |
86 | }, { timeout: maxTime }) | |
87 | } | |
88 | ||
89 | private async getVideoNameElement () { | |
90 | // We have 2 video info name block, pick the first that is not empty | |
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() | |
104 | } | |
105 | } |