]>
Commit | Line | Data |
---|---|---|
6d210220 C |
1 | import { browserSleep, go } from '../utils' |
2 | ||
3 | export class VideoListPage { | |
4 | ||
5 | constructor (private isMobileDevice: boolean, private isSafari: boolean) { | |
6 | ||
7 | } | |
8 | ||
9 | async goOnVideosList () { | |
10 | let url: string | |
11 | ||
12 | // We did not upload a file on a mobile device | |
13 | if (this.isMobileDevice === true || this.isSafari === true) { | |
14 | url = 'https://peertube2.cpy.re/videos/local' | |
15 | } else { | |
16 | url = '/videos/recently-added' | |
17 | } | |
18 | ||
19 | await go(url) | |
20 | ||
21 | // Waiting the following element does not work on Safari... | |
22 | if (this.isSafari) return browserSleep(3000) | |
23 | ||
24 | await this.waitForList() | |
25 | } | |
26 | ||
27 | async goOnLocal () { | |
28 | await $('.menu-link[href="/videos/local"]').click() | |
29 | await this.waitForTitle('Local videos') | |
30 | } | |
31 | ||
32 | async goOnRecentlyAdded () { | |
33 | await $('.menu-link[href="/videos/recently-added"]').click() | |
34 | await this.waitForTitle('Recently added') | |
35 | } | |
36 | ||
37 | async goOnTrending () { | |
38 | await $('.menu-link[href="/videos/trending"]').click() | |
39 | await this.waitForTitle('Trending') | |
40 | } | |
41 | ||
42 | async goOnHomepage () { | |
43 | await go('/home') | |
44 | await this.waitForList() | |
45 | } | |
46 | ||
47 | async goOnRootChannel () { | |
48 | await go('/c/root_channel/videos') | |
49 | await this.waitForList() | |
50 | } | |
51 | ||
52 | async goOnRootAccount () { | |
53 | await go('/a/root/videos') | |
54 | await this.waitForList() | |
55 | } | |
56 | ||
57 | async goOnRootAccountChannels () { | |
58 | await go('/a/root/video-channels') | |
59 | await this.waitForList() | |
60 | } | |
61 | ||
62 | getNSFWFilter () { | |
63 | return $$('.active-filter').filter(async a => { | |
64 | return (await a.getText()).includes('Sensitive') | |
65 | }).then(f => f[0]) | |
66 | } | |
67 | ||
68 | async getVideosListName () { | |
69 | const elems = await $$('.videos .video-miniature .video-miniature-name') | |
70 | const texts = await Promise.all(elems.map(e => e.getText())) | |
71 | ||
72 | return texts.map(t => t.trim()) | |
73 | } | |
74 | ||
75 | videoExists (name: string) { | |
76 | return $('.video-miniature-name=' + name).isDisplayed() | |
77 | } | |
78 | ||
79 | async videoIsBlurred (name: string) { | |
80 | const filter = await $('.video-miniature-name=' + name).getCSSProperty('filter') | |
81 | ||
82 | return filter.value !== 'none' | |
83 | } | |
84 | ||
85 | async clickOnVideo (videoName: string) { | |
86 | const video = async () => { | |
87 | const videos = await $$('.videos .video-miniature .video-miniature-name').filter(async e => { | |
88 | const t = await e.getText() | |
89 | ||
90 | return t === videoName | |
91 | }) | |
92 | ||
93 | return videos[0] | |
94 | } | |
95 | ||
96 | await browser.waitUntil(async () => { | |
97 | const elem = await video() | |
98 | ||
99 | return elem?.isClickable() | |
100 | }); | |
101 | ||
102 | (await video()).click() | |
103 | ||
104 | await browser.waitUntil(async () => (await browser.getUrl()).includes('/w/')) | |
105 | } | |
106 | ||
107 | async clickOnFirstVideo () { | |
108 | const video = () => $('.videos .video-miniature .video-thumbnail') | |
109 | const videoName = () => $('.videos .video-miniature .video-miniature-name') | |
110 | ||
111 | await video().waitForClickable() | |
112 | ||
113 | const textToReturn = await videoName().getText() | |
114 | await video().click() | |
115 | ||
116 | await browser.waitUntil(async () => (await browser.getUrl()).includes('/w/')) | |
117 | ||
118 | return textToReturn | |
119 | } | |
120 | ||
121 | private waitForList () { | |
122 | return $('.videos .video-miniature .video-miniature-name').waitForDisplayed() | |
123 | } | |
124 | ||
125 | private waitForTitle (title: string) { | |
126 | return $('h1=' + title).waitForDisplayed() | |
127 | } | |
128 | } |