]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix e2e tests in parallel
authorChocobozzz <me@florianbigard.com>
Tue, 18 Jun 2019 08:20:55 +0000 (10:20 +0200)
committerChocobozzz <me@florianbigard.com>
Wed, 19 Jun 2019 13:05:35 +0000 (15:05 +0200)
client/e2e/protractor.conf.js
client/e2e/src/po/my-account.ts
client/e2e/src/po/video-watch.po.ts
client/e2e/src/videos.e2e-spec.ts

index 51d0b220dc0fc3b469a008d16f0435e7ded9b141..3fce9b0f53e3ed57cbe99077032e3772ef1b9d88 100644 (file)
@@ -18,25 +18,30 @@ exports.config = {
   multiCapabilities: [
     {
       browserName: 'Chrome',
-      name: 'Latest Chrome Desktop'
+      name: 'Latest Chrome Desktop',
+      resolution: '1280x1024'
     },
     {
       browserName: 'Safari',
       version: '11.1',
-      name: 'Safari Desktop'
+      name: 'Safari Desktop',
+      resolution: '1280x1024'
     },
     {
       browserName: 'Firefox',
       version: '60', // ESR,
-      name: 'Firefox ESR Desktop'
+      name: 'Firefox ESR Desktop',
+      resolution: '1280x1024'
     },
     {
       browserName: 'Firefox',
-      name: 'Latest Firefox Desktop'
+      name: 'Latest Firefox Desktop',
+      resolution: '1280x1024'
     },
     {
       browserName: 'Edge',
-      name: 'Latest Edge Desktop'
+      name: 'Latest Edge Desktop',
+      resolution: '1280x1024'
     },
     {
       browserName: 'Chrome',
index e49372983c482a4bda9a89fb4ad6fdda7ab2f1dd..49db789fb486d34eef20eecfc040e8ff97d02fb7 100644 (file)
@@ -16,34 +16,32 @@ export class MyAccountPage {
 
   // My account Videos
 
-  getLastVideoName () {
-    return this.getAllVideoNameElements().first().getText()
-  }
-
-  removeLastVideo () {
-    return this.getLastVideoElement().element(by.css('my-delete-button')).click()
+  removeVideo (name: string) {
+    return this.getVideoElement(name).element(by.css('my-delete-button')).click()
   }
 
   validRemove () {
     return element(by.css('.action-button-submit')).click()
   }
 
-  countVideos () {
-    return this.getAllVideoNameElements().count()
+  countVideos (names: string[]) {
+    return element.all(by.css('.video'))
+                  .filter(e => {
+                    return e.element(by.css('.video-miniature-name'))
+                            .getText()
+                            .then(t => names.some(n => t.includes(n)))
+                  })
+                  .count()
   }
 
   // My account playlists
 
-  getLastUpdatedPlaylistName () {
-    return this.getLastUpdatedPlaylist().element(by.css('.miniature-name')).getText()
-  }
-
-  getLastUpdatedPlaylistVideosText () {
-    return this.getLastUpdatedPlaylist().element(by.css('.miniature-playlist-info-overlay')).getText()
+  getPlaylistVideosText (name: string) {
+    return this.getPlaylist(name).element(by.css('.miniature-playlist-info-overlay')).getText()
   }
 
-  clickOnLastUpdatedPlaylist () {
-    return this.getLastUpdatedPlaylist().element(by.css('.miniature-thumbnail')).click()
+  clickOnPlaylist (name: string) {
+    return this.getPlaylist(name).element(by.css('.miniature-thumbnail')).click()
   }
 
   countTotalPlaylistElements () {
@@ -56,17 +54,17 @@ export class MyAccountPage {
 
   // My account Videos
 
-  private getLastVideoElement () {
-    return element.all(by.css('.video')).first()
-  }
-
-  private getAllVideoNameElements () {
-    return element.all(by.css('.video-miniature-name'))
+  private getVideoElement (name: string) {
+    return element.all(by.css('.video'))
+                  .filter(e => e.element(by.css('.video-miniature-name')).getText().then(t => t.includes(name)))
+                  .first()
   }
 
   // My account playlists
 
-  private getLastUpdatedPlaylist () {
-    return element.all(by.css('my-video-playlist-miniature')).first()
+  private getPlaylist (name: string) {
+    return element.all(by.css('my-video-playlist-miniature'))
+      .filter(e => e.element(by.css('.miniature-name')).getText().then(t => t.includes(name)))
+      .first()
   }
 }
index 9bb0a39192168c69023ae610daf1ef0e2eb36d29..c06b131b65f891cdb55d6d18165ef30f6eac9db5 100644 (file)
@@ -126,8 +126,18 @@ export class VideoWatchPage {
     return element(by.css('.action-button-save')).click()
   }
 
-  async saveToWatchLater () {
-    return element.all(by.css('my-video-add-to-playlist .playlist')).first().click()
+  async createPlaylist (name: string) {
+    await element(by.css('.new-playlist-button')).click()
+
+    await element(by.css('#displayName')).sendKeys(name)
+
+    return element(by.css('.new-playlist-block input[type=submit]')).click()
+  }
+
+  async saveToPlaylist (name: string) {
+    return element.all(by.css('my-video-add-to-playlist .playlist'))
+                  .filter(p => p.getText().then(t => t === name))
+                  .click()
   }
 
   waitUntilVideoName (name: string, maxTime: number) {
index c19ab30927d1a4ad817233d7503e5e8ce3a47d31..27706a5061d3cf913e1e0b0d8695467a5e2b0ba5 100644 (file)
@@ -31,7 +31,9 @@ describe('Videos workflow', () => {
   let myAccountPage: MyAccountPage
   let loginPage: LoginPage
 
-  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 () => {
@@ -122,41 +124,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 +170,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)
   })
 })