aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/e2e/src
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-05-12 16:38:55 +0200
committerChocobozzz <me@florianbigard.com>2020-05-12 16:49:35 +0200
commitee68bbc481c154111c60fe80d57565d35bfac46e (patch)
tree64de79b49228feb35af486e2cf755bc7839fe148 /client/e2e/src
parent853c3d533d287d762053e0fa6ecf6bfc3feb0051 (diff)
downloadPeerTube-ee68bbc481c154111c60fe80d57565d35bfac46e.tar.gz
PeerTube-ee68bbc481c154111c60fe80d57565d35bfac46e.tar.zst
PeerTube-ee68bbc481c154111c60fe80d57565d35bfac46e.zip
Unblock ios e2e tests
Diffstat (limited to 'client/e2e/src')
-rw-r--r--client/e2e/src/po/app.po.ts7
-rw-r--r--client/e2e/src/po/video-watch.po.ts21
-rw-r--r--client/e2e/src/utils.ts30
-rw-r--r--client/e2e/src/videos.e2e-spec.ts33
4 files changed, 56 insertions, 35 deletions
diff --git a/client/e2e/src/po/app.po.ts b/client/e2e/src/po/app.po.ts
index a636e825f..4954880ef 100644
--- a/client/e2e/src/po/app.po.ts
+++ b/client/e2e/src/po/app.po.ts
@@ -10,12 +10,5 @@ export class AppPage {
10 await element(by.css('.configure-instance-button')).click() 10 await element(by.css('.configure-instance-button')).click()
11 11
12 await browser.switchTo().window(firstHandle) 12 await browser.switchTo().window(firstHandle)
13
14 await browser.refresh()
15
16 await element(by.css('.form-group-checkbox')).click()
17 await element(by.css('.action-button-cancel')).click()
18
19 await browser.switchTo().window(firstHandle)
20 } 13 }
21} 14}
diff --git a/client/e2e/src/po/video-watch.po.ts b/client/e2e/src/po/video-watch.po.ts
index c5e37e6de..bcfceefbc 100644
--- a/client/e2e/src/po/video-watch.po.ts
+++ b/client/e2e/src/po/video-watch.po.ts
@@ -1,4 +1,5 @@
1import { browser, by, element, ElementFinder, ExpectedConditions } from 'protractor' 1import { browser, by, element, ElementFinder, ExpectedConditions } from 'protractor'
2import { browserSleep } from '../utils'
2 3
3export class VideoWatchPage { 4export class VideoWatchPage {
4 async goOnVideosList (isMobileDevice: boolean, isSafari: boolean) { 5 async goOnVideosList (isMobileDevice: boolean, isSafari: boolean) {
@@ -11,10 +12,10 @@ export class VideoWatchPage {
11 url = '/videos/recently-added' 12 url = '/videos/recently-added'
12 } 13 }
13 14
14 await browser.get(url) 15 await browser.get(url, 20000)
15 16
16 // Waiting the following element does not work on Safari... 17 // Waiting the following element does not work on Safari...
17 if (isSafari) return browser.sleep(3000) 18 if (isSafari) return browserSleep(3000)
18 19
19 const elem = element.all(by.css('.videos .video-miniature .video-miniature-name')).first() 20 const elem = element.all(by.css('.videos .video-miniature .video-miniature-name')).first()
20 return browser.wait(browser.ExpectedConditions.visibilityOf(elem)) 21 return browser.wait(browser.ExpectedConditions.visibilityOf(elem))
@@ -27,13 +28,12 @@ export class VideoWatchPage {
27 } 28 }
28 29
29 waitWatchVideoName (videoName: string, isMobileDevice: boolean, isSafari: boolean) { 30 waitWatchVideoName (videoName: string, isMobileDevice: boolean, isSafari: boolean) {
31 if (isSafari) return browserSleep(5000)
32
30 // On mobile we display the first node, on desktop the second 33 // On mobile we display the first node, on desktop the second
31 const index = isMobileDevice ? 0 : 1 34 const index = isMobileDevice ? 0 : 1
32 35
33 const elem = element.all(by.css('.video-info .video-info-name')).get(index) 36 const elem = element.all(by.css('.video-info .video-info-name')).get(index)
34
35 if (isSafari) return browser.sleep(5000)
36
37 return browser.wait(browser.ExpectedConditions.textToBePresentInElement(elem, videoName)) 37 return browser.wait(browser.ExpectedConditions.textToBePresentInElement(elem, videoName))
38 } 38 }
39 39
@@ -55,7 +55,7 @@ export class VideoWatchPage {
55 await playButton.click() 55 await playButton.click()
56 } 56 }
57 57
58 await browser.sleep(1000) 58 await browserSleep(1000)
59 await browser.wait(browser.ExpectedConditions.invisibilityOf(element(by.css('.vjs-loading-spinner')))) 59 await browser.wait(browser.ExpectedConditions.invisibilityOf(element(by.css('.vjs-loading-spinner'))))
60 60
61 const videojsEl = element(by.css('div.video-js')) 61 const videojsEl = element(by.css('div.video-js'))
@@ -63,13 +63,16 @@ export class VideoWatchPage {
63 63
64 // On Android, we need to click twice on "play" (BrowserStack particularity) 64 // On Android, we need to click twice on "play" (BrowserStack particularity)
65 if (isMobileDevice) { 65 if (isMobileDevice) {
66 await browser.sleep(3000) 66 await browserSleep(3000)
67
67 await videojsEl.click() 68 await videojsEl.click()
68 } 69 }
69 70
70 await browser.sleep(7000) 71 browser.ignoreSynchronization = false
72 await browserSleep(7000)
73 browser.ignoreSynchronization = true
71 74
72 return videojsEl.click() 75 await videojsEl.click()
73 } 76 }
74 77
75 async clickOnVideo (videoName: string) { 78 async clickOnVideo (videoName: string) {
diff --git a/client/e2e/src/utils.ts b/client/e2e/src/utils.ts
new file mode 100644
index 000000000..e19da6402
--- /dev/null
+++ b/client/e2e/src/utils.ts
@@ -0,0 +1,30 @@
1import { browser } from 'protractor'
2
3async function browserSleep (amount: number) {
4 if (await isIOS()) browser.ignoreSynchronization = false
5
6 await browser.sleep(amount)
7
8 if (await isIOS()) browser.ignoreSynchronization = true
9}
10
11async function isMobileDevice () {
12 const caps = await browser.getCapabilities()
13 return caps.get('realMobile') === 'true' || caps.get('realMobile') === true
14}
15
16async function isSafari () {
17 const caps = await browser.getCapabilities()
18 return caps.get('browserName') && caps.get('browserName').toLowerCase() === 'safari'
19}
20
21async function isIOS () {
22 return await isMobileDevice() && await isSafari()
23}
24
25export {
26 isMobileDevice,
27 isSafari,
28 isIOS,
29 browserSleep
30}
diff --git a/client/e2e/src/videos.e2e-spec.ts b/client/e2e/src/videos.e2e-spec.ts
index b2c5ab4c6..0cba8331f 100644
--- a/client/e2e/src/videos.e2e-spec.ts
+++ b/client/e2e/src/videos.e2e-spec.ts
@@ -1,10 +1,11 @@
1import { VideoWatchPage } from './po/video-watch.po'
2import { VideoUploadPage } from './po/video-upload.po'
3import { LoginPage } from './po/login.po'
4import { browser } from 'protractor' 1import { browser } from 'protractor'
5import { VideoUpdatePage } from './po/video-update.po'
6import { MyAccountPage } from './po/my-account'
7import { AppPage } from './po/app.po' 2import { AppPage } from './po/app.po'
3import { LoginPage } from './po/login.po'
4import { MyAccountPage } from './po/my-account'
5import { VideoUpdatePage } from './po/video-update.po'
6import { VideoUploadPage } from './po/video-upload.po'
7import { VideoWatchPage } from './po/video-watch.po'
8import { isIOS, isMobileDevice, isSafari } from './utils'
8 9
9async function skipIfUploadNotSupported () { 10async function skipIfUploadNotSupported () {
10 if (await isMobileDevice() || await isSafari()) { 11 if (await isMobileDevice() || await isSafari()) {
@@ -15,16 +16,6 @@ async function skipIfUploadNotSupported () {
15 return false 16 return false
16} 17}
17 18
18async function isMobileDevice () {
19 const caps = await browser.getCapabilities()
20 return caps.get('realMobile') === 'true' || caps.get('realMobile') === true
21}
22
23async function isSafari () {
24 const caps = await browser.getCapabilities()
25 return caps.get('browserName') && caps.get('browserName').toLowerCase() === 'safari'
26}
27
28describe('Videos workflow', () => { 19describe('Videos workflow', () => {
29 let videoWatchPage: VideoWatchPage 20 let videoWatchPage: VideoWatchPage
30 let videoUploadPage: VideoUploadPage 21 let videoUploadPage: VideoUploadPage
@@ -46,11 +37,15 @@ describe('Videos workflow', () => {
46 loginPage = new LoginPage() 37 loginPage = new LoginPage()
47 appPage = new AppPage() 38 appPage = new AppPage()
48 39
49 if (await isMobileDevice()) { 40 if (await isIOS()) {
50 console.log('Mobile device detected.') 41 // iOS does not seem to work with protractor
51 } 42 // https://github.com/angular/protractor/issues/2840
43 browser.ignoreSynchronization = true
52 44
53 if (await isSafari()) { 45 console.log('iOS detected')
46 } else if (await isMobileDevice()) {
47 console.log('Android detected.')
48 } else if (await isSafari()) {
54 console.log('Safari detected.') 49 console.log('Safari detected.')
55 } 50 }
56 51