]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/e2e/src/videos.e2e-spec.ts
Fix browserstack badge
[github/Chocobozzz/PeerTube.git] / client / e2e / src / videos.e2e-spec.ts
index c19ab30927d1a4ad817233d7503e5e8ce3a47d31..b2c5ab4c63567d4f0363ca7284f968029028a7a2 100644 (file)
@@ -4,6 +4,7 @@ import { LoginPage } from './po/login.po'
 import { browser } from 'protractor'
 import { VideoUpdatePage } from './po/video-update.po'
 import { MyAccountPage } from './po/my-account'
+import { AppPage } from './po/app.po'
 
 async function skipIfUploadNotSupported () {
   if (await isMobileDevice() || await isSafari()) {
@@ -30,8 +31,11 @@ describe('Videos workflow', () => {
   let videoUpdatePage: VideoUpdatePage
   let myAccountPage: MyAccountPage
   let loginPage: LoginPage
+  let appPage: AppPage
 
-  const videoName = new Date().getTime() + ' video'
+  let videoName = new Date().getTime() + ' video'
+  const video2Name = new Date().getTime() + ' second video'
+  const playlistName = new Date().getTime() + ' playlist'
   let videoWatchUrl: string
 
   beforeEach(async () => {
@@ -40,6 +44,7 @@ describe('Videos workflow', () => {
     videoUpdatePage = new VideoUpdatePage()
     myAccountPage = new MyAccountPage()
     loginPage = new LoginPage()
+    appPage = new AppPage()
 
     if (await isMobileDevice()) {
       console.log('Mobile device detected.')
@@ -48,6 +53,10 @@ describe('Videos workflow', () => {
     if (await isSafari()) {
       console.log('Safari detected.')
     }
+
+    if (!await isMobileDevice()) {
+      await browser.driver.manage().window().maximize()
+    }
   })
 
   it('Should log in', async () => {
@@ -59,6 +68,12 @@ describe('Videos workflow', () => {
     return loginPage.loginAsRootUser()
   })
 
+  it('Should close the welcome modal', async () => {
+    if (await skipIfUploadNotSupported()) return
+
+    await appPage.closeWelcomeModal()
+  })
+
   it('Should upload a video', async () => {
     if (await skipIfUploadNotSupported()) return
 
@@ -122,41 +137,42 @@ describe('Videos workflow', () => {
 
     await videoWatchPage.clickOnUpdate()
 
-    await videoUpdatePage.updateName('my new name')
+    videoName += ' updated'
+    await videoUpdatePage.updateName(videoName)
 
     await videoUpdatePage.validUpdate()
 
     const name = await videoWatchPage.getVideoName()
-    expect(name).toEqual('my new name')
+    expect(name).toEqual(videoName)
   })
 
   it('Should add the video in my playlist', async () => {
     if (await skipIfUploadNotSupported()) return
 
     await videoWatchPage.clickOnSave()
-    await videoWatchPage.saveToWatchLater()
+
+    await videoWatchPage.createPlaylist(playlistName)
+
+    await videoWatchPage.saveToPlaylist(playlistName)
 
     await videoUploadPage.navigateTo()
 
     await videoUploadPage.uploadVideo()
-    await videoUploadPage.validSecondUploadStep('second video')
+    await videoUploadPage.validSecondUploadStep(video2Name)
 
     await videoWatchPage.clickOnSave()
-    await videoWatchPage.saveToWatchLater()
+    await videoWatchPage.saveToPlaylist(playlistName)
   })
 
-  it('Should have the watch later playlist in my account', async () => {
+  it('Should have the playlist in my account', async () => {
     if (await skipIfUploadNotSupported()) return
 
     await myAccountPage.navigateToMyPlaylists()
 
-    const name = await myAccountPage.getLastUpdatedPlaylistName()
-    expect(name).toEqual('Watch later')
-
-    const videosNumberText = await myAccountPage.getLastUpdatedPlaylistVideosText()
+    const videosNumberText = await myAccountPage.getPlaylistVideosText(playlistName)
     expect(videosNumberText).toEqual('2 videos')
 
-    await myAccountPage.clickOnLastUpdatedPlaylist()
+    await myAccountPage.clickOnPlaylist(playlistName)
 
     const count = await myAccountPage.countTotalPlaylistElements()
     expect(count).toEqual(2)
@@ -167,35 +183,25 @@ describe('Videos workflow', () => {
 
     await myAccountPage.playPlaylist()
 
-    await videoWatchPage.waitUntilVideoName('second video', 20000 * 1000)
+    await videoWatchPage.waitUntilVideoName(video2Name, 20000 * 1000)
   })
 
-  it('Should have the video in my account', async () => {
+  it('Should delete the video 2', async () => {
     if (await skipIfUploadNotSupported()) return
 
     await myAccountPage.navigateToMyVideos()
 
-    const lastVideoName = await myAccountPage.getLastVideoName()
-    expect(lastVideoName).toEqual('second video')
-  })
-
-  it('Should delete the last video', async () => {
-    if (await skipIfUploadNotSupported()) return
-
-    await myAccountPage.removeLastVideo()
+    await myAccountPage.removeVideo(video2Name)
     await myAccountPage.validRemove()
 
-    const count = await myAccountPage.countVideos()
+    const count = await myAccountPage.countVideos([ videoName, video2Name ])
     expect(count).toEqual(1)
   })
 
   it('Should delete the first video', async () => {
     if (await skipIfUploadNotSupported()) return
 
-    await myAccountPage.removeLastVideo()
+    await myAccountPage.removeVideo(videoName)
     await myAccountPage.validRemove()
-
-    const count = await myAccountPage.countVideos()
-    expect(count).toEqual(0)
   })
 })