]>
Commit | Line | Data |
---|---|---|
6d210220 | 1 | import { browserSleep, FIXTURE_URLS, go } from '../utils' |
5f92c4dc C |
2 | |
3 | export 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 | ||
3cf68b86 C |
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 | ||
a9bfa85d C |
42 | isPrivacyWarningDisplayed () { |
43 | return $('my-privacy-concerns').isDisplayed() | |
44 | } | |
45 | ||
7f90579c | 46 | async goOnAssociatedEmbed () { |
3419e0e1 | 47 | let url = await browser.getUrl() |
18305950 | 48 | url = url.replace('/w/', '/videos/embed/') |
7f90579c | 49 | url = url.replace(':3333', ':9001') |
ee68bbc4 | 50 | |
a9bfa85d C |
51 | await go(url) |
52 | await $('.vjs-big-play-button').waitForDisplayed() | |
53 | } | |
54 | ||
2024a3b9 C |
55 | isEmbedWarningDisplayed () { |
56 | return $('.peertube-dock-description').isDisplayed() | |
7f90579c | 57 | } |
91d95589 | 58 | |
3419e0e1 | 59 | goOnP2PMediaLoaderEmbed () { |
12d6b873 | 60 | return go(FIXTURE_URLS.HLS_EMBED) |
7f90579c | 61 | } |
cd4d7a2c | 62 | |
3419e0e1 | 63 | goOnP2PMediaLoaderPlaylistEmbed () { |
12d6b873 | 64 | return go(FIXTURE_URLS.HLS_PLAYLIST_EMBED) |
5f92c4dc C |
65 | } |
66 | ||
e69cb173 | 67 | async clickOnUpdate () { |
3cf68b86 | 68 | await this.clickOnMoreDropdownIcon() |
e69cb173 | 69 | |
3419e0e1 | 70 | const items = await $$('.dropdown-menu.show .dropdown-item') |
e69cb173 C |
71 | |
72 | for (const item of items) { | |
73 | const href = await item.getAttribute('href') | |
74 | ||
3419e0e1 | 75 | if (href?.includes('/update/')) { |
e69cb173 C |
76 | await item.click() |
77 | return | |
78 | } | |
79 | } | |
80 | } | |
81 | ||
3419e0e1 C |
82 | clickOnSave () { |
83 | return $('.action-button-save').click() | |
e69cb173 C |
84 | } |
85 | ||
bbe078ba | 86 | async createPlaylist (name: string) { |
3419e0e1 C |
87 | const newPlaylistButton = () => $('.new-playlist-button') |
88 | ||
89 | await newPlaylistButton().waitForClickable() | |
90 | await newPlaylistButton().click() | |
91 | ||
92 | const displayName = () => $('#displayName') | |
bbe078ba | 93 | |
3419e0e1 C |
94 | await displayName().waitForDisplayed() |
95 | await displayName().setValue(name) | |
bbe078ba | 96 | |
3419e0e1 | 97 | return $('.new-playlist-block input[type=submit]').click() |
bbe078ba C |
98 | } |
99 | ||
100 | async saveToPlaylist (name: string) { | |
3419e0e1 C |
101 | const playlist = () => $('my-video-add-to-playlist').$(`.playlist=${name}`) |
102 | ||
103 | await playlist().waitForDisplayed() | |
104 | ||
105 | return playlist().click() | |
e69cb173 C |
106 | } |
107 | ||
108 | waitUntilVideoName (name: string, maxTime: number) { | |
3419e0e1 C |
109 | return browser.waitUntil(async () => { |
110 | return (await this.getVideoName()) === name | |
111 | }, { timeout: maxTime }) | |
e69cb173 C |
112 | } |
113 | ||
3cf68b86 C |
114 | async clickOnMoreDropdownIcon () { |
115 | const dropdown = $('my-video-actions-dropdown .action-button') | |
116 | await dropdown.click() | |
117 | ||
118 | await $('.dropdown-menu.show .dropdown-item').waitForDisplayed() | |
119 | } | |
120 | ||
3419e0e1 | 121 | private async getVideoNameElement () { |
e69cb173 | 122 | // We have 2 video info name block, pick the first that is not empty |
3419e0e1 C |
123 | const elem = async () => { |
124 | const elems = await $$('.video-info-first-row .video-info-name').filter(e => e.isDisplayed()) | |
125 | ||
126 | return elems[0] | |
127 | } | |
128 | ||
129 | await browser.waitUntil(async () => { | |
130 | const e = await elem() | |
131 | ||
132 | return e?.isDisplayed() | |
133 | }) | |
134 | ||
135 | return elem() | |
e69cb173 | 136 | } |
5f92c4dc | 137 | } |