]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/e2e/src/utils/common.ts
Merge branch 'release/4.2.0' into develop
[github/Chocobozzz/PeerTube.git] / client / e2e / src / utils / common.ts
CommitLineData
ee68bbc4 1async function browserSleep (amount: number) {
3419e0e1
C
2 await browser.pause(amount)
3}
ee68bbc4 4
3419e0e1
C
5function isMobileDevice () {
6 const platformName = (browser.capabilities['platformName'] || '').toLowerCase()
ee68bbc4 7
3419e0e1 8 return platformName === 'android' || platformName === 'ios'
ee68bbc4
C
9}
10
3419e0e1
C
11function isSafari () {
12 return browser.capabilities['browserName'] &&
13 browser.capabilities['browserName'].toLowerCase() === 'safari'
ee68bbc4
C
14}
15
3419e0e1
C
16function isIOS () {
17 return isMobileDevice() && isSafari()
ee68bbc4
C
18}
19
3419e0e1
C
20async function go (url: string) {
21 await browser.url(url)
22
23 // Hide notifications that could fail tests when hiding buttons
24 await browser.execute(() => {
25 const style = document.createElement('style')
26 style.innerHTML = 'p-toast { display: none }'
27 document.head.appendChild(style)
28 })
ee68bbc4
C
29}
30
6d210220
C
31async function waitServerUp () {
32 await browser.waitUntil(async () => {
33 await go('/')
34 await browserSleep(500)
35
36 return $('<my-app>').isDisplayed()
37 }, { timeout: 20 * 1000 })
38}
39
3419e0e1 40export {
ee68bbc4
C
41 isMobileDevice,
42 isSafari,
43 isIOS,
6d210220 44 waitServerUp,
3419e0e1 45 go,
ee68bbc4
C
46 browserSleep
47}