]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/e2e/src/po/video-upload.po.ts
Make it works with new autoplay policy
[github/Chocobozzz/PeerTube.git] / client / e2e / src / po / video-upload.po.ts
CommitLineData
0b33c520 1import { browser, by, element } from 'protractor'
2e8e97f3 2import { FileDetector } from 'selenium-webdriver/remote'
0b33c520 3import { join } from 'path'
5f92c4dc
C
4
5export class VideoUploadPage {
d1bd87e0
C
6 async navigateTo () {
7 await element(by.css('.header .upload-button')).click()
8
9 return browser.wait(browser.ExpectedConditions.visibilityOf(element(by.css('.upload-video-container'))))
5f92c4dc
C
10 }
11
12 async uploadVideo () {
2e8e97f3
C
13 browser.setFileDetector(new FileDetector())
14
5f92c4dc 15 const fileToUpload = join(__dirname, '../../fixtures/video.mp4')
d1bd87e0
C
16 const fileInputSelector = '.upload-video-container input[type=file]'
17 const parentFileInput = '.upload-video .button-file'
18
19 // Avoid sending keys on non visible element
20 await browser.executeScript(`document.querySelector('${fileInputSelector}').style.opacity = 1`)
21 // await browser.executeScript(`document.querySelector('${fileInputSelector}').style.opacity = 1`)
22 await browser.executeScript(`document.querySelector('${parentFileInput}').style.overflow = 'initial'`)
5f92c4dc 23
d1bd87e0
C
24 const elem = element(by.css(fileInputSelector))
25 await elem.sendKeys(fileToUpload)
5f92c4dc
C
26
27 // Wait for the upload to finish
28 await browser.wait(browser.ExpectedConditions.elementToBeClickable(this.getSecondStepSubmitButton()))
29 }
30
31 async validSecondUploadStep (videoName: string) {
32 const nameInput = element(by.css('input#name'))
33 await nameInput.clear()
34 await nameInput.sendKeys(videoName)
35
36 await this.getSecondStepSubmitButton().click()
37
38 return browser.wait(browser.ExpectedConditions.urlContains('/watch/'))
39 }
40
41 private getSecondStepSubmitButton () {
42 return element(by.css('.submit-button:not(.disabled) input'))
43 }
44}