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