1 import { join } from 'path'
2 import { getCheckbox, selectCustomSelect } from '../utils'
4 export class VideoUploadPage {
6 const publishButton = await $('.root-header .publish-button')
8 await publishButton.waitForClickable()
9 await publishButton.click()
11 await $('.upload-video-container').waitForDisplayed()
14 async uploadVideo (fixtureName: 'video.mp4' | 'video2.mp4' | 'video3.mp4') {
15 const fileToUpload = join(__dirname, '../../fixtures/' + fixtureName)
16 const fileInputSelector = '.upload-video-container input[type=file]'
17 const parentFileInput = '.upload-video-container .button-file'
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'`)
23 await browser.pause(1000)
25 const elem = await $(fileInputSelector)
26 await elem.chooseFile(fileToUpload)
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()
33 return !warning && progress
38 const checkbox = await getCheckbox('nsfw')
39 await checkbox.waitForClickable()
41 return checkbox.click()
44 async validSecondUploadStep (videoName: string) {
45 const nameInput = $('input#name')
46 await nameInput.clearValue()
47 await nameInput.setValue(videoName)
49 const button = this.getSecondStepSubmitButton()
50 await button.waitForClickable()
54 return browser.waitUntil(async () => {
55 return (await browser.getUrl()).includes('/w/')
60 return selectCustomSelect('privacy', 'Public')
64 return selectCustomSelect('privacy', 'Private')
67 private getSecondStepSubmitButton () {
68 return $('.submit-container my-button')