]>
Commit | Line | Data |
---|---|---|
1 | import { go } from '../utils' | |
2 | ||
3 | export class MyAccountPage { | |
4 | ||
5 | navigateToMyVideos () { | |
6 | return $('a[href="/my-library/videos"]').click() | |
7 | } | |
8 | ||
9 | navigateToMyPlaylists () { | |
10 | return $('a[href="/my-library/video-playlists"]').click() | |
11 | } | |
12 | ||
13 | navigateToMyHistory () { | |
14 | return $('a[href="/my-library/history/videos"]').click() | |
15 | } | |
16 | ||
17 | // My account Videos | |
18 | ||
19 | async removeVideo (name: string) { | |
20 | const container = await this.getVideoElement(name) | |
21 | ||
22 | await container.$('.dropdown-toggle').click() | |
23 | ||
24 | const dropdownMenu = () => container.$('.dropdown-menu .dropdown-item:nth-child(2)') | |
25 | ||
26 | await dropdownMenu().waitForDisplayed() | |
27 | return dropdownMenu().click() | |
28 | } | |
29 | ||
30 | validRemove () { | |
31 | return $('input[type=submit]').click() | |
32 | } | |
33 | ||
34 | async countVideos (names: string[]) { | |
35 | const elements = await $$('.video').filter(async e => { | |
36 | const t = await e.$('.video-miniature-name').getText() | |
37 | ||
38 | return names.some(n => t.includes(n)) | |
39 | }) | |
40 | ||
41 | return elements.length | |
42 | } | |
43 | ||
44 | // My account playlists | |
45 | ||
46 | async getPlaylistVideosText (name: string) { | |
47 | const elem = await this.getPlaylist(name) | |
48 | ||
49 | return elem.$('.miniature-playlist-info-overlay').getText() | |
50 | } | |
51 | ||
52 | async clickOnPlaylist (name: string) { | |
53 | const elem = await this.getPlaylist(name) | |
54 | ||
55 | return elem.$('.miniature-thumbnail').click() | |
56 | } | |
57 | ||
58 | async countTotalPlaylistElements () { | |
59 | await $('<my-video-playlist-element-miniature>').waitForDisplayed() | |
60 | ||
61 | return $$('<my-video-playlist-element-miniature>').length | |
62 | } | |
63 | ||
64 | playPlaylist () { | |
65 | return $('.playlist-info .miniature-thumbnail').click() | |
66 | } | |
67 | ||
68 | async goOnAssociatedPlaylistEmbed () { | |
69 | let url = await browser.getUrl() | |
70 | url = url.replace('/w/p/', '/video-playlists/embed/') | |
71 | url = url.replace(':3333', ':9001') | |
72 | ||
73 | return go(url) | |
74 | } | |
75 | ||
76 | // My account Videos | |
77 | ||
78 | private async getVideoElement (name: string) { | |
79 | const video = async () => { | |
80 | const videos = await $$('.video').filter(async e => { | |
81 | const t = await e.$('.video-miniature-name').getText() | |
82 | ||
83 | return t.includes(name) | |
84 | }) | |
85 | ||
86 | return videos[0] | |
87 | } | |
88 | ||
89 | await browser.waitUntil(async () => { | |
90 | return (await video()).isDisplayed() | |
91 | }) | |
92 | ||
93 | return video() | |
94 | } | |
95 | ||
96 | // My account playlists | |
97 | ||
98 | private async getPlaylist (name: string) { | |
99 | const playlist = () => { | |
100 | return $$('my-video-playlist-miniature') | |
101 | .filter(async e => { | |
102 | const t = await e.$('.miniature-name').getText() | |
103 | ||
104 | return t.includes(name) | |
105 | }) | |
106 | .then(elems => elems[0]) | |
107 | } | |
108 | ||
109 | await browser.waitUntil(async () => { | |
110 | const el = await playlist() | |
111 | ||
112 | return el?.isDisplayed() | |
113 | }) | |
114 | ||
115 | return playlist() | |
116 | } | |
117 | } |