]>
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 | getPrivacy () { | |
25 | return $('.attribute-privacy .attribute-value').getText() | |
26 | } | |
27 | ||
28 | getLicence () { | |
29 | return $('.attribute-licence .attribute-value').getText() | |
30 | } | |
31 | ||
32 | async isDownloadEnabled () { | |
33 | await this.clickOnMoreDropdownIcon() | |
34 | ||
35 | return $('.dropdown-item .icon-download').isExisting() | |
36 | } | |
37 | ||
38 | areCommentsEnabled () { | |
39 | return $('my-video-comment-add').isExisting() | |
40 | } | |
41 | ||
42 | isPrivacyWarningDisplayed () { | |
43 | return $('my-privacy-concerns').isDisplayed() | |
44 | } | |
45 | ||
46 | async goOnAssociatedEmbed () { | |
47 | let url = await browser.getUrl() | |
48 | url = url.replace('/w/', '/videos/embed/') | |
49 | url = url.replace(':3333', ':9001') | |
50 | ||
51 | await go(url) | |
52 | await this.waitEmbedForDisplayed() | |
53 | } | |
54 | ||
55 | waitEmbedForDisplayed () { | |
56 | return $('.vjs-big-play-button').waitForDisplayed() | |
57 | } | |
58 | ||
59 | isEmbedWarningDisplayed () { | |
60 | return $('.peertube-dock-description').isDisplayed() | |
61 | } | |
62 | ||
63 | goOnP2PMediaLoaderEmbed () { | |
64 | return go(FIXTURE_URLS.HLS_EMBED) | |
65 | } | |
66 | ||
67 | goOnP2PMediaLoaderPlaylistEmbed () { | |
68 | return go(FIXTURE_URLS.HLS_PLAYLIST_EMBED) | |
69 | } | |
70 | ||
71 | async clickOnUpdate () { | |
72 | await this.clickOnMoreDropdownIcon() | |
73 | ||
74 | const items = await $$('.dropdown-menu.show .dropdown-item') | |
75 | ||
76 | for (const item of items) { | |
77 | const href = await item.getAttribute('href') | |
78 | ||
79 | if (href?.includes('/update/')) { | |
80 | await item.click() | |
81 | return | |
82 | } | |
83 | } | |
84 | } | |
85 | ||
86 | clickOnSave () { | |
87 | return $('.action-button-save').click() | |
88 | } | |
89 | ||
90 | async createPlaylist (name: string) { | |
91 | const newPlaylistButton = () => $('.new-playlist-button') | |
92 | ||
93 | await newPlaylistButton().waitForClickable() | |
94 | await newPlaylistButton().click() | |
95 | ||
96 | const displayName = () => $('#displayName') | |
97 | ||
98 | await displayName().waitForDisplayed() | |
99 | await displayName().setValue(name) | |
100 | ||
101 | return $('.new-playlist-block input[type=submit]').click() | |
102 | } | |
103 | ||
104 | async saveToPlaylist (name: string) { | |
105 | const playlist = () => $('my-video-add-to-playlist').$(`.playlist=${name}`) | |
106 | ||
107 | await playlist().waitForDisplayed() | |
108 | ||
109 | return playlist().click() | |
110 | } | |
111 | ||
112 | waitUntilVideoName (name: string, maxTime: number) { | |
113 | return browser.waitUntil(async () => { | |
114 | return (await this.getVideoName()) === name | |
115 | }, { timeout: maxTime }) | |
116 | } | |
117 | ||
118 | async clickOnMoreDropdownIcon () { | |
119 | const dropdown = $('my-video-actions-dropdown .action-button') | |
120 | await dropdown.click() | |
121 | ||
122 | await $('.dropdown-menu.show .dropdown-item').waitForDisplayed() | |
123 | } | |
124 | ||
125 | private async getVideoNameElement () { | |
126 | // We have 2 video info name block, pick the first that is not empty | |
127 | const elem = async () => { | |
128 | const elems = await $$('.video-info-first-row .video-info-name').filter(e => e.isDisplayed()) | |
129 | ||
130 | return elems[0] | |
131 | } | |
132 | ||
133 | await browser.waitUntil(async () => { | |
134 | const e = await elem() | |
135 | ||
136 | return e?.isDisplayed() | |
137 | }) | |
138 | ||
139 | return elem() | |
140 | } | |
141 | } |