PeerTube/client/e2e/src/utils/common.ts

48 lines
1.0 KiB
TypeScript
Raw Normal View History

2020-05-12 16:38:55 +02:00
async function browserSleep (amount: number) {
2021-08-30 16:24:25 +02:00
await browser.pause(amount)
}
2020-05-12 16:38:55 +02:00
2021-08-30 16:24:25 +02:00
function isMobileDevice () {
const platformName = (browser.capabilities['platformName'] || '').toLowerCase()
2020-05-12 16:38:55 +02:00
2021-08-30 16:24:25 +02:00
return platformName === 'android' || platformName === 'ios'
2020-05-12 16:38:55 +02:00
}
2021-08-30 16:24:25 +02:00
function isSafari () {
return browser.capabilities['browserName'] &&
browser.capabilities['browserName'].toLowerCase() === 'safari'
2020-05-12 16:38:55 +02:00
}
2021-08-30 16:24:25 +02:00
function isIOS () {
return isMobileDevice() && isSafari()
2020-05-12 16:38:55 +02:00
}
2021-08-30 16:24:25 +02:00
async function go (url: string) {
await browser.url(url)
// Hide notifications that could fail tests when hiding buttons
await browser.execute(() => {
const style = document.createElement('style')
style.innerHTML = 'p-toast { display: none }'
document.head.appendChild(style)
})
2020-05-12 16:38:55 +02:00
}
2021-09-03 10:27:04 +02:00
async function waitServerUp () {
await browser.waitUntil(async () => {
await go('/')
await browserSleep(500)
return $('<my-app>').isDisplayed()
}, { timeout: 20 * 1000 })
}
2021-08-30 16:24:25 +02:00
export {
2020-05-12 16:38:55 +02:00
isMobileDevice,
isSafari,
isIOS,
2021-09-03 10:27:04 +02:00
waitServerUp,
2021-08-30 16:24:25 +02:00
go,
2020-05-12 16:38:55 +02:00
browserSleep
}