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 isPrivacyWarningDisplayed () {
43 return $('my-privacy-concerns').isDisplayed()
46 async goOnAssociatedEmbed () {
47 let url = await browser.getUrl()
48 url = url.replace('/w/', '/videos/embed/')
49 url = url.replace(':3333', ':9001')
52 await $('.vjs-big-play-button').waitForDisplayed()
55 async isEmbedWarningDisplayed () {
56 const text = await $('.vjs-dock-description').getText()
61 goOnP2PMediaLoaderEmbed () {
62 return go(FIXTURE_URLS.HLS_EMBED)
65 goOnP2PMediaLoaderPlaylistEmbed () {
66 return go(FIXTURE_URLS.HLS_PLAYLIST_EMBED)
69 async clickOnUpdate () {
70 await this.clickOnMoreDropdownIcon()
72 const items = await $$('.dropdown-menu.show .dropdown-item')
74 for (const item of items) {
75 const href = await item.getAttribute('href')
77 if (href?.includes('/update/')) {
85 return $('.action-button-save').click()
88 async createPlaylist (name: string) {
89 const newPlaylistButton = () => $('.new-playlist-button')
91 await newPlaylistButton().waitForClickable()
92 await newPlaylistButton().click()
94 const displayName = () => $('#displayName')
96 await displayName().waitForDisplayed()
97 await displayName().setValue(name)
99 return $('.new-playlist-block input[type=submit]').click()
102 async saveToPlaylist (name: string) {
103 const playlist = () => $('my-video-add-to-playlist').$(`.playlist=${name}`)
105 await playlist().waitForDisplayed()
107 return playlist().click()
110 waitUntilVideoName (name: string, maxTime: number) {
111 return browser.waitUntil(async () => {
112 return (await this.getVideoName()) === name
113 }, { timeout: maxTime })
116 async clickOnMoreDropdownIcon () {
117 const dropdown = $('my-video-actions-dropdown .action-button')
118 await dropdown.click()
120 await $('.dropdown-menu.show .dropdown-item').waitForDisplayed()
123 private async getVideoNameElement () {
124 // We have 2 video info name block, pick the first that is not empty
125 const elem = async () => {
126 const elems = await $$('.video-info-first-row .video-info-name').filter(e => e.isDisplayed())
131 await browser.waitUntil(async () => {
132 const e = await elem()
134 return e?.isDisplayed()