PeerTube/client/e2e/src/po/video-watch.po.ts

106 lines
2.6 KiB
TypeScript
Raw Normal View History

2021-09-03 10:27:04 +02:00
import { browserSleep, FIXTURE_URLS, go } from '../utils'
2018-05-17 10:55:01 +02:00
export class VideoWatchPage {
2021-09-03 10:27:04 +02:00
constructor (private isMobileDevice: boolean, private isSafari: boolean) {
2021-08-30 16:24:25 +02:00
2018-05-17 10:55:01 +02:00
}
2021-09-03 10:27:04 +02:00
waitWatchVideoName (videoName: string) {
if (this.isSafari) return browserSleep(5000)
2020-05-12 16:38:55 +02:00
2018-09-20 15:45:11 +02:00
// On mobile we display the first node, on desktop the second
2021-09-03 10:27:04 +02:00
const index = this.isMobileDevice ? 0 : 1
2018-09-20 15:45:11 +02:00
2021-08-30 16:24:25 +02:00
return browser.waitUntil(async () => {
return (await $$('.video-info .video-info-name')[index].getText()).includes(videoName)
})
2018-05-17 10:55:01 +02:00
}
2019-06-17 08:11:25 +02:00
getVideoName () {
2021-08-30 16:24:25 +02:00
return this.getVideoNameElement().then(e => e.getText())
2019-06-17 08:11:25 +02:00
}
2020-08-07 10:25:07 +02:00
async goOnAssociatedEmbed () {
2021-08-30 16:24:25 +02:00
let url = await browser.getUrl()
2021-08-26 09:15:59 +02:00
url = url.replace('/w/', '/videos/embed/')
2020-08-07 10:25:07 +02:00
url = url.replace(':3333', ':9001')
2020-05-12 16:38:55 +02:00
2021-08-30 16:24:25 +02:00
return go(url)
2020-08-07 10:25:07 +02:00
}
2018-06-08 14:20:43 +02:00
2021-08-30 16:24:25 +02:00
goOnP2PMediaLoaderEmbed () {
2021-09-02 08:57:59 +02:00
return go(FIXTURE_URLS.HLS_EMBED)
2020-08-07 10:25:07 +02:00
}
2018-05-18 11:02:40 +02:00
2021-08-30 16:24:25 +02:00
goOnP2PMediaLoaderPlaylistEmbed () {
2021-09-02 08:57:59 +02:00
return go(FIXTURE_URLS.HLS_PLAYLIST_EMBED)
2018-05-17 10:55:01 +02:00
}
2019-06-17 08:11:25 +02:00
async clickOnUpdate () {
2021-08-30 16:24:25 +02:00
const dropdown = $('my-video-actions-dropdown .action-button')
2019-06-17 08:11:25 +02:00
await dropdown.click()
2021-08-30 16:24:25 +02:00
await $('.dropdown-menu.show .dropdown-item').waitForDisplayed()
const items = await $$('.dropdown-menu.show .dropdown-item')
2019-06-17 08:11:25 +02:00
for (const item of items) {
const href = await item.getAttribute('href')
2021-08-30 16:24:25 +02:00
if (href?.includes('/update/')) {
2019-06-17 08:11:25 +02:00
await item.click()
return
}
}
}
2021-08-30 16:24:25 +02:00
clickOnSave () {
return $('.action-button-save').click()
2019-06-17 08:11:25 +02:00
}
2019-06-18 10:20:55 +02:00
async createPlaylist (name: string) {
2021-08-30 16:24:25 +02:00
const newPlaylistButton = () => $('.new-playlist-button')
await newPlaylistButton().waitForClickable()
await newPlaylistButton().click()
const displayName = () => $('#displayName')
2019-06-18 10:20:55 +02:00
2021-08-30 16:24:25 +02:00
await displayName().waitForDisplayed()
await displayName().setValue(name)
2019-06-18 10:20:55 +02:00
2021-08-30 16:24:25 +02:00
return $('.new-playlist-block input[type=submit]').click()
2019-06-18 10:20:55 +02:00
}
async saveToPlaylist (name: string) {
2021-08-30 16:24:25 +02:00
const playlist = () => $('my-video-add-to-playlist').$(`.playlist=${name}`)
await playlist().waitForDisplayed()
return playlist().click()
2019-06-17 08:11:25 +02:00
}
waitUntilVideoName (name: string, maxTime: number) {
2021-08-30 16:24:25 +02:00
return browser.waitUntil(async () => {
return (await this.getVideoName()) === name
}, { timeout: maxTime })
2019-06-17 08:11:25 +02:00
}
2021-08-30 16:24:25 +02:00
private async getVideoNameElement () {
2019-06-17 08:11:25 +02:00
// We have 2 video info name block, pick the first that is not empty
2021-08-30 16:24:25 +02:00
const elem = async () => {
const elems = await $$('.video-info-first-row .video-info-name').filter(e => e.isDisplayed())
return elems[0]
}
await browser.waitUntil(async () => {
const e = await elem()
return e?.isDisplayed()
})
return elem()
2019-06-17 08:11:25 +02:00
}
2018-05-17 10:55:01 +02:00
}