1 import { browserSleep, go } from '../utils'
3 export class VideoListPage {
5 constructor (private isMobileDevice: boolean, private isSafari: boolean) {
9 async goOnVideosList () {
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'
16 url = '/videos/recently-added'
21 // Waiting the following element does not work on Safari...
22 if (this.isSafari) return browserSleep(3000)
24 await this.waitForList()
28 await $('.menu-link[href="/videos/local"]').click()
29 await this.waitForTitle('Local videos')
32 async goOnRecentlyAdded () {
33 await $('.menu-link[href="/videos/recently-added"]').click()
34 await this.waitForTitle('Recently added')
37 async goOnTrending () {
38 await $('.menu-link[href="/videos/trending"]').click()
39 await this.waitForTitle('Trending')
42 async goOnHomepage () {
44 await this.waitForList()
47 async goOnRootChannel () {
48 await go('/c/root_channel/videos')
49 await this.waitForList()
52 async goOnRootAccount () {
53 await go('/a/root/videos')
54 await this.waitForList()
57 async goOnRootAccountChannels () {
58 await go('/a/root/video-channels')
59 await this.waitForList()
63 return $$('.active-filter').filter(async a => {
64 return (await a.getText()).includes('Sensitive')
68 async getVideosListName () {
69 const elems = await $$('.videos .video-miniature .video-miniature-name')
70 const texts = await Promise.all(elems.map(e => e.getText()))
72 return texts.map(t => t.trim())
75 videoExists (name: string) {
76 return $('.video-miniature-name=' + name).isDisplayed()
79 async videoIsBlurred (name: string) {
80 const filter = await $('.video-miniature-name=' + name).getCSSProperty('filter')
82 return filter.value !== 'none'
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()
90 return t === videoName
96 await browser.waitUntil(async () => {
97 const elem = await video()
99 return elem?.isClickable()
102 (await video()).click()
104 await browser.waitUntil(async () => (await browser.getUrl()).includes('/w/'))
107 async clickOnFirstVideo () {
108 const video = () => $('.videos .video-miniature .video-thumbnail')
109 const videoName = () => $('.videos .video-miniature .video-miniature-name')
111 await video().waitForClickable()
113 const textToReturn = await videoName().getText()
114 await video().click()
116 await browser.waitUntil(async () => (await browser.getUrl()).includes('/w/'))
121 private waitForList () {
122 return $('.videos .video-miniature .video-miniature-name').waitForDisplayed()
125 private waitForTitle (title: string) {
126 return $('h1=' + title).waitForDisplayed()