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