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