Fix e2e tests
This commit is contained in:
parent
2199aaef6f
commit
c8bc2a1af6
|
@ -85,7 +85,9 @@ exports.config = {
|
||||||
require('ts-node').register({
|
require('ts-node').register({
|
||||||
project: require('path').join(__dirname, './tsconfig.e2e.json')
|
project: require('path').join(__dirname, './tsconfig.e2e.json')
|
||||||
})
|
})
|
||||||
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }))
|
jasmine.getEnv().addReporter(new SpecReporter({
|
||||||
|
spec: { displayStacktrace: 'raw' }
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { browser, by, element, ExpectedConditions } from 'protractor'
|
import { browser, by, element } from 'protractor'
|
||||||
import { browserSleep, isIOS, isMobileDevice } from '../utils'
|
import { browserSleep, isIOS, isMobileDevice, isSafari } from '../utils'
|
||||||
|
|
||||||
export class PlayerPage {
|
export class PlayerPage {
|
||||||
|
|
||||||
|
@ -17,27 +17,22 @@ export class PlayerPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
async playAndPauseVideo (isAutoplay: boolean) {
|
async playAndPauseVideo (isAutoplay: boolean) {
|
||||||
// Autoplay is disabled on iOS
|
const videojsEl = element(by.css('div.video-js'))
|
||||||
if (isAutoplay === false || await isIOS()) {
|
await browser.wait(browser.ExpectedConditions.elementToBeClickable(videojsEl))
|
||||||
|
|
||||||
|
// Autoplay is disabled on iOS and Safari
|
||||||
|
if (await isIOS() || await isSafari() || await isMobileDevice()) {
|
||||||
|
// We can't play the video using protractor if it is not muted
|
||||||
|
await browser.executeScript(`document.querySelector('video').muted = true`)
|
||||||
|
await this.clickOnPlayButton()
|
||||||
|
} else if (isAutoplay === false) {
|
||||||
await this.clickOnPlayButton()
|
await this.clickOnPlayButton()
|
||||||
}
|
}
|
||||||
|
|
||||||
await browserSleep(2000)
|
await browserSleep(2000)
|
||||||
await browser.wait(browser.ExpectedConditions.invisibilityOf(element(by.css('.vjs-loading-spinner'))))
|
await browser.wait(browser.ExpectedConditions.invisibilityOf(element(by.css('.vjs-loading-spinner'))))
|
||||||
|
|
||||||
const videojsEl = element(by.css('div.video-js'))
|
await browserSleep(2000)
|
||||||
await browser.wait(browser.ExpectedConditions.elementToBeClickable(videojsEl))
|
|
||||||
|
|
||||||
if (await isMobileDevice()) {
|
|
||||||
await browserSleep(5000)
|
|
||||||
|
|
||||||
// On Android, we need to click twice on "play" (BrowserStack particularity)
|
|
||||||
if (!await isIOS()) await videojsEl.click()
|
|
||||||
}
|
|
||||||
|
|
||||||
browser.ignoreSynchronization = false
|
|
||||||
await browserSleep(7000)
|
|
||||||
browser.ignoreSynchronization = true
|
|
||||||
|
|
||||||
await videojsEl.click()
|
await videojsEl.click()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
import { browser } from 'protractor'
|
import { browser } from 'protractor'
|
||||||
|
|
||||||
async function browserSleep (amount: number) {
|
async function browserSleep (amount: number) {
|
||||||
if (await isIOS()) browser.ignoreSynchronization = false
|
const oldValue = await browser.waitForAngularEnabled()
|
||||||
|
|
||||||
|
// iOS does not seem to work with protractor
|
||||||
|
// https://github.com/angular/protractor/issues/2840
|
||||||
|
if (await isIOS()) browser.waitForAngularEnabled(true)
|
||||||
|
|
||||||
await browser.sleep(amount)
|
await browser.sleep(amount)
|
||||||
|
|
||||||
if (await isIOS()) browser.ignoreSynchronization = true
|
if (await isIOS()) browser.waitForAngularEnabled(oldValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function isMobileDevice () {
|
async function isMobileDevice () {
|
||||||
|
|
|
@ -43,7 +43,7 @@ describe('Videos workflow', () => {
|
||||||
if (await isIOS()) {
|
if (await isIOS()) {
|
||||||
// iOS does not seem to work with protractor
|
// iOS does not seem to work with protractor
|
||||||
// https://github.com/angular/protractor/issues/2840
|
// https://github.com/angular/protractor/issues/2840
|
||||||
browser.ignoreSynchronization = true
|
browser.waitForAngularEnabled(false)
|
||||||
|
|
||||||
console.log('iOS detected')
|
console.log('iOS detected')
|
||||||
} else if (await isMobileDevice()) {
|
} else if (await isMobileDevice()) {
|
||||||
|
@ -111,6 +111,7 @@ describe('Videos workflow', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should watch the associated embed video', async () => {
|
it('Should watch the associated embed video', async () => {
|
||||||
|
const oldValue = await browser.waitForAngularEnabled()
|
||||||
await browser.waitForAngularEnabled(false)
|
await browser.waitForAngularEnabled(false)
|
||||||
|
|
||||||
await videoWatchPage.goOnAssociatedEmbed()
|
await videoWatchPage.goOnAssociatedEmbed()
|
||||||
|
@ -118,10 +119,11 @@ describe('Videos workflow', () => {
|
||||||
await playerPage.playAndPauseVideo(false)
|
await playerPage.playAndPauseVideo(false)
|
||||||
expect(playerPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
|
expect(playerPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
|
||||||
|
|
||||||
await browser.waitForAngularEnabled(true)
|
await browser.waitForAngularEnabled(oldValue)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should watch the p2p media loader embed video', async () => {
|
it('Should watch the p2p media loader embed video', async () => {
|
||||||
|
const oldValue = await browser.waitForAngularEnabled()
|
||||||
await browser.waitForAngularEnabled(false)
|
await browser.waitForAngularEnabled(false)
|
||||||
|
|
||||||
await videoWatchPage.goOnP2PMediaLoaderEmbed()
|
await videoWatchPage.goOnP2PMediaLoaderEmbed()
|
||||||
|
@ -129,7 +131,7 @@ describe('Videos workflow', () => {
|
||||||
await playerPage.playAndPauseVideo(false)
|
await playerPage.playAndPauseVideo(false)
|
||||||
expect(playerPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
|
expect(playerPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
|
||||||
|
|
||||||
await browser.waitForAngularEnabled(true)
|
await browser.waitForAngularEnabled(oldValue)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should update the video', async () => {
|
it('Should update the video', async () => {
|
||||||
|
@ -185,11 +187,12 @@ describe('Videos workflow', () => {
|
||||||
|
|
||||||
await myAccountPage.playPlaylist()
|
await myAccountPage.playPlaylist()
|
||||||
|
|
||||||
|
const oldValue = await browser.waitForAngularEnabled()
|
||||||
await browser.waitForAngularEnabled(false)
|
await browser.waitForAngularEnabled(false)
|
||||||
|
|
||||||
await videoWatchPage.waitUntilVideoName(video2Name, 20000 * 1000)
|
await videoWatchPage.waitUntilVideoName(video2Name, 20000 * 1000)
|
||||||
|
|
||||||
await browser.waitForAngularEnabled(true)
|
await browser.waitForAngularEnabled(oldValue)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should watch the webtorrent playlist in the embed', async () => {
|
it('Should watch the webtorrent playlist in the embed', async () => {
|
||||||
|
@ -198,6 +201,7 @@ describe('Videos workflow', () => {
|
||||||
const accessToken = await browser.executeScript(`return window.localStorage.getItem('access_token');`)
|
const accessToken = await browser.executeScript(`return window.localStorage.getItem('access_token');`)
|
||||||
const refreshToken = await browser.executeScript(`return window.localStorage.getItem('refresh_token');`)
|
const refreshToken = await browser.executeScript(`return window.localStorage.getItem('refresh_token');`)
|
||||||
|
|
||||||
|
const oldValue = await browser.waitForAngularEnabled()
|
||||||
await browser.waitForAngularEnabled(false)
|
await browser.waitForAngularEnabled(false)
|
||||||
|
|
||||||
await myAccountPage.goOnAssociatedPlaylistEmbed()
|
await myAccountPage.goOnAssociatedPlaylistEmbed()
|
||||||
|
@ -212,10 +216,11 @@ describe('Videos workflow', () => {
|
||||||
|
|
||||||
await playerPage.waitUntilPlaylistInfo('2/2')
|
await playerPage.waitUntilPlaylistInfo('2/2')
|
||||||
|
|
||||||
await browser.waitForAngularEnabled(true)
|
await browser.waitForAngularEnabled(oldValue)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should watch the HLS playlist in the embed', async () => {
|
it('Should watch the HLS playlist in the embed', async () => {
|
||||||
|
const oldValue = await browser.waitForAngularEnabled()
|
||||||
await browser.waitForAngularEnabled(false)
|
await browser.waitForAngularEnabled(false)
|
||||||
|
|
||||||
await videoWatchPage.goOnP2PMediaLoaderPlaylistEmbed()
|
await videoWatchPage.goOnP2PMediaLoaderPlaylistEmbed()
|
||||||
|
@ -224,7 +229,7 @@ describe('Videos workflow', () => {
|
||||||
|
|
||||||
await playerPage.waitUntilPlaylistInfo('2/2')
|
await playerPage.waitUntilPlaylistInfo('2/2')
|
||||||
|
|
||||||
await browser.waitForAngularEnabled(true)
|
await browser.waitForAngularEnabled(oldValue)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should delete the video 2', async () => {
|
it('Should delete the video 2', async () => {
|
||||||
|
|
Loading…
Reference in New Issue