]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/e2e/src/po/video-upload.po.ts
a248912edb55f0b14b7515173e5f14331d617518
[github/Chocobozzz/PeerTube.git] / client / e2e / src / po / video-upload.po.ts
1 import { browser, by, element } from 'protractor'
2 import { FileDetector } from 'selenium-webdriver/remote'
3 import { join } from 'path'
4
5 export class VideoUploadPage {
6 async navigateTo () {
7 await element(by.css('.header .publish-button')).click()
8
9 return browser.wait(browser.ExpectedConditions.visibilityOf(element(by.css('.upload-video-container'))))
10 }
11
12 async uploadVideo () {
13 browser.setFileDetector(new FileDetector())
14
15 const fileToUpload = join(__dirname, '../../fixtures/video.mp4')
16 const fileInputSelector = '.upload-video-container input[type=file]'
17 const parentFileInput = '.upload-video-container .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('${parentFileInput}').style.overflow = 'initial'`)
22
23 await browser.sleep(1000)
24
25 const elem = element(by.css(fileInputSelector))
26 await elem.sendKeys(fileToUpload)
27
28 // Wait for the upload to finish
29 await browser.wait(async () => {
30 const actionButton = this.getSecondStepSubmitButton().element(by.css('.action-button'))
31
32 const klass = await actionButton.getAttribute('class')
33 return !klass.includes('disabled')
34 })
35 }
36
37 async validSecondUploadStep (videoName: string) {
38 const nameInput = element(by.css('input#name'))
39 await nameInput.clear()
40 await nameInput.sendKeys(videoName)
41
42 await this.getSecondStepSubmitButton().click()
43
44 return browser.wait(browser.ExpectedConditions.urlContains('/w/'))
45 }
46
47 private getSecondStepSubmitButton () {
48 return element(by.css('.submit-container my-button'))
49 }
50 }