diff options
author | Chocobozzz <me@florianbigard.com> | 2021-08-30 16:24:25 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-09-01 15:06:46 +0200 |
commit | 3419e0e1fe8e48a08b63ca0ded31087f913eb2b6 (patch) | |
tree | 63ac7190b79194e93aec9bbfd3c336e60f469e9d /client/e2e/src/utils.ts | |
parent | 2a4c9669d2d6ac6cd4ae43544698f826ae98080f (diff) | |
download | PeerTube-3419e0e1fe8e48a08b63ca0ded31087f913eb2b6.tar.gz PeerTube-3419e0e1fe8e48a08b63ca0ded31087f913eb2b6.tar.zst PeerTube-3419e0e1fe8e48a08b63ca0ded31087f913eb2b6.zip |
Migrate to webdriverio
Diffstat (limited to 'client/e2e/src/utils.ts')
-rw-r--r-- | client/e2e/src/utils.ts | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/client/e2e/src/utils.ts b/client/e2e/src/utils.ts index a9d30c03a..df1c29238 100644 --- a/client/e2e/src/utils.ts +++ b/client/e2e/src/utils.ts | |||
@@ -1,34 +1,37 @@ | |||
1 | import { browser } from 'protractor' | ||
2 | |||
3 | async function browserSleep (amount: number) { | 1 | async function browserSleep (amount: number) { |
4 | const oldValue = await browser.waitForAngularEnabled() | 2 | await browser.pause(amount) |
5 | 3 | } | |
6 | // iOS does not seem to work with protractor | ||
7 | // https://github.com/angular/protractor/issues/2840 | ||
8 | if (await isIOS()) browser.waitForAngularEnabled(true) | ||
9 | 4 | ||
10 | await browser.sleep(amount) | 5 | function isMobileDevice () { |
6 | const platformName = (browser.capabilities['platformName'] || '').toLowerCase() | ||
11 | 7 | ||
12 | if (await isIOS()) browser.waitForAngularEnabled(oldValue) | 8 | return platformName === 'android' || platformName === 'ios' |
13 | } | 9 | } |
14 | 10 | ||
15 | async function isMobileDevice () { | 11 | function isSafari () { |
16 | const caps = await browser.getCapabilities() | 12 | return browser.capabilities['browserName'] && |
17 | return caps.get('realMobile') === 'true' || caps.get('realMobile') === true | 13 | browser.capabilities['browserName'].toLowerCase() === 'safari' |
18 | } | 14 | } |
19 | 15 | ||
20 | async function isSafari () { | 16 | function isIOS () { |
21 | const caps = await browser.getCapabilities() | 17 | return isMobileDevice() && isSafari() |
22 | return caps.get('browserName') && caps.get('browserName').toLowerCase() === 'safari' | ||
23 | } | 18 | } |
24 | 19 | ||
25 | async function isIOS () { | 20 | async function go (url: string) { |
26 | return await isMobileDevice() && await isSafari() | 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 | }) | ||
27 | } | 29 | } |
28 | 30 | ||
29 | export { | 31 | export { |
30 | isMobileDevice, | 32 | isMobileDevice, |
31 | isSafari, | 33 | isSafari, |
32 | isIOS, | 34 | isIOS, |
35 | go, | ||
33 | browserSleep | 36 | browserSleep |
34 | } | 37 | } |