]>
Commit | Line | Data |
---|---|---|
a9bfa85d | 1 | import { getCheckbox, go } from '../utils' |
e69cb173 C |
2 | |
3 | export class MyAccountPage { | |
4 | ||
5 | navigateToMyVideos () { | |
3419e0e1 | 6 | return $('a[href="/my-library/videos"]').click() |
e69cb173 C |
7 | } |
8 | ||
9 | navigateToMyPlaylists () { | |
3419e0e1 | 10 | return $('a[href="/my-library/video-playlists"]').click() |
e69cb173 C |
11 | } |
12 | ||
13 | navigateToMyHistory () { | |
3419e0e1 | 14 | return $('a[href="/my-library/history/videos"]').click() |
e69cb173 C |
15 | } |
16 | ||
6d210220 C |
17 | // Settings |
18 | ||
19 | navigateToMySettings () { | |
20 | return $('a[href="/my-account"]').click() | |
21 | } | |
22 | ||
23 | async updateNSFW (newValue: 'do_not_list' | 'blur' | 'display') { | |
24 | const nsfw = $('#nsfwPolicy') | |
25 | ||
26 | await nsfw.waitForDisplayed() | |
27 | await nsfw.scrollIntoView(false) // Avoid issues with fixed header on firefox | |
28 | await nsfw.selectByAttribute('value', newValue) | |
29 | ||
a9bfa85d C |
30 | await this.submitVideoSettings() |
31 | } | |
32 | ||
33 | async clickOnP2PCheckbox () { | |
3c065fe3 | 34 | const p2p = await getCheckbox('p2pEnabled') |
a9bfa85d C |
35 | |
36 | await p2p.waitForClickable() | |
37 | await p2p.scrollIntoView(false) // Avoid issues with fixed header on firefox | |
38 | ||
39 | await p2p.click() | |
40 | ||
41 | await this.submitVideoSettings() | |
42 | } | |
43 | ||
44 | private async submitVideoSettings () { | |
6d210220 C |
45 | const submit = $('my-user-video-settings input[type=submit]') |
46 | await submit.scrollIntoView(false) | |
47 | await submit.click() | |
48 | } | |
49 | ||
e69cb173 C |
50 | // My account Videos |
51 | ||
6b88559b | 52 | async removeVideo (name: string) { |
3419e0e1 | 53 | const container = await this.getVideoElement(name) |
6b88559b | 54 | |
3419e0e1 | 55 | await container.$('.dropdown-toggle').click() |
6b88559b | 56 | |
450de91e | 57 | const dropdownMenu = () => container.$$('.dropdown-menu .dropdown-item')[1] |
6b88559b | 58 | |
3419e0e1 C |
59 | await dropdownMenu().waitForDisplayed() |
60 | return dropdownMenu().click() | |
e69cb173 C |
61 | } |
62 | ||
63 | validRemove () { | |
3419e0e1 | 64 | return $('input[type=submit]').click() |
e69cb173 C |
65 | } |
66 | ||
3419e0e1 C |
67 | async countVideos (names: string[]) { |
68 | const elements = await $$('.video').filter(async e => { | |
69 | const t = await e.$('.video-miniature-name').getText() | |
70 | ||
71 | return names.some(n => t.includes(n)) | |
72 | }) | |
73 | ||
74 | return elements.length | |
e69cb173 C |
75 | } |
76 | ||
77 | // My account playlists | |
78 | ||
3419e0e1 C |
79 | async getPlaylistVideosText (name: string) { |
80 | const elem = await this.getPlaylist(name) | |
81 | ||
82 | return elem.$('.miniature-playlist-info-overlay').getText() | |
e69cb173 C |
83 | } |
84 | ||
3419e0e1 C |
85 | async clickOnPlaylist (name: string) { |
86 | const elem = await this.getPlaylist(name) | |
87 | ||
88 | return elem.$('.miniature-thumbnail').click() | |
e69cb173 C |
89 | } |
90 | ||
3419e0e1 C |
91 | async countTotalPlaylistElements () { |
92 | await $('<my-video-playlist-element-miniature>').waitForDisplayed() | |
93 | ||
94 | return $$('<my-video-playlist-element-miniature>').length | |
e69cb173 C |
95 | } |
96 | ||
97 | playPlaylist () { | |
3419e0e1 | 98 | return $('.playlist-info .miniature-thumbnail').click() |
e69cb173 C |
99 | } |
100 | ||
5ab7fd9d | 101 | async goOnAssociatedPlaylistEmbed () { |
3419e0e1 | 102 | let url = await browser.getUrl() |
a1eda903 | 103 | url = url.replace('/w/p/', '/video-playlists/embed/') |
5ab7fd9d C |
104 | url = url.replace(':3333', ':9001') |
105 | ||
3419e0e1 | 106 | return go(url) |
5ab7fd9d C |
107 | } |
108 | ||
e69cb173 C |
109 | // My account Videos |
110 | ||
3419e0e1 C |
111 | private async getVideoElement (name: string) { |
112 | const video = async () => { | |
113 | const videos = await $$('.video').filter(async e => { | |
114 | const t = await e.$('.video-miniature-name').getText() | |
115 | ||
116 | return t.includes(name) | |
117 | }) | |
118 | ||
119 | return videos[0] | |
120 | } | |
121 | ||
122 | await browser.waitUntil(async () => { | |
123 | return (await video()).isDisplayed() | |
124 | }) | |
125 | ||
126 | return video() | |
e69cb173 C |
127 | } |
128 | ||
129 | // My account playlists | |
130 | ||
3419e0e1 C |
131 | private async getPlaylist (name: string) { |
132 | const playlist = () => { | |
133 | return $$('my-video-playlist-miniature') | |
134 | .filter(async e => { | |
135 | const t = await e.$('.miniature-name').getText() | |
136 | ||
137 | return t.includes(name) | |
138 | }) | |
139 | .then(elems => elems[0]) | |
140 | } | |
141 | ||
142 | await browser.waitUntil(async () => { | |
143 | const el = await playlist() | |
144 | ||
145 | return el?.isDisplayed() | |
146 | }) | |
147 | ||
148 | return playlist() | |
e69cb173 C |
149 | } |
150 | } |