aboutsummaryrefslogblamecommitdiffhomepage
path: root/client/e2e/src/po/video-upload.po.ts
blob: 741914d2deaab06e634cdc82fa42587f24c88ae7 (plain) (tree)
1
2
3
4
5
6
7
8
9
10

                                                 
                                                        






                                        

                                               





















                                                                                                         
import { browser, element, by } from 'protractor'
import { join } from 'path'
import { FileDetector } from 'selenium-webdriver/remote'

export class VideoUploadPage {
  navigateTo () {
    return browser.get('/videos/upload')
  }

  async uploadVideo () {
    browser.setFileDetector(new FileDetector())

    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'))
  }
}