aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/e2e/src/po/video-upload.po.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/e2e/src/po/video-upload.po.ts')
-rw-r--r--client/e2e/src/po/video-upload.po.ts34
1 files changed, 16 insertions, 18 deletions
diff --git a/client/e2e/src/po/video-upload.po.ts b/client/e2e/src/po/video-upload.po.ts
index a248912ed..34f916b55 100644
--- a/client/e2e/src/po/video-upload.po.ts
+++ b/client/e2e/src/po/video-upload.po.ts
@@ -1,33 +1,29 @@
1import { browser, by, element } from 'protractor'
2import { FileDetector } from 'selenium-webdriver/remote'
3import { join } from 'path' 1import { join } from 'path'
4 2
5export class VideoUploadPage { 3export class VideoUploadPage {
6 async navigateTo () { 4 async navigateTo () {
7 await element(by.css('.header .publish-button')).click() 5 await $('.header .publish-button').click()
8 6
9 return browser.wait(browser.ExpectedConditions.visibilityOf(element(by.css('.upload-video-container')))) 7 await $('.upload-video-container').waitForDisplayed()
10 } 8 }
11 9
12 async uploadVideo () { 10 async uploadVideo () {
13 browser.setFileDetector(new FileDetector())
14
15 const fileToUpload = join(__dirname, '../../fixtures/video.mp4') 11 const fileToUpload = join(__dirname, '../../fixtures/video.mp4')
16 const fileInputSelector = '.upload-video-container input[type=file]' 12 const fileInputSelector = '.upload-video-container input[type=file]'
17 const parentFileInput = '.upload-video-container .button-file' 13 const parentFileInput = '.upload-video-container .button-file'
18 14
19 // Avoid sending keys on non visible element 15 // Avoid sending keys on non visible element
20 await browser.executeScript(`document.querySelector('${fileInputSelector}').style.opacity = 1`) 16 await browser.execute(`document.querySelector('${fileInputSelector}').style.opacity = 1`)
21 await browser.executeScript(`document.querySelector('${parentFileInput}').style.overflow = 'initial'`) 17 await browser.execute(`document.querySelector('${parentFileInput}').style.overflow = 'initial'`)
22 18
23 await browser.sleep(1000) 19 await browser.pause(1000)
24 20
25 const elem = element(by.css(fileInputSelector)) 21 const elem = await $(fileInputSelector)
26 await elem.sendKeys(fileToUpload) 22 await elem.chooseFile(fileToUpload)
27 23
28 // Wait for the upload to finish 24 // Wait for the upload to finish
29 await browser.wait(async () => { 25 await browser.waitUntil(async () => {
30 const actionButton = this.getSecondStepSubmitButton().element(by.css('.action-button')) 26 const actionButton = this.getSecondStepSubmitButton().$('.action-button')
31 27
32 const klass = await actionButton.getAttribute('class') 28 const klass = await actionButton.getAttribute('class')
33 return !klass.includes('disabled') 29 return !klass.includes('disabled')
@@ -35,16 +31,18 @@ export class VideoUploadPage {
35 } 31 }
36 32
37 async validSecondUploadStep (videoName: string) { 33 async validSecondUploadStep (videoName: string) {
38 const nameInput = element(by.css('input#name')) 34 const nameInput = $('input#name')
39 await nameInput.clear() 35 await nameInput.clearValue()
40 await nameInput.sendKeys(videoName) 36 await nameInput.setValue(videoName)
41 37
42 await this.getSecondStepSubmitButton().click() 38 await this.getSecondStepSubmitButton().click()
43 39
44 return browser.wait(browser.ExpectedConditions.urlContains('/w/')) 40 return browser.waitUntil(async () => {
41 return (await browser.getUrl()).includes('/w/')
42 })
45 } 43 }
46 44
47 private getSecondStepSubmitButton () { 45 private getSecondStepSubmitButton () {
48 return element(by.css('.submit-container my-button')) 46 return $('.submit-container my-button')
49 } 47 }
50} 48}