]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/e2e/src/po/video-watch.po.ts
Add ability for admins to set default p2p policy
[github/Chocobozzz/PeerTube.git] / client / e2e / src / po / video-watch.po.ts
index 01061d5d44a91da2ebd6ad4938c3b9677022a159..cecda3a8b941a1092d558294ccf10bda4952acc6 100644 (file)
@@ -1,36 +1,16 @@
-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)
@@ -41,67 +21,54 @@ export class VideoWatchPage {
     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)
-  }
-
-  goOnP2PMediaLoaderEmbed () {
-    return go(
-      'https://peertube2.cpy.re/videos/embed/969bf103-7818-43b5-94a0-de159e13de50'
-    )
+  getPrivacy () {
+    return $('.attribute-privacy .attribute-value').getText()
   }
 
-  goOnP2PMediaLoaderPlaylistEmbed () {
-    return go(
-      'https://peertube2.cpy.re/video-playlists/embed/73804a40-da9a-40c2-b1eb-2c6d9eec8f0a'
-    )
+  getLicence () {
+    return $('.attribute-licence .attribute-value').getText()
   }
 
-  async clickOnVideo (videoName: string) {
-    const video = async () => {
-      const videos = await $$('.videos .video-miniature .video-miniature-name').filter(async e => {
-        const t = await e.getText()
+  async isDownloadEnabled () {
+    await this.clickOnMoreDropdownIcon()
 
-        return t === videoName
-      })
-
-      return videos[0]
-    }
+    return $('.dropdown-item .icon-download').isExisting()
+  }
 
-    await browser.waitUntil(async () => {
-      const elem = await video()
+  areCommentsEnabled () {
+    return $('my-video-comment-add').isExisting()
+  }
 
-      return elem?.isClickable()
-    });
+  isPrivacyWarningDisplayed () {
+    return $('my-privacy-concerns').isDisplayed()
+  }
 
-    (await video()).click()
+  async goOnAssociatedEmbed () {
+    let url = await browser.getUrl()
+    url = url.replace('/w/', '/videos/embed/')
+    url = url.replace(':3333', ':9001')
 
-    await browser.waitUntil(async () => (await browser.getUrl()).includes('/w/'))
+    await go(url)
+    await $('.vjs-big-play-button').waitForDisplayed()
   }
 
-  async clickOnFirstVideo () {
-    const video = () => $('.videos .video-miniature .video-thumbnail')
-    const videoName = () => $('.videos .video-miniature .video-miniature-name')
-
-    await video().waitForClickable()
+  async isEmbedWarningDisplayed () {
+    const text = await $('.vjs-dock-description').getText()
 
-    const textToReturn = await videoName().getText()
-    await video().click()
+    return !!text.trim()
+  }
 
-    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) {
@@ -146,6 +113,13 @@ export class VideoWatchPage {
     }, { 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 () => {