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