]>
Commit | Line | Data |
---|---|---|
3419e0e1 | 1 | import { 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 | ||
30 | const submit = $('my-user-video-settings input[type=submit]') | |
31 | await submit.scrollIntoView(false) | |
32 | await submit.click() | |
33 | } | |
34 | ||
e69cb173 C |
35 | // My account Videos |
36 | ||
6b88559b | 37 | async removeVideo (name: string) { |
3419e0e1 | 38 | const container = await this.getVideoElement(name) |
6b88559b | 39 | |
3419e0e1 | 40 | await container.$('.dropdown-toggle').click() |
6b88559b | 41 | |
450de91e | 42 | const dropdownMenu = () => container.$$('.dropdown-menu .dropdown-item')[1] |
6b88559b | 43 | |
3419e0e1 C |
44 | await dropdownMenu().waitForDisplayed() |
45 | return dropdownMenu().click() | |
e69cb173 C |
46 | } |
47 | ||
48 | validRemove () { | |
3419e0e1 | 49 | return $('input[type=submit]').click() |
e69cb173 C |
50 | } |
51 | ||
3419e0e1 C |
52 | async countVideos (names: string[]) { |
53 | const elements = await $$('.video').filter(async e => { | |
54 | const t = await e.$('.video-miniature-name').getText() | |
55 | ||
56 | return names.some(n => t.includes(n)) | |
57 | }) | |
58 | ||
59 | return elements.length | |
e69cb173 C |
60 | } |
61 | ||
62 | // My account playlists | |
63 | ||
3419e0e1 C |
64 | async getPlaylistVideosText (name: string) { |
65 | const elem = await this.getPlaylist(name) | |
66 | ||
67 | return elem.$('.miniature-playlist-info-overlay').getText() | |
e69cb173 C |
68 | } |
69 | ||
3419e0e1 C |
70 | async clickOnPlaylist (name: string) { |
71 | const elem = await this.getPlaylist(name) | |
72 | ||
73 | return elem.$('.miniature-thumbnail').click() | |
e69cb173 C |
74 | } |
75 | ||
3419e0e1 C |
76 | async countTotalPlaylistElements () { |
77 | await $('<my-video-playlist-element-miniature>').waitForDisplayed() | |
78 | ||
79 | return $$('<my-video-playlist-element-miniature>').length | |
e69cb173 C |
80 | } |
81 | ||
82 | playPlaylist () { | |
3419e0e1 | 83 | return $('.playlist-info .miniature-thumbnail').click() |
e69cb173 C |
84 | } |
85 | ||
5ab7fd9d | 86 | async goOnAssociatedPlaylistEmbed () { |
3419e0e1 | 87 | let url = await browser.getUrl() |
a1eda903 | 88 | url = url.replace('/w/p/', '/video-playlists/embed/') |
5ab7fd9d C |
89 | url = url.replace(':3333', ':9001') |
90 | ||
3419e0e1 | 91 | return go(url) |
5ab7fd9d C |
92 | } |
93 | ||
e69cb173 C |
94 | // My account Videos |
95 | ||
3419e0e1 C |
96 | private async getVideoElement (name: string) { |
97 | const video = async () => { | |
98 | const videos = await $$('.video').filter(async e => { | |
99 | const t = await e.$('.video-miniature-name').getText() | |
100 | ||
101 | return t.includes(name) | |
102 | }) | |
103 | ||
104 | return videos[0] | |
105 | } | |
106 | ||
107 | await browser.waitUntil(async () => { | |
108 | return (await video()).isDisplayed() | |
109 | }) | |
110 | ||
111 | return video() | |
e69cb173 C |
112 | } |
113 | ||
114 | // My account playlists | |
115 | ||
3419e0e1 C |
116 | private async getPlaylist (name: string) { |
117 | const playlist = () => { | |
118 | return $$('my-video-playlist-miniature') | |
119 | .filter(async e => { | |
120 | const t = await e.$('.miniature-name').getText() | |
121 | ||
122 | return t.includes(name) | |
123 | }) | |
124 | .then(elems => elems[0]) | |
125 | } | |
126 | ||
127 | await browser.waitUntil(async () => { | |
128 | const el = await playlist() | |
129 | ||
130 | return el?.isDisplayed() | |
131 | }) | |
132 | ||
133 | return playlist() | |
e69cb173 C |
134 | } |
135 | } |