]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/e2e/src/po/video-upload.po.ts
Migrate to webdriverio
[github/Chocobozzz/PeerTube.git] / client / e2e / src / po / video-upload.po.ts
1 import { join } from 'path'
2
3 export class VideoUploadPage {
4 async navigateTo () {
5 await $('.header .publish-button').click()
6
7 await $('.upload-video-container').waitForDisplayed()
8 }
9
10 async uploadVideo () {
11 const fileToUpload = join(__dirname, '../../fixtures/video.mp4')
12 const fileInputSelector = '.upload-video-container input[type=file]'
13 const parentFileInput = '.upload-video-container .button-file'
14
15 // Avoid sending keys on non visible element
16 await browser.execute(`document.querySelector('${fileInputSelector}').style.opacity = 1`)
17 await browser.execute(`document.querySelector('${parentFileInput}').style.overflow = 'initial'`)
18
19 await browser.pause(1000)
20
21 const elem = await $(fileInputSelector)
22 await elem.chooseFile(fileToUpload)
23
24 // Wait for the upload to finish
25 await browser.waitUntil(async () => {
26 const actionButton = this.getSecondStepSubmitButton().$('.action-button')
27
28 const klass = await actionButton.getAttribute('class')
29 return !klass.includes('disabled')
30 })
31 }
32
33 async validSecondUploadStep (videoName: string) {
34 const nameInput = $('input#name')
35 await nameInput.clearValue()
36 await nameInput.setValue(videoName)
37
38 await this.getSecondStepSubmitButton().click()
39
40 return browser.waitUntil(async () => {
41 return (await browser.getUrl()).includes('/w/')
42 })
43 }
44
45 private getSecondStepSubmitButton () {
46 return $('.submit-container my-button')
47 }
48 }