From ee68bbc481c154111c60fe80d57565d35bfac46e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 12 May 2020 16:38:55 +0200 Subject: Unblock ios e2e tests --- client/e2e/src/po/app.po.ts | 7 ------- client/e2e/src/po/video-watch.po.ts | 21 ++++++++++++--------- client/e2e/src/utils.ts | 30 ++++++++++++++++++++++++++++++ client/e2e/src/videos.e2e-spec.ts | 33 ++++++++++++++------------------- 4 files changed, 56 insertions(+), 35 deletions(-) create mode 100644 client/e2e/src/utils.ts (limited to 'client/e2e/src') diff --git a/client/e2e/src/po/app.po.ts b/client/e2e/src/po/app.po.ts index a636e825f..4954880ef 100644 --- a/client/e2e/src/po/app.po.ts +++ b/client/e2e/src/po/app.po.ts @@ -10,12 +10,5 @@ export class AppPage { await element(by.css('.configure-instance-button')).click() await browser.switchTo().window(firstHandle) - - await browser.refresh() - - await element(by.css('.form-group-checkbox')).click() - await element(by.css('.action-button-cancel')).click() - - await browser.switchTo().window(firstHandle) } } diff --git a/client/e2e/src/po/video-watch.po.ts b/client/e2e/src/po/video-watch.po.ts index c5e37e6de..bcfceefbc 100644 --- a/client/e2e/src/po/video-watch.po.ts +++ b/client/e2e/src/po/video-watch.po.ts @@ -1,4 +1,5 @@ import { browser, by, element, ElementFinder, ExpectedConditions } from 'protractor' +import { browserSleep } from '../utils' export class VideoWatchPage { async goOnVideosList (isMobileDevice: boolean, isSafari: boolean) { @@ -11,10 +12,10 @@ export class VideoWatchPage { url = '/videos/recently-added' } - await browser.get(url) + await browser.get(url, 20000) // Waiting the following element does not work on Safari... - if (isSafari) return browser.sleep(3000) + if (isSafari) return browserSleep(3000) const elem = element.all(by.css('.videos .video-miniature .video-miniature-name')).first() return browser.wait(browser.ExpectedConditions.visibilityOf(elem)) @@ -27,13 +28,12 @@ export class VideoWatchPage { } waitWatchVideoName (videoName: string, isMobileDevice: boolean, isSafari: boolean) { + if (isSafari) return browserSleep(5000) + // On mobile we display the first node, on desktop the second const index = isMobileDevice ? 0 : 1 const elem = element.all(by.css('.video-info .video-info-name')).get(index) - - if (isSafari) return browser.sleep(5000) - return browser.wait(browser.ExpectedConditions.textToBePresentInElement(elem, videoName)) } @@ -55,7 +55,7 @@ export class VideoWatchPage { await playButton.click() } - await browser.sleep(1000) + await browserSleep(1000) await browser.wait(browser.ExpectedConditions.invisibilityOf(element(by.css('.vjs-loading-spinner')))) const videojsEl = element(by.css('div.video-js')) @@ -63,13 +63,16 @@ export class VideoWatchPage { // On Android, we need to click twice on "play" (BrowserStack particularity) if (isMobileDevice) { - await browser.sleep(3000) + await browserSleep(3000) + await videojsEl.click() } - await browser.sleep(7000) + browser.ignoreSynchronization = false + await browserSleep(7000) + browser.ignoreSynchronization = true - return videojsEl.click() + await videojsEl.click() } async clickOnVideo (videoName: string) { diff --git a/client/e2e/src/utils.ts b/client/e2e/src/utils.ts new file mode 100644 index 000000000..e19da6402 --- /dev/null +++ b/client/e2e/src/utils.ts @@ -0,0 +1,30 @@ +import { browser } from 'protractor' + +async function browserSleep (amount: number) { + if (await isIOS()) browser.ignoreSynchronization = false + + await browser.sleep(amount) + + if (await isIOS()) browser.ignoreSynchronization = true +} + +async function isMobileDevice () { + const caps = await browser.getCapabilities() + return caps.get('realMobile') === 'true' || caps.get('realMobile') === true +} + +async function isSafari () { + const caps = await browser.getCapabilities() + return caps.get('browserName') && caps.get('browserName').toLowerCase() === 'safari' +} + +async function isIOS () { + return await isMobileDevice() && await isSafari() +} + +export { + isMobileDevice, + isSafari, + isIOS, + browserSleep +} diff --git a/client/e2e/src/videos.e2e-spec.ts b/client/e2e/src/videos.e2e-spec.ts index b2c5ab4c6..0cba8331f 100644 --- a/client/e2e/src/videos.e2e-spec.ts +++ b/client/e2e/src/videos.e2e-spec.ts @@ -1,10 +1,11 @@ -import { VideoWatchPage } from './po/video-watch.po' -import { VideoUploadPage } from './po/video-upload.po' -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' +import { LoginPage } from './po/login.po' +import { MyAccountPage } from './po/my-account' +import { VideoUpdatePage } from './po/video-update.po' +import { VideoUploadPage } from './po/video-upload.po' +import { VideoWatchPage } from './po/video-watch.po' +import { isIOS, isMobileDevice, isSafari } from './utils' async function skipIfUploadNotSupported () { if (await isMobileDevice() || await isSafari()) { @@ -15,16 +16,6 @@ async function skipIfUploadNotSupported () { return false } -async function isMobileDevice () { - const caps = await browser.getCapabilities() - return caps.get('realMobile') === 'true' || caps.get('realMobile') === true -} - -async function isSafari () { - const caps = await browser.getCapabilities() - return caps.get('browserName') && caps.get('browserName').toLowerCase() === 'safari' -} - describe('Videos workflow', () => { let videoWatchPage: VideoWatchPage let videoUploadPage: VideoUploadPage @@ -46,11 +37,15 @@ describe('Videos workflow', () => { loginPage = new LoginPage() appPage = new AppPage() - if (await isMobileDevice()) { - console.log('Mobile device detected.') - } + if (await isIOS()) { + // iOS does not seem to work with protractor + // https://github.com/angular/protractor/issues/2840 + browser.ignoreSynchronization = true - if (await isSafari()) { + console.log('iOS detected') + } else if (await isMobileDevice()) { + console.log('Android detected.') + } else if (await isSafari()) { console.log('Safari detected.') } -- cgit v1.2.3