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 {
|
||||
|
||||
|
@ -23,9 +23,17 @@ export class LoginPage {
|
|||
await $('input#username').setValue(username)
|
||||
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) {
|
||||
const menuToggle = $('.top-left-block span[role=button]')
|
||||
|
|
|
@ -29,29 +29,32 @@ export class PlayerPage {
|
|||
}
|
||||
|
||||
async playAndPauseVideo (isAutoplay: boolean, waitUntilSec: number) {
|
||||
const videojsElem = () => $('div.video-js')
|
||||
|
||||
await videojsElem().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`)
|
||||
await this.clickOnPlayButton()
|
||||
} else if (isAutoplay === false) {
|
||||
await this.clickOnPlayButton()
|
||||
// Autoplay is disabled on mobile and Safari
|
||||
if (isIOS() || isSafari() || isMobileDevice() || isAutoplay === false) {
|
||||
await this.playVideo()
|
||||
}
|
||||
|
||||
await $('div.video-js.vjs-has-started').waitForExist()
|
||||
|
||||
await browserSleep(2000)
|
||||
|
||||
await browser.waitUntil(async () => {
|
||||
return (await this.getWatchVideoPlayerCurrentTime()) >= waitUntilSec
|
||||
})
|
||||
|
||||
await videojsElem().click()
|
||||
// Pause video
|
||||
await $('div.video-js').click()
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,12 @@ function isMobileDevice () {
|
|||
return platformName === 'android' || platformName === 'ios'
|
||||
}
|
||||
|
||||
function isAndroid () {
|
||||
const platformName = (browser.capabilities['platformName'] || '').toLowerCase()
|
||||
|
||||
return platformName === 'android'
|
||||
}
|
||||
|
||||
function isSafari () {
|
||||
return browser.capabilities['browserName'] &&
|
||||
browser.capabilities['browserName'].toLowerCase() === 'safari'
|
||||
|
@ -41,6 +47,7 @@ export {
|
|||
isMobileDevice,
|
||||
isSafari,
|
||||
isIOS,
|
||||
isAndroid,
|
||||
waitServerUp,
|
||||
go,
|
||||
browserSleep
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
"esModuleInterop": true,
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"typeRoots": [
|
||||
"../node_modules/@types",
|
||||
"../node_modules"
|
||||
],
|
||||
"types": [
|
||||
"node",
|
||||
"@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 {
|
||||
'bstack:options': {
|
||||
...buildMainOptions(sessionName),
|
||||
|
||||
os,
|
||||
osVersion,
|
||||
resolution
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function buildBStackMobileOptions (sessionName: string, deviceName: string, osVersion: string) {
|
||||
function buildBStackMobileOptions (options: {
|
||||
sessionName: string
|
||||
deviceName: string
|
||||
osVersion: string
|
||||
}) {
|
||||
const { sessionName, deviceName, osVersion } = options
|
||||
|
||||
return {
|
||||
'bstack:options': {
|
||||
...buildMainOptions(sessionName),
|
||||
|
@ -53,45 +67,45 @@ module.exports = {
|
|||
{
|
||||
browserName: 'Chrome',
|
||||
|
||||
...buildBStackDesktopOptions('Latest Chrome Desktop', '1280x1024')
|
||||
...buildBStackDesktopOptions({ sessionName: 'Latest Chrome Desktop', resolution: '1280x1024', os: 'Windows', osVersion: '8' })
|
||||
},
|
||||
{
|
||||
browserName: 'Firefox',
|
||||
browserVersion: '78', // Very old ESR
|
||||
|
||||
...buildBStackDesktopOptions('Firefox ESR Desktop', '1280x1024', 'Windows')
|
||||
...buildBStackDesktopOptions({ sessionName: 'Firefox ESR Desktop', resolution: '1280x1024', os: 'Windows', osVersion: '8' })
|
||||
},
|
||||
{
|
||||
browserName: 'Safari',
|
||||
browserVersion: '12.1',
|
||||
|
||||
...buildBStackDesktopOptions('Safari Desktop', '1280x1024')
|
||||
...buildBStackDesktopOptions({ sessionName: 'Safari Desktop', resolution: '1280x1024' })
|
||||
},
|
||||
{
|
||||
browserName: 'Firefox',
|
||||
|
||||
...buildBStackDesktopOptions('Firefox Latest', '1280x1024')
|
||||
...buildBStackDesktopOptions({ sessionName: 'Firefox Latest', resolution: '1280x1024', os: 'Windows', osVersion: '8' })
|
||||
},
|
||||
{
|
||||
browserName: 'Edge',
|
||||
|
||||
...buildBStackDesktopOptions('Edge Latest', '1280x1024')
|
||||
...buildBStackDesktopOptions({ sessionName: 'Edge Latest', resolution: '1280x1024' })
|
||||
},
|
||||
|
||||
{
|
||||
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',
|
||||
|
||||
...buildBStackMobileOptions('Safari iPhone', 'iPhone 8 Plus', '12.4')
|
||||
...buildBStackMobileOptions({ sessionName: 'Safari iPhone', deviceName: 'iPhone 8 Plus', osVersion: '12.4' })
|
||||
},
|
||||
{
|
||||
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 () {
|
||||
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')
|
||||
|
||||
|
|
Loading…
Reference in New Issue