From 1fad099d72584ae54701603729339a3cd1cf0d52 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 24 May 2018 09:05:58 +0200 Subject: Fix protractor with Safari --- client/e2e/protractor.conf.js | 5 ++--- client/e2e/src/po/video-watch.po.ts | 36 +++++++++++++++++++++--------------- client/e2e/src/videos.e2e-spec.ts | 24 +++++++++++------------- 3 files changed, 34 insertions(+), 31 deletions(-) (limited to 'client/e2e') diff --git a/client/e2e/protractor.conf.js b/client/e2e/protractor.conf.js index 5dcd77284..60b0ad904 100644 --- a/client/e2e/protractor.conf.js +++ b/client/e2e/protractor.conf.js @@ -12,7 +12,7 @@ exports.config = { 'browserstack.user': process.env.BROWSERSTACK_USER, 'browserstack.key': process.env.BROWSERSTACK_KEY, 'browserstack.local': true, - projec: 'PeerTube' + project: 'PeerTube' }, multiCapabilities: [ @@ -22,8 +22,7 @@ exports.config = { }, { browserName: 'Safari', - version: '11.1', - resolution: '1920x1080' + version: '11.1' }, { browserName: 'Firefox', diff --git a/client/e2e/src/po/video-watch.po.ts b/client/e2e/src/po/video-watch.po.ts index 19d02ff51..ec3d16c3b 100644 --- a/client/e2e/src/po/video-watch.po.ts +++ b/client/e2e/src/po/video-watch.po.ts @@ -1,11 +1,11 @@ import { by, element, browser } from 'protractor' export class VideoWatchPage { - async goOnVideosList (isIphoneDevice: boolean, isSafari: boolean) { + async goOnVideosList (isMobileDevice: boolean, isSafari: boolean) { let url: string - if (isIphoneDevice === true) { - // Local testing is buggy :/ + // 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' @@ -26,8 +26,11 @@ export class VideoWatchPage { .then((texts: any) => texts.map(t => t.trim())) } - waitWatchVideoName (videoName: string) { + waitWatchVideoName (videoName: string, isSafari: boolean) { const elem = element(by.css('.video-info .video-info-name')) + + if (isSafari) return browser.sleep(5000) + return browser.wait(browser.ExpectedConditions.textToBePresentInElement(elem, videoName)) } @@ -38,27 +41,27 @@ export class VideoWatchPage { .then(seconds => parseInt(seconds, 10)) } - async pauseVideo (pauseAfterMs: number, isAutoplay: boolean, isSafari: boolean) { + async pauseVideo (isAutoplay: boolean, isDesktopSafari: boolean) { if (isAutoplay === false) { const playButton = element(by.css('.vjs-big-play-button')) await browser.wait(browser.ExpectedConditions.elementToBeClickable(playButton)) await playButton.click() } - if (isSafari === true) { - await browser.sleep(1000) - await element(by.css('.vjs-play-control')).click() - } + // if (isDesktopSafari === true) { + // await browser.sleep(1000) + // await element(by.css('.vjs-play-control')).click() + // } await browser.sleep(1000) await browser.wait(browser.ExpectedConditions.invisibilityOf(element(by.css('.vjs-loading-spinner')))) - const el = element(by.css('div.video-js')) - await browser.wait(browser.ExpectedConditions.elementToBeClickable(el)) + const videojsEl = element(by.css('div.video-js')) + await browser.wait(browser.ExpectedConditions.elementToBeClickable(videojsEl)) - await browser.sleep(pauseAfterMs) + await browser.sleep(7000) - return el.click() + return videojsEl.click() } async clickOnVideo (videoName: string) { @@ -70,10 +73,13 @@ export class VideoWatchPage { } async clickOnFirstVideo () { - const video = element.all(by.css('.videos .video-miniature .video-miniature-name')).first() + const video = element.all(by.css('.videos .video-miniature .video-thumbnail')).first() + const videoName = element.all(by.css('.videos .video-miniature .video-miniature-name')).first() + + // Don't know why but the expectation fails on Safari await browser.wait(browser.ExpectedConditions.elementToBeClickable(video)) - const textToReturn = video.getText() + const textToReturn = videoName.getText() await video.click() await browser.wait(browser.ExpectedConditions.urlContains('/watch/')) diff --git a/client/e2e/src/videos.e2e-spec.ts b/client/e2e/src/videos.e2e-spec.ts index f216f8dd1..16fe6b70d 100644 --- a/client/e2e/src/videos.e2e-spec.ts +++ b/client/e2e/src/videos.e2e-spec.ts @@ -9,7 +9,6 @@ describe('Videos workflow', () => { let loginPage: LoginPage const videoName = new Date().getTime() + ' video' let isMobileDevice = false - let isIphoneDevice = false let isSafari = false beforeEach(async () => { @@ -21,13 +20,12 @@ describe('Videos workflow', () => { const caps = await browser.getCapabilities() isMobileDevice = caps.get('realMobile') === 'true' || caps.get('realMobile') === true - isIphoneDevice = caps.get('device') === 'iphone' isSafari = caps.get('browserName') && caps.get('browserName').toLowerCase() === 'safari' }) it('Should log in', () => { - if (isMobileDevice) { - console.log('Skipping because we are on a real device and BrowserStack does not support file upload.') + if (isMobileDevice || isSafari) { + console.log('Skipping because we are on a real device or Safari and BrowserStack does not support file upload.') return } @@ -35,8 +33,8 @@ describe('Videos workflow', () => { }) it('Should upload a video', async () => { - if (isMobileDevice) { - console.log('Skipping because we are on a real device and BrowserStack does not support file upload.') + if (isMobileDevice || isSafari) { + console.log('Skipping because we are on a real device or Safari and BrowserStack does not support file upload.') return } @@ -47,10 +45,10 @@ describe('Videos workflow', () => { }) it('Should list the video', async () => { - await videoWatchPage.goOnVideosList(isIphoneDevice, isSafari) + await videoWatchPage.goOnVideosList(isMobileDevice, isSafari) - if (isMobileDevice) { - console.log('Skipping because we are on a real device and BrowserStack does not support file upload.') + if (isMobileDevice || isSafari) { + console.log('Skipping because we are on a real device or Safari and BrowserStack does not support file upload.') return } @@ -61,21 +59,21 @@ describe('Videos workflow', () => { it('Should go on video watch page', async () => { let videoNameToExcept = videoName - if (isMobileDevice) videoNameToExcept = await videoWatchPage.clickOnFirstVideo() + if (isMobileDevice || isSafari) videoNameToExcept = await videoWatchPage.clickOnFirstVideo() else await videoWatchPage.clickOnVideo(videoName) - return videoWatchPage.waitWatchVideoName(videoNameToExcept) + return videoWatchPage.waitWatchVideoName(videoNameToExcept, isSafari) }) it('Should play the video', async () => { - await videoWatchPage.pauseVideo(7000, !isMobileDevice, isSafari) + await videoWatchPage.pauseVideo(!isMobileDevice, isSafari && isMobileDevice === false) expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2) }) it('Should watch the associated embed video', async () => { await videoWatchPage.goOnAssociatedEmbed() - await videoWatchPage.pauseVideo(7000, false, isSafari) + await videoWatchPage.pauseVideo(false, isSafari && isMobileDevice === false) expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2) }) }) -- cgit v1.2.3