1 import { browserSleep, FIXTURE_URLS, go } from '../utils'
3 export class VideoWatchPage {
5 constructor (private isMobileDevice: boolean, private isSafari: boolean) {
9 waitWatchVideoName (videoName: string) {
10 if (this.isSafari) return browserSleep(5000)
12 // On mobile we display the first node, on desktop the second
13 const index = this.isMobileDevice ? 0 : 1
15 return browser.waitUntil(async () => {
16 return (await $$('.video-info .video-info-name')[index].getText()).includes(videoName)
21 return this.getVideoNameElement().then(e => e.getText())
25 return $('.attribute-privacy .attribute-value').getText()
29 return $('.attribute-licence .attribute-value').getText()
32 async isDownloadEnabled () {
33 await this.clickOnMoreDropdownIcon()
35 return $('.dropdown-item .icon-download').isExisting()
38 areCommentsEnabled () {
39 return $('my-video-comment-add').isExisting()
42 async goOnAssociatedEmbed () {
43 let url = await browser.getUrl()
44 url = url.replace('/w/', '/videos/embed/')
45 url = url.replace(':3333', ':9001')
50 goOnP2PMediaLoaderEmbed () {
51 return go(FIXTURE_URLS.HLS_EMBED)
54 goOnP2PMediaLoaderPlaylistEmbed () {
55 return go(FIXTURE_URLS.HLS_PLAYLIST_EMBED)
58 async clickOnUpdate () {
59 await this.clickOnMoreDropdownIcon()
61 const items = await $$('.dropdown-menu.show .dropdown-item')
63 for (const item of items) {
64 const href = await item.getAttribute('href')
66 if (href?.includes('/update/')) {
74 return $('.action-button-save').click()
77 async createPlaylist (name: string) {
78 const newPlaylistButton = () => $('.new-playlist-button')
80 await newPlaylistButton().waitForClickable()
81 await newPlaylistButton().click()
83 const displayName = () => $('#displayName')
85 await displayName().waitForDisplayed()
86 await displayName().setValue(name)
88 return $('.new-playlist-block input[type=submit]').click()
91 async saveToPlaylist (name: string) {
92 const playlist = () => $('my-video-add-to-playlist').$(`.playlist=${name}`)
94 await playlist().waitForDisplayed()
96 return playlist().click()
99 waitUntilVideoName (name: string, maxTime: number) {
100 return browser.waitUntil(async () => {
101 return (await this.getVideoName()) === name
102 }, { timeout: maxTime })
105 async clickOnMoreDropdownIcon () {
106 const dropdown = $('my-video-actions-dropdown .action-button')
107 await dropdown.click()
109 await $('.dropdown-menu.show .dropdown-item').waitForDisplayed()
112 private async getVideoNameElement () {
113 // We have 2 video info name block, pick the first that is not empty
114 const elem = async () => {
115 const elems = await $$('.video-info-first-row .video-info-name').filter(e => e.isDisplayed())
120 await browser.waitUntil(async () => {
121 const e = await elem()
123 return e?.isDisplayed()