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

46 lines
1.6 KiB
TypeScript
Raw Normal View History

2018-05-19 13:58:29 +02:00
import { browser, by, element } from 'protractor'
2018-05-17 16:33:20 +02:00
import { FileDetector } from 'selenium-webdriver/remote'
2018-05-19 13:58:29 +02:00
import { join } from 'path'
2018-05-17 10:55:01 +02:00
export class VideoUploadPage {
2018-05-22 16:02:29 +02:00
async navigateTo () {
2020-11-30 09:11:12 +01:00
await element(by.css('.header .publish-button')).click()
2018-05-22 16:02:29 +02:00
return browser.wait(browser.ExpectedConditions.visibilityOf(element(by.css('.upload-video-container'))))
2018-05-17 10:55:01 +02:00
}
async uploadVideo () {
2018-05-17 16:33:20 +02:00
browser.setFileDetector(new FileDetector())
2018-05-17 10:55:01 +02:00
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
await browser.executeScript(`document.querySelector('${fileInputSelector}').style.opacity = 1`)
await browser.executeScript(`document.querySelector('${parentFileInput}').style.overflow = 'initial'`)
2018-05-17 10:55:01 +02:00
2019-02-21 11:24:07 +01:00
await browser.sleep(1000)
2018-05-22 16:02:29 +02:00
const elem = element(by.css(fileInputSelector))
await elem.sendKeys(fileToUpload)
2018-05-17 10:55:01 +02:00
// Wait for the upload to finish
await browser.wait(browser.ExpectedConditions.elementToBeClickable(this.getSecondStepSubmitButton()))
}
async validSecondUploadStep (videoName: string) {
const nameInput = element(by.css('input#name'))
await nameInput.clear()
await nameInput.sendKeys(videoName)
await this.getSecondStepSubmitButton().click()
return browser.wait(browser.ExpectedConditions.urlContains('/watch/'))
}
private getSecondStepSubmitButton () {
2021-01-19 11:43:35 +01:00
return element(by.css('.submit-container my-button'))
2018-05-17 10:55:01 +02:00
}
}