diff options
author | Chocobozzz <me@florianbigard.com> | 2018-05-22 16:02:29 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-05-22 16:02:29 +0200 |
commit | d1bd87e066633b8a66266b280327ec828980916b (patch) | |
tree | bfb30a565088cbb2675a8ab224b1ae1fc5dbfd16 /client/e2e | |
parent | 293c885b5c6d4d694792cf430c51d73ecd1f3bee (diff) | |
download | PeerTube-d1bd87e066633b8a66266b280327ec828980916b.tar.gz PeerTube-d1bd87e066633b8a66266b280327ec828980916b.tar.zst PeerTube-d1bd87e066633b8a66266b280327ec828980916b.zip |
Make it works with new autoplay policy
Diffstat (limited to 'client/e2e')
-rw-r--r-- | client/e2e/protractor.conf.js | 35 | ||||
-rw-r--r-- | client/e2e/src/po/video-upload.po.ts | 16 | ||||
-rw-r--r-- | client/e2e/src/po/video-watch.po.ts | 49 | ||||
-rw-r--r-- | client/e2e/src/videos.e2e-spec.ts | 19 |
4 files changed, 67 insertions, 52 deletions
diff --git a/client/e2e/protractor.conf.js b/client/e2e/protractor.conf.js index a4fd12473..5dcd77284 100644 --- a/client/e2e/protractor.conf.js +++ b/client/e2e/protractor.conf.js | |||
@@ -5,16 +5,14 @@ const {SpecReporter} = require('jasmine-spec-reporter') | |||
5 | 5 | ||
6 | exports.config = { | 6 | exports.config = { |
7 | allScriptsTimeout: 25000, | 7 | allScriptsTimeout: 25000, |
8 | specs: [ | 8 | specs: ['./src/**/*.e2e-spec.ts'], |
9 | './src/**/*.e2e-spec.ts' | ||
10 | ], | ||
11 | 9 | ||
12 | seleniumAddress: 'http://hub-cloud.browserstack.com/wd/hub', | 10 | seleniumAddress: 'http://hub-cloud.browserstack.com/wd/hub', |
13 | commonCapabilities: { | 11 | commonCapabilities: { |
14 | 'browserstack.user': process.env.BROWSERSTACK_USER, | 12 | 'browserstack.user': process.env.BROWSERSTACK_USER, |
15 | 'browserstack.key': process.env.BROWSERSTACK_KEY, | 13 | 'browserstack.key': process.env.BROWSERSTACK_KEY, |
16 | 'browserstack.local': true, | 14 | 'browserstack.local': true, |
17 | 'project': 'PeerTube' | 15 | projec: 'PeerTube' |
18 | }, | 16 | }, |
19 | 17 | ||
20 | multiCapabilities: [ | 18 | multiCapabilities: [ |
@@ -24,7 +22,8 @@ exports.config = { | |||
24 | }, | 22 | }, |
25 | { | 23 | { |
26 | browserName: 'Safari', | 24 | browserName: 'Safari', |
27 | version: '11.1' | 25 | version: '11.1', |
26 | resolution: '1920x1080' | ||
28 | }, | 27 | }, |
29 | { | 28 | { |
30 | browserName: 'Firefox', | 29 | browserName: 'Firefox', |
@@ -44,35 +43,29 @@ exports.config = { | |||
44 | realMobile: 'true', | 43 | realMobile: 'true', |
45 | os_version: '5.0' | 44 | os_version: '5.0' |
46 | }, | 45 | }, |
47 | // { | 46 | { |
48 | // browserName: 'Safari', | 47 | browserName: 'Safari', |
49 | // device: 'iPhone 6s', | 48 | device: 'iPhone SE', |
50 | // realMobile: 'true', | 49 | realMobile: 'true', |
51 | // os_version: '9.0' | 50 | os_version: '11.2' |
52 | // }, | 51 | } |
53 | // { | ||
54 | // browserName: 'Safari', | ||
55 | // device: 'iPhone SE', | ||
56 | // realMobile: 'true', | ||
57 | // os_version: '11.2' | ||
58 | // } | ||
59 | ], | 52 | ], |
60 | 53 | ||
61 | maxSessions: 1, | 54 | // maxSessions: 1, |
62 | // BrowserStack compatible ports: https://www.browserstack.com/question/664 | 55 | // BrowserStack compatible ports: https://www.browserstack.com/question/664 |
63 | baseUrl: 'http://localhost:3333/', | 56 | baseUrl: 'http://localhost:3333/', |
64 | framework: 'jasmine', | 57 | framework: 'jasmine', |
65 | jasmineNodeOpts: { | 58 | jasmineNodeOpts: { |
66 | showColors: true, | 59 | showColors: true, |
67 | defaultTimeoutInterval: 45000, | 60 | defaultTimeoutInterval: 45000, |
68 | print: function () {} | 61 | print: function() {} |
69 | }, | 62 | }, |
70 | 63 | ||
71 | onPrepare () { | 64 | onPrepare() { |
72 | require('ts-node').register({ | 65 | require('ts-node').register({ |
73 | project: require('path').join(__dirname, './tsconfig.e2e.json') | 66 | project: require('path').join(__dirname, './tsconfig.e2e.json') |
74 | }) | 67 | }) |
75 | jasmine.getEnv().addReporter(new SpecReporter({spec: {displayStacktrace: true}})) | 68 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })) |
76 | } | 69 | } |
77 | } | 70 | } |
78 | 71 | ||
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' | |||
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | 4 | ||
5 | export class VideoUploadPage { | 5 | export 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 @@ | |||
1 | import { by, element, browser } from 'protractor' | 1 | import { by, element, browser } from 'protractor' |
2 | 2 | ||
3 | export class VideoWatchPage { | 3 | export 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 | }) |