PeerTube/client/e2e/src/po/video-upload.po.ts

54 lines
1.5 KiB
TypeScript
Raw Normal View History

2018-05-19 13:58:29 +02:00
import { join } from 'path'
2021-09-03 10:27:04 +02:00
import { clickOnCheckbox } from '../utils'
2018-05-17 10:55:01 +02:00
export class VideoUploadPage {
2018-05-22 16:02:29 +02:00
async navigateTo () {
2021-08-30 16:24:25 +02:00
await $('.header .publish-button').click()
2018-05-22 16:02:29 +02:00
2021-08-30 16:24:25 +02:00
await $('.upload-video-container').waitForDisplayed()
2018-05-17 10:55:01 +02:00
}
async uploadVideo () {
const fileToUpload = join(__dirname, '../../fixtures/video.mp4')
2018-05-22 16:02:29 +02:00
const fileInputSelector = '.upload-video-container input[type=file]'
2019-02-21 11:24:07 +01:00
const parentFileInput = '.upload-video-container .button-file'
2018-05-22 16:02:29 +02:00
// Avoid sending keys on non visible element
2021-08-30 16:24:25 +02:00
await browser.execute(`document.querySelector('${fileInputSelector}').style.opacity = 1`)
await browser.execute(`document.querySelector('${parentFileInput}').style.overflow = 'initial'`)
2018-05-17 10:55:01 +02:00
2021-08-30 16:24:25 +02:00
await browser.pause(1000)
2019-02-21 11:24:07 +01:00
2021-08-30 16:24:25 +02:00
const elem = await $(fileInputSelector)
await elem.chooseFile(fileToUpload)
2018-05-17 10:55:01 +02:00
// Wait for the upload to finish
2021-08-30 16:24:25 +02:00
await browser.waitUntil(async () => {
const actionButton = this.getSecondStepSubmitButton().$('.action-button')
2021-05-10 13:56:26 +02:00
const klass = await actionButton.getAttribute('class')
return !klass.includes('disabled')
})
2018-05-17 10:55:01 +02:00
}
2021-09-03 10:27:04 +02:00
setAsNSFW () {
return clickOnCheckbox('nsfw')
}
2018-05-17 10:55:01 +02:00
async validSecondUploadStep (videoName: string) {
2021-08-30 16:24:25 +02:00
const nameInput = $('input#name')
await nameInput.clearValue()
await nameInput.setValue(videoName)
2018-05-17 10:55:01 +02:00
await this.getSecondStepSubmitButton().click()
2021-08-30 16:24:25 +02:00
return browser.waitUntil(async () => {
return (await browser.getUrl()).includes('/w/')
})
2018-05-17 10:55:01 +02:00
}
private getSecondStepSubmitButton () {
2021-08-30 16:24:25 +02:00
return $('.submit-container my-button')
2018-05-17 10:55:01 +02:00
}
}