aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/e2e/src/po/video-watch.po.ts
blob: 266c9850c4e9f2676f40305aff86365be904f836 (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
import { by, element, browser } from 'protractor'

export class VideoWatchPage {
  async goOnRecentlyAdded () {
    const url = '/videos/recently-added'

    await browser.get(url)
    return browser.wait(browser.ExpectedConditions.elementToBeClickable(element(this.getFirstVideoListSelector())))
  }

  getVideosListName () {
    return element.all(this.getFirstVideoListSelector()).getText()
  }

  waitWatchVideoName (videoName: string) {
    const elem = element(by.css('.video-info .video-info-name'))
    return browser.wait(browser.ExpectedConditions.textToBePresentInElement(elem, videoName))
  }

  getWatchVideoPlayerCurrentTime () {
    return element(by.css('.video-js .vjs-current-time-display'))
      .getText()
      .then((t: string) => t.split(':')[1])
      .then(seconds => parseInt(seconds, 10))
  }

  async pauseVideo () {
    const el = element(by.css('video'))
    await browser.wait(browser.ExpectedConditions.elementToBeClickable(el))

    return el.click()
  }

  async clickOnFirstVideoOfList () {
    const video = element(by.css('.videos .video-miniature:first-child .video-thumbnail'))

    await video.click()

    await browser.wait(browser.ExpectedConditions.urlContains('/watch/'))
  }

  private getFirstVideoListSelector () {
    return by.css('.videos .video-miniature-name')
  }
}