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 {
|
|
|
|
navigateTo () {
|
|
|
|
return browser.get('/videos/upload')
|
|
|
|
}
|
|
|
|
|
|
|
|
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')
|
|
|
|
|
|
|
|
await element(by.css('.upload-video-container input[type=file]')).sendKeys(fileToUpload)
|
|
|
|
|
|
|
|
// 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 () {
|
|
|
|
return element(by.css('.submit-button:not(.disabled) input'))
|
|
|
|
}
|
|
|
|
}
|