mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Fix e2e tests
This commit is contained in:
parent
9684bc959e
commit
e29221f855
@ -1,4 +1,4 @@
|
|||||||
import { go } from '../utils'
|
import { browserSleep, go, isAndroid, isMobileDevice } from '../utils'
|
||||||
|
|
||||||
export class LoginPage {
|
export class LoginPage {
|
||||||
|
|
||||||
@ -23,9 +23,17 @@ export class LoginPage {
|
|||||||
await $('input#username').setValue(username)
|
await $('input#username').setValue(username)
|
||||||
await $('input#password').setValue(password)
|
await $('input#password').setValue(password)
|
||||||
|
|
||||||
await browser.pause(1000)
|
await browserSleep(1000)
|
||||||
|
|
||||||
await $('form input[type=submit]').click()
|
const submit = $('.login-form-and-externals > form input[type=submit]')
|
||||||
|
await submit.click()
|
||||||
|
|
||||||
|
// Have to do this on Android, don't really know why
|
||||||
|
// I think we need to "escape" from the password input, so click twice on the submit button
|
||||||
|
if (isAndroid()) {
|
||||||
|
await browserSleep(2000)
|
||||||
|
await submit.click()
|
||||||
|
}
|
||||||
|
|
||||||
if (this.isMobileDevice) {
|
if (this.isMobileDevice) {
|
||||||
const menuToggle = $('.top-left-block span[role=button]')
|
const menuToggle = $('.top-left-block span[role=button]')
|
||||||
|
@ -29,29 +29,32 @@ export class PlayerPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async playAndPauseVideo (isAutoplay: boolean, waitUntilSec: number) {
|
async playAndPauseVideo (isAutoplay: boolean, waitUntilSec: number) {
|
||||||
const videojsElem = () => $('div.video-js')
|
// Autoplay is disabled on mobile and Safari
|
||||||
|
if (isIOS() || isSafari() || isMobileDevice() || isAutoplay === false) {
|
||||||
await videojsElem().waitForExist()
|
await this.playVideo()
|
||||||
|
|
||||||
// Autoplay is disabled on iOS and Safari
|
|
||||||
if (isIOS() || isSafari() || isMobileDevice()) {
|
|
||||||
// We can't play the video if it is not muted
|
|
||||||
await browser.execute(`document.querySelector('video').muted = true`)
|
|
||||||
await this.clickOnPlayButton()
|
|
||||||
} else if (isAutoplay === false) {
|
|
||||||
await this.clickOnPlayButton()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await $('div.video-js.vjs-has-started').waitForExist()
|
||||||
|
|
||||||
await browserSleep(2000)
|
await browserSleep(2000)
|
||||||
|
|
||||||
await browser.waitUntil(async () => {
|
await browser.waitUntil(async () => {
|
||||||
return (await this.getWatchVideoPlayerCurrentTime()) >= waitUntilSec
|
return (await this.getWatchVideoPlayerCurrentTime()) >= waitUntilSec
|
||||||
})
|
})
|
||||||
|
|
||||||
await videojsElem().click()
|
// Pause video
|
||||||
|
await $('div.video-js').click()
|
||||||
}
|
}
|
||||||
|
|
||||||
async playVideo () {
|
async playVideo () {
|
||||||
|
await $('div.video-js.vjs-paused').waitForExist()
|
||||||
|
|
||||||
|
// Autoplay is disabled on iOS and Safari
|
||||||
|
if (isIOS() || isSafari() || isMobileDevice()) {
|
||||||
|
// We can't play the video if it is not muted
|
||||||
|
await browser.execute(`document.querySelector('video').muted = true`)
|
||||||
|
}
|
||||||
|
|
||||||
return this.clickOnPlayButton()
|
return this.clickOnPlayButton()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,12 @@ function isMobileDevice () {
|
|||||||
return platformName === 'android' || platformName === 'ios'
|
return platformName === 'android' || platformName === 'ios'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isAndroid () {
|
||||||
|
const platformName = (browser.capabilities['platformName'] || '').toLowerCase()
|
||||||
|
|
||||||
|
return platformName === 'android'
|
||||||
|
}
|
||||||
|
|
||||||
function isSafari () {
|
function isSafari () {
|
||||||
return browser.capabilities['browserName'] &&
|
return browser.capabilities['browserName'] &&
|
||||||
browser.capabilities['browserName'].toLowerCase() === 'safari'
|
browser.capabilities['browserName'].toLowerCase() === 'safari'
|
||||||
@ -41,6 +47,7 @@ export {
|
|||||||
isMobileDevice,
|
isMobileDevice,
|
||||||
isSafari,
|
isSafari,
|
||||||
isIOS,
|
isIOS,
|
||||||
|
isAndroid,
|
||||||
waitServerUp,
|
waitServerUp,
|
||||||
go,
|
go,
|
||||||
browserSleep
|
browserSleep
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
|
"typeRoots": [
|
||||||
|
"../node_modules/@types",
|
||||||
|
"../node_modules"
|
||||||
|
],
|
||||||
"types": [
|
"types": [
|
||||||
"node",
|
"node",
|
||||||
"@wdio/globals/types",
|
"@wdio/globals/types",
|
||||||
|
@ -17,18 +17,32 @@ function buildMainOptions (sessionName: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildBStackDesktopOptions (sessionName: string, resolution: string, os?: string) {
|
function buildBStackDesktopOptions (options: {
|
||||||
|
sessionName: string
|
||||||
|
resolution: string
|
||||||
|
os?: string
|
||||||
|
osVersion?: string
|
||||||
|
}) {
|
||||||
|
const { sessionName, resolution, os, osVersion } = options
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'bstack:options': {
|
'bstack:options': {
|
||||||
...buildMainOptions(sessionName),
|
...buildMainOptions(sessionName),
|
||||||
|
|
||||||
os,
|
os,
|
||||||
|
osVersion,
|
||||||
resolution
|
resolution
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildBStackMobileOptions (sessionName: string, deviceName: string, osVersion: string) {
|
function buildBStackMobileOptions (options: {
|
||||||
|
sessionName: string
|
||||||
|
deviceName: string
|
||||||
|
osVersion: string
|
||||||
|
}) {
|
||||||
|
const { sessionName, deviceName, osVersion } = options
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'bstack:options': {
|
'bstack:options': {
|
||||||
...buildMainOptions(sessionName),
|
...buildMainOptions(sessionName),
|
||||||
@ -53,45 +67,45 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
browserName: 'Chrome',
|
browserName: 'Chrome',
|
||||||
|
|
||||||
...buildBStackDesktopOptions('Latest Chrome Desktop', '1280x1024')
|
...buildBStackDesktopOptions({ sessionName: 'Latest Chrome Desktop', resolution: '1280x1024', os: 'Windows', osVersion: '8' })
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
browserName: 'Firefox',
|
browserName: 'Firefox',
|
||||||
browserVersion: '78', // Very old ESR
|
browserVersion: '78', // Very old ESR
|
||||||
|
|
||||||
...buildBStackDesktopOptions('Firefox ESR Desktop', '1280x1024', 'Windows')
|
...buildBStackDesktopOptions({ sessionName: 'Firefox ESR Desktop', resolution: '1280x1024', os: 'Windows', osVersion: '8' })
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
browserName: 'Safari',
|
browserName: 'Safari',
|
||||||
browserVersion: '12.1',
|
browserVersion: '12.1',
|
||||||
|
|
||||||
...buildBStackDesktopOptions('Safari Desktop', '1280x1024')
|
...buildBStackDesktopOptions({ sessionName: 'Safari Desktop', resolution: '1280x1024' })
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
browserName: 'Firefox',
|
browserName: 'Firefox',
|
||||||
|
|
||||||
...buildBStackDesktopOptions('Firefox Latest', '1280x1024')
|
...buildBStackDesktopOptions({ sessionName: 'Firefox Latest', resolution: '1280x1024', os: 'Windows', osVersion: '8' })
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
browserName: 'Edge',
|
browserName: 'Edge',
|
||||||
|
|
||||||
...buildBStackDesktopOptions('Edge Latest', '1280x1024')
|
...buildBStackDesktopOptions({ sessionName: 'Edge Latest', resolution: '1280x1024' })
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
browserName: 'Chrome',
|
browserName: 'Chrome',
|
||||||
|
|
||||||
...buildBStackMobileOptions('Latest Chrome Android', 'Samsung Galaxy S8', '7.0')
|
...buildBStackMobileOptions({ sessionName: 'Latest Chrome Android', deviceName: 'Samsung Galaxy S8', osVersion: '7.0' })
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
browserName: 'Safari',
|
browserName: 'Safari',
|
||||||
|
|
||||||
...buildBStackMobileOptions('Safari iPhone', 'iPhone 8 Plus', '12.4')
|
...buildBStackMobileOptions({ sessionName: 'Safari iPhone', deviceName: 'iPhone 8 Plus', osVersion: '12.4' })
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
browserName: 'Safari',
|
browserName: 'Safari',
|
||||||
|
|
||||||
...buildBStackMobileOptions('Safari iPad', 'iPad 7th', '13')
|
...buildBStackMobileOptions({ sessionName: 'Safari iPad', deviceName: 'iPad 7th', osVersion: '13' })
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
@ -315,7 +315,8 @@ class PeerTubePlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private initCaptions () {
|
private initCaptions () {
|
||||||
debugLogger('Init captions with current subtitle ' + this.currentSubtitle)
|
if (this.currentSubtitle) debugLogger('Init captions with current subtitle ' + this.currentSubtitle)
|
||||||
|
else debugLogger('Init captions without current subtitle')
|
||||||
|
|
||||||
this.player.tech(true).clearTracks('text')
|
this.player.tech(true).clearTracks('text')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user