aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/e2e/src
diff options
context:
space:
mode:
Diffstat (limited to 'client/e2e/src')
-rw-r--r--client/e2e/src/po/video-upload.po.ts16
-rw-r--r--client/e2e/src/po/video-watch.po.ts49
-rw-r--r--client/e2e/src/videos.e2e-spec.ts19
3 files changed, 53 insertions, 31 deletions
diff --git a/client/e2e/src/po/video-upload.po.ts b/client/e2e/src/po/video-upload.po.ts
index 1ac696107..1978707e3 100644
--- a/client/e2e/src/po/video-upload.po.ts
+++ b/client/e2e/src/po/video-upload.po.ts
@@ -3,16 +3,26 @@ import { FileDetector } from 'selenium-webdriver/remote'
3import { join } from 'path' 3import { join } from 'path'
4 4
5export class VideoUploadPage { 5export class VideoUploadPage {
6 navigateTo () { 6 async navigateTo () {
7 return browser.get('/videos/upload') 7 await element(by.css('.header .upload-button')).click()
8
9 return browser.wait(browser.ExpectedConditions.visibilityOf(element(by.css('.upload-video-container'))))
8 } 10 }
9 11
10 async uploadVideo () { 12 async uploadVideo () {
11 browser.setFileDetector(new FileDetector()) 13 browser.setFileDetector(new FileDetector())
12 14
13 const fileToUpload = join(__dirname, '../../fixtures/video.mp4') 15 const fileToUpload = join(__dirname, '../../fixtures/video.mp4')
16 const fileInputSelector = '.upload-video-container input[type=file]'
17 const parentFileInput = '.upload-video .button-file'
18
19 // Avoid sending keys on non visible element
20 await browser.executeScript(`document.querySelector('${fileInputSelector}').style.opacity = 1`)
21 // await browser.executeScript(`document.querySelector('${fileInputSelector}').style.opacity = 1`)
22 await browser.executeScript(`document.querySelector('${parentFileInput}').style.overflow = 'initial'`)
14 23
15 await element(by.css('.upload-video-container input[type=file]')).sendKeys(fileToUpload) 24 const elem = element(by.css(fileInputSelector))
25 await elem.sendKeys(fileToUpload)
16 26
17 // Wait for the upload to finish 27 // Wait for the upload to finish
18 await browser.wait(browser.ExpectedConditions.elementToBeClickable(this.getSecondStepSubmitButton())) 28 await browser.wait(browser.ExpectedConditions.elementToBeClickable(this.getSecondStepSubmitButton()))
diff --git a/client/e2e/src/po/video-watch.po.ts b/client/e2e/src/po/video-watch.po.ts
index 0f37e3e33..19d02ff51 100644
--- a/client/e2e/src/po/video-watch.po.ts
+++ b/client/e2e/src/po/video-watch.po.ts
@@ -1,7 +1,7 @@
1import { by, element, browser } from 'protractor' 1import { by, element, browser } from 'protractor'
2 2
3export class VideoWatchPage { 3export class VideoWatchPage {
4 async goOnVideosList (isIphoneDevice: boolean) { 4 async goOnVideosList (isIphoneDevice: boolean, isSafari: boolean) {
5 let url: string 5 let url: string
6 6
7 if (isIphoneDevice === true) { 7 if (isIphoneDevice === true) {
@@ -12,11 +12,16 @@ export class VideoWatchPage {
12 } 12 }
13 13
14 await browser.get(url) 14 await browser.get(url)
15 return browser.wait(browser.ExpectedConditions.elementToBeClickable(element(this.getFirstVideoListSelector()))) 15
16 // Waiting the following element does not work on Safari...
17 if (isSafari === true) return browser.sleep(3000)
18
19 const elem = element.all(by.css('.videos .video-miniature .video-miniature-name')).first()
20 return browser.wait(browser.ExpectedConditions.visibilityOf(elem))
16 } 21 }
17 22
18 getVideosListName () { 23 getVideosListName () {
19 return element.all(this.getFirstVideoListSelector()) 24 return element.all(by.css('.videos .video-miniature .video-miniature-name'))
20 .getText() 25 .getText()
21 .then((texts: any) => texts.map(t => t.trim())) 26 .then((texts: any) => texts.map(t => t.trim()))
22 } 27 }
@@ -33,19 +38,19 @@ export class VideoWatchPage {
33 .then(seconds => parseInt(seconds, 10)) 38 .then(seconds => parseInt(seconds, 10))
34 } 39 }
35 40
36 async pauseVideo (pauseAfterMs: number, isMobileDevice: boolean, isIphoneDevice: boolean) { 41 async pauseVideo (pauseAfterMs: number, isAutoplay: boolean, isSafari: boolean) {
37 if (isMobileDevice === true) { 42 if (isAutoplay === false) {
38 if (isIphoneDevice === false) { 43 const playButton = element(by.css('.vjs-big-play-button'))
39 const playButton = element(by.css('.vjs-big-play-button')) 44 await browser.wait(browser.ExpectedConditions.elementToBeClickable(playButton))
40 await browser.wait(browser.ExpectedConditions.elementToBeClickable(playButton)) 45 await playButton.click()
41 await playButton.click() 46 }
42 } else { 47
43 const playButton = element(by.css('video')) 48 if (isSafari === true) {
44 await browser.wait(browser.ExpectedConditions.elementToBeClickable(playButton)) 49 await browser.sleep(1000)
45 await playButton.click() 50 await element(by.css('.vjs-play-control')).click()
46 }
47 } 51 }
48 52
53 await browser.sleep(1000)
49 await browser.wait(browser.ExpectedConditions.invisibilityOf(element(by.css('.vjs-loading-spinner')))) 54 await browser.wait(browser.ExpectedConditions.invisibilityOf(element(by.css('.vjs-loading-spinner'))))
50 55
51 const el = element(by.css('div.video-js')) 56 const el = element(by.css('div.video-js'))
@@ -53,11 +58,7 @@ export class VideoWatchPage {
53 58
54 await browser.sleep(pauseAfterMs) 59 await browser.sleep(pauseAfterMs)
55 60
56 if (isIphoneDevice === true) { 61 return el.click()
57 // document.webkitCancelFullScreen()
58 } else {
59 return el.click()
60 }
61 } 62 }
62 63
63 async clickOnVideo (videoName: string) { 64 async clickOnVideo (videoName: string) {
@@ -69,7 +70,7 @@ export class VideoWatchPage {
69 } 70 }
70 71
71 async clickOnFirstVideo () { 72 async clickOnFirstVideo () {
72 const video = element(by.css('.videos .video-miniature:first-child .video-miniature-name')) 73 const video = element.all(by.css('.videos .video-miniature .video-miniature-name')).first()
73 await browser.wait(browser.ExpectedConditions.elementToBeClickable(video)) 74 await browser.wait(browser.ExpectedConditions.elementToBeClickable(video))
74 const textToReturn = video.getText() 75 const textToReturn = video.getText()
75 76
@@ -79,7 +80,11 @@ export class VideoWatchPage {
79 return textToReturn 80 return textToReturn
80 } 81 }
81 82
82 private getFirstVideoListSelector () { 83 async goOnAssociatedEmbed () {
83 return by.css('.videos .video-miniature-name') 84 let url = await browser.getCurrentUrl()
85 url = url.replace('/watch/', '/embed/')
86 url = url.replace(':3333', ':9001')
87
88 return browser.get(url)
84 } 89 }
85} 90}
diff --git a/client/e2e/src/videos.e2e-spec.ts b/client/e2e/src/videos.e2e-spec.ts
index c21bc163e..f216f8dd1 100644
--- a/client/e2e/src/videos.e2e-spec.ts
+++ b/client/e2e/src/videos.e2e-spec.ts
@@ -10,6 +10,7 @@ describe('Videos workflow', () => {
10 const videoName = new Date().getTime() + ' video' 10 const videoName = new Date().getTime() + ' video'
11 let isMobileDevice = false 11 let isMobileDevice = false
12 let isIphoneDevice = false 12 let isIphoneDevice = false
13 let isSafari = false
13 14
14 beforeEach(async () => { 15 beforeEach(async () => {
15 browser.waitForAngularEnabled(false) 16 browser.waitForAngularEnabled(false)
@@ -21,6 +22,7 @@ describe('Videos workflow', () => {
21 const caps = await browser.getCapabilities() 22 const caps = await browser.getCapabilities()
22 isMobileDevice = caps.get('realMobile') === 'true' || caps.get('realMobile') === true 23 isMobileDevice = caps.get('realMobile') === 'true' || caps.get('realMobile') === true
23 isIphoneDevice = caps.get('device') === 'iphone' 24 isIphoneDevice = caps.get('device') === 'iphone'
25 isSafari = caps.get('browserName') && caps.get('browserName').toLowerCase() === 'safari'
24 }) 26 })
25 27
26 it('Should log in', () => { 28 it('Should log in', () => {
@@ -38,14 +40,14 @@ describe('Videos workflow', () => {
38 return 40 return
39 } 41 }
40 42
41 pageUploadPage.navigateTo() 43 await pageUploadPage.navigateTo()
42 44
43 await pageUploadPage.uploadVideo() 45 await pageUploadPage.uploadVideo()
44 return pageUploadPage.validSecondUploadStep(videoName) 46 return pageUploadPage.validSecondUploadStep(videoName)
45 }) 47 })
46 48
47 it('Should list the video', async () => { 49 it('Should list the video', async () => {
48 await videoWatchPage.goOnVideosList(isIphoneDevice) 50 await videoWatchPage.goOnVideosList(isIphoneDevice, isSafari)
49 51
50 if (isMobileDevice) { 52 if (isMobileDevice) {
51 console.log('Skipping because we are on a real device and BrowserStack does not support file upload.') 53 console.log('Skipping because we are on a real device and BrowserStack does not support file upload.')
@@ -59,16 +61,21 @@ describe('Videos workflow', () => {
59 it('Should go on video watch page', async () => { 61 it('Should go on video watch page', async () => {
60 let videoNameToExcept = videoName 62 let videoNameToExcept = videoName
61 63
62 if (isMobileDevice && isIphoneDevice) videoNameToExcept = 'PeerTube_Mobile.v.1' 64 if (isMobileDevice) videoNameToExcept = await videoWatchPage.clickOnFirstVideo()
63
64 if (isMobileDevice && isIphoneDevice === false) videoNameToExcept = await videoWatchPage.clickOnFirstVideo()
65 else await videoWatchPage.clickOnVideo(videoName) 65 else await videoWatchPage.clickOnVideo(videoName)
66 66
67 return videoWatchPage.waitWatchVideoName(videoNameToExcept) 67 return videoWatchPage.waitWatchVideoName(videoNameToExcept)
68 }) 68 })
69 69
70 it('Should play the video', async () => { 70 it('Should play the video', async () => {
71 await videoWatchPage.pauseVideo(7000, isMobileDevice, isIphoneDevice) 71 await videoWatchPage.pauseVideo(7000, !isMobileDevice, isSafari)
72 expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
73 })
74
75 it('Should watch the associated embed video', async () => {
76 await videoWatchPage.goOnAssociatedEmbed()
77
78 await videoWatchPage.pauseVideo(7000, false, isSafari)
72 expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2) 79 expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
73 }) 80 })
74}) 81})