1
0
Fork 0

Fix e2e tests

This commit is contained in:
Chocobozzz 2018-06-08 11:25:12 +02:00
parent dbe868c070
commit 7cf26f433f
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
6 changed files with 22 additions and 16 deletions

View File

@ -18,35 +18,42 @@ exports.config = {
multiCapabilities: [ multiCapabilities: [
{ {
browserName: 'Chrome', browserName: 'Chrome',
version: '66' version: '66',
name: 'Latest Chrome Desktop'
}, },
{ {
browserName: 'Safari', browserName: 'Safari',
version: '11.1' version: '11.1',
name: 'Safari Desktop'
}, },
{ {
browserName: 'Firefox', browserName: 'Firefox',
version: '52' // ESR version: '52', // ESR,
name: 'Old Firefox ESR Desktop'
}, },
{ {
browserName: 'Firefox', browserName: 'Firefox',
version: '60' version: '60',
name: 'Latest Firefox Desktop'
}, },
{ {
browserName: 'Edge', browserName: 'Edge',
version: '16' version: '16',
name: 'Latest Edge Desktop'
}, },
{ {
browserName: 'Chrome', browserName: 'Chrome',
device: 'Google Nexus 6', device: 'Google Nexus 6',
realMobile: 'true', realMobile: 'true',
os_version: '5.0' os_version: '5.0',
name: 'Latest Chrome Android'
}, },
{ {
browserName: 'Safari', browserName: 'Safari',
device: 'iPhone SE', device: 'iPhone SE',
realMobile: 'true', realMobile: 'true',
os_version: '11.2' os_version: '11.2',
name: 'Latest Safari iPhone'
} }
], ],

View File

@ -41,7 +41,7 @@ export class VideoWatchPage {
.then(seconds => parseInt(seconds, 10)) .then(seconds => parseInt(seconds, 10))
} }
async pauseVideo (isAutoplay: boolean) { async pauseVideo (isAutoplay: boolean, isMobileDevice: boolean) {
if (isAutoplay === false) { if (isAutoplay === false) {
const playButton = element(by.css('.vjs-big-play-button')) const playButton = element(by.css('.vjs-big-play-button'))
await browser.wait(browser.ExpectedConditions.elementToBeClickable(playButton)) await browser.wait(browser.ExpectedConditions.elementToBeClickable(playButton))

View File

@ -66,14 +66,14 @@ describe('Videos workflow', () => {
}) })
it('Should play the video', async () => { it('Should play the video', async () => {
await videoWatchPage.pauseVideo(!isMobileDevice) await videoWatchPage.pauseVideo(!isMobileDevice, isMobileDevice)
expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2) expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
}) })
it('Should watch the associated embed video', async () => { it('Should watch the associated embed video', async () => {
await videoWatchPage.goOnAssociatedEmbed() await videoWatchPage.goOnAssociatedEmbed()
await videoWatchPage.pauseVideo(false) await videoWatchPage.pauseVideo(false, isMobileDevice)
expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2) expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
}) })
}) })

View File

@ -55,7 +55,7 @@ export class AppComponent implements OnInit {
if (e instanceof NavigationEnd) { if (e instanceof NavigationEnd) {
const pathname = window.location.pathname const pathname = window.location.pathname
if (!pathname || pathname === '/' || is18nPath(pathname)) { if (!pathname || pathname === '/' || is18nPath(pathname)) {
this.redirectService.redirectToHomepage() this.redirectService.redirectToHomepage(true)
} }
} }
}) })

View File

@ -28,10 +28,10 @@ export class RedirectService {
}) })
} }
redirectToHomepage () { redirectToHomepage (skipLocationChange = false) {
console.log('Redirecting to %s...', RedirectService.DEFAULT_ROUTE) console.log('Redirecting to %s...', RedirectService.DEFAULT_ROUTE)
this.router.navigate([ RedirectService.DEFAULT_ROUTE ], { skipLocationChange: true }) this.router.navigate([ RedirectService.DEFAULT_ROUTE ], { skipLocationChange })
.catch(() => { .catch(() => {
console.error( console.error(
'Cannot navigate to %s, resetting default route to %s.', 'Cannot navigate to %s, resetting default route to %s.',
@ -40,7 +40,7 @@ export class RedirectService {
) )
RedirectService.DEFAULT_ROUTE = RedirectService.INIT_DEFAULT_ROUTE RedirectService.DEFAULT_ROUTE = RedirectService.INIT_DEFAULT_ROUTE
return this.router.navigate([ RedirectService.DEFAULT_ROUTE ], { skipLocationChange: true }) return this.router.navigate([ RedirectService.DEFAULT_ROUTE ], { skipLocationChange })
}) })
} }

View File

@ -21,7 +21,6 @@ import * as videojs from 'video.js'
import { VideoDetails } from '../../../../shared' import { VideoDetails } from '../../../../shared'
import { addContextMenu, getVideojsOptions, loadLocale } from '../../assets/player/peertube-player' import { addContextMenu, getVideojsOptions, loadLocale } from '../../assets/player/peertube-player'
import { environment } from '../../environments/environment'
function getVideoUrl (id: string) { function getVideoUrl (id: string) {
return window.location.origin + '/api/v1/videos/' + id return window.location.origin + '/api/v1/videos/' + id
@ -62,7 +61,7 @@ const urlParts = window.location.href.split('/')
const lastPart = urlParts[urlParts.length - 1] const lastPart = urlParts[urlParts.length - 1]
const videoId = lastPart.indexOf('?') === -1 ? lastPart : lastPart.split('?')[0] const videoId = lastPart.indexOf('?') === -1 ? lastPart : lastPart.split('?')[0]
loadLocale(environment.apiUrl, videojs, navigator.language) loadLocale(window.location.origin, videojs, navigator.language)
.then(() => loadVideoInfo(videoId)) .then(() => loadVideoInfo(videoId))
.then(async response => { .then(async response => {
const videoContainerId = 'video-container' const videoContainerId = 'video-container'