-import { browserSleep, go } from '../utils'
+import { browserSleep, FIXTURE_URLS, go } from '../utils'
export class VideoWatchPage {
- async goOnVideosList (isMobileDevice: boolean, isSafari: boolean) {
- let url: string
-
- // We did not upload a file on a mobile device
- if (isMobileDevice === true || isSafari === true) {
- url = 'https://peertube2.cpy.re/videos/local'
- } else {
- url = '/videos/recently-added'
- }
-
- await go(url)
-
- // Waiting the following element does not work on Safari...
- if (isSafari) return browserSleep(3000)
-
- await $('.videos .video-miniature .video-miniature-name').waitForDisplayed()
- }
- async getVideosListName () {
- const elems = await $$('.videos .video-miniature .video-miniature-name')
- const texts = await Promise.all(elems.map(e => e.getText()))
+ constructor (private isMobileDevice: boolean, private isSafari: boolean) {
- return texts.map(t => t.trim())
}
- waitWatchVideoName (videoName: string, isMobileDevice: boolean, isSafari: boolean) {
- if (isSafari) return browserSleep(5000)
+ waitWatchVideoName (videoName: string) {
+ if (this.isSafari) return browserSleep(5000)
// On mobile we display the first node, on desktop the second
- const index = isMobileDevice ? 0 : 1
+ const index = this.isMobileDevice ? 0 : 1
return browser.waitUntil(async () => {
return (await $$('.video-info .video-info-name')[index].getText()).includes(videoName)
return this.getVideoNameElement().then(e => e.getText())
}
- async goOnAssociatedEmbed () {
- let url = await browser.getUrl()
- url = url.replace('/w/', '/videos/embed/')
- url = url.replace(':3333', ':9001')
-
- return go(url)
+ getPrivacy () {
+ return $('.attribute-privacy .attribute-value').getText()
}
- goOnP2PMediaLoaderEmbed () {
- return go(
- 'https://peertube2.cpy.re/videos/embed/969bf103-7818-43b5-94a0-de159e13de50'
- )
+ getLicence () {
+ return $('.attribute-licence .attribute-value').getText()
}
- goOnP2PMediaLoaderPlaylistEmbed () {
- return go(
- 'https://peertube2.cpy.re/video-playlists/embed/73804a40-da9a-40c2-b1eb-2c6d9eec8f0a'
- )
- }
-
- async clickOnVideo (videoName: string) {
- const video = async () => {
- const videos = await $$('.videos .video-miniature .video-miniature-name').filter(async e => {
- const t = await e.getText()
-
- return t === videoName
- })
+ async isDownloadEnabled () {
+ await this.clickOnMoreDropdownIcon()
- return videos[0]
- }
-
- await browser.waitUntil(async () => {
- const elem = await video()
-
- return elem?.isClickable()
- });
+ return $('.dropdown-item .icon-download').isExisting()
+ }
- (await video()).click()
+ areCommentsEnabled () {
+ return $('my-video-comment-add').isExisting()
+ }
- await browser.waitUntil(async () => (await browser.getUrl()).includes('/w/'))
+ isPrivacyWarningDisplayed () {
+ return $('my-privacy-concerns').isDisplayed()
}
- async clickOnFirstVideo () {
- const video = () => $('.videos .video-miniature .video-thumbnail')
- const videoName = () => $('.videos .video-miniature .video-miniature-name')
+ async goOnAssociatedEmbed () {
+ let url = await browser.getUrl()
+ url = url.replace('/w/', '/videos/embed/')
+ url = url.replace(':3333', ':9001')
- await video().waitForClickable()
+ await go(url)
+ await $('.vjs-big-play-button').waitForDisplayed()
+ }
- const textToReturn = await videoName().getText()
- await video().click()
+ isEmbedWarningDisplayed () {
+ return $('.peertube-dock-description').isDisplayed()
+ }
- await browser.waitUntil(async () => (await browser.getUrl()).includes('/w/'))
+ goOnP2PMediaLoaderEmbed () {
+ return go(FIXTURE_URLS.HLS_EMBED)
+ }
- return textToReturn
+ goOnP2PMediaLoaderPlaylistEmbed () {
+ return go(FIXTURE_URLS.HLS_PLAYLIST_EMBED)
}
async clickOnUpdate () {
- const dropdown = $('my-video-actions-dropdown .action-button')
- await dropdown.click()
+ await this.clickOnMoreDropdownIcon()
- await $('.dropdown-menu.show .dropdown-item').waitForDisplayed()
const items = await $$('.dropdown-menu.show .dropdown-item')
for (const item of items) {
}, { timeout: maxTime })
}
+ async clickOnMoreDropdownIcon () {
+ const dropdown = $('my-video-actions-dropdown .action-button')
+ await dropdown.click()
+
+ await $('.dropdown-menu.show .dropdown-item').waitForDisplayed()
+ }
+
private async getVideoNameElement () {
// We have 2 video info name block, pick the first that is not empty
const elem = async () => {