]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/e2e/src/po/video-upload.po.ts
Fix local E2E tests
[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 const publishButton = await $('.header .publish-button')
7
8 await publishButton.waitForClickable()
9 await publishButton.click()
10
11 await $('.upload-video-container').waitForDisplayed()
12 }
13
14 async uploadVideo () {
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.execute(`document.querySelector('${fileInputSelector}').style.opacity = 1`)
21 await browser.execute(`document.querySelector('${parentFileInput}').style.overflow = 'initial'`)
22
23 await browser.pause(1000)
24
25 const elem = await $(fileInputSelector)
26 await elem.chooseFile(fileToUpload)
27
28 // Wait for the upload to finish
29 await browser.waitUntil(async () => {
30 const warning = await $('=Publish will be available when upload is finished').isDisplayed()
31 const progress = await $('.progress-bar=100%').isDisplayed()
32
33 return !warning && progress
34 })
35 }
36
37 async setAsNSFW () {
38 const checkbox = await getCheckbox('nsfw')
39
40 return checkbox.click()
41 }
42
43 async validSecondUploadStep (videoName: string) {
44 const nameInput = $('input#name')
45 await nameInput.clearValue()
46 await nameInput.setValue(videoName)
47
48 await this.getSecondStepSubmitButton().click()
49
50 return browser.waitUntil(async () => {
51 return (await browser.getUrl()).includes('/w/')
52 })
53 }
54
55 setAsPublic () {
56 return selectCustomSelect('privacy', 'Public')
57 }
58
59 setAsPrivate () {
60 return selectCustomSelect('privacy', 'Private')
61 }
62
63 private getSecondStepSubmitButton () {
64 return $('.submit-container my-button')
65 }
66 }