aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/e2e/src/po/video-upload.po.ts
blob: 7e79897637a43c99776650de6e9fe54fc151caa7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { join } from 'path'
import { getCheckbox, selectCustomSelect } from '../utils'

export class VideoUploadPage {
  async navigateTo () {
    const publishButton = await $('.root-header .publish-button')

    await publishButton.waitForClickable()
    await publishButton.click()

    await $('.upload-video-container').waitForDisplayed()
  }

  async uploadVideo (fixtureName: 'video.mp4' | 'video2.mp4' | 'video3.mp4') {
    const fileToUpload = join(__dirname, '../../fixtures/' + fixtureName)
    const fileInputSelector = '.upload-video-container input[type=file]'
    const parentFileInput = '.upload-video-container .button-file'

    // Avoid sending keys on non visible element
    await browser.execute(`document.querySelector('${fileInputSelector}').style.opacity = 1`)
    await browser.execute(`document.querySelector('${parentFileInput}').style.overflow = 'initial'`)

    await browser.pause(1000)

    const elem = await $(fileInputSelector)
    await elem.chooseFile(fileToUpload)

    // Wait for the upload to finish
    await browser.waitUntil(async () => {
      const warning = await $('=Publish will be available when upload is finished').isDisplayed()
      const progress = await $('.progress-bar=100%').isDisplayed()

      return !warning && progress
    })
  }

  async setAsNSFW () {
    const checkbox = await getCheckbox('nsfw')
    await checkbox.waitForClickable()

    return checkbox.click()
  }

  async validSecondUploadStep (videoName: string) {
    const nameInput = $('input#name')
    await nameInput.clearValue()
    await nameInput.setValue(videoName)

    const button = this.getSecondStepSubmitButton()
    await button.waitForClickable()

    await button.click()

    return browser.waitUntil(async () => {
      return (await browser.getUrl()).includes('/w/')
    })
  }

  setAsPublic () {
    return selectCustomSelect('privacy', 'Public')
  }

  setAsPrivate () {
    return selectCustomSelect('privacy', 'Private')
  }

  private getSecondStepSubmitButton () {
    return $('.submit-container my-button')
  }
}