]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/e2e/src/po/video-watch.po.ts
Fix videos language tests
[github/Chocobozzz/PeerTube.git] / client / e2e / src / po / video-watch.po.ts
CommitLineData
6d210220 1import { browserSleep, FIXTURE_URLS, go } from '../utils'
5f92c4dc
C
2
3export class VideoWatchPage {
5f92c4dc 4
6d210220 5 constructor (private isMobileDevice: boolean, private isSafari: boolean) {
3419e0e1 6
5f92c4dc
C
7 }
8
6d210220
C
9 waitWatchVideoName (videoName: string) {
10 if (this.isSafari) return browserSleep(5000)
ee68bbc4 11
6247b205 12 // On mobile we display the first node, on desktop the second
6d210220 13 const index = this.isMobileDevice ? 0 : 1
6247b205 14
3419e0e1
C
15 return browser.waitUntil(async () => {
16 return (await $$('.video-info .video-info-name')[index].getText()).includes(videoName)
17 })
5f92c4dc
C
18 }
19
e69cb173 20 getVideoName () {
3419e0e1 21 return this.getVideoNameElement().then(e => e.getText())
e69cb173
C
22 }
23
3cf68b86
C
24 getPrivacy () {
25 return $('.attribute-privacy .attribute-value').getText()
26 }
27
28 getLicence () {
29 return $('.attribute-licence .attribute-value').getText()
30 }
31
32 async isDownloadEnabled () {
33 await this.clickOnMoreDropdownIcon()
34
35 return $('.dropdown-item .icon-download').isExisting()
36 }
37
38 areCommentsEnabled () {
39 return $('my-video-comment-add').isExisting()
40 }
41
7f90579c 42 async goOnAssociatedEmbed () {
3419e0e1 43 let url = await browser.getUrl()
18305950 44 url = url.replace('/w/', '/videos/embed/')
7f90579c 45 url = url.replace(':3333', ':9001')
ee68bbc4 46
3419e0e1 47 return go(url)
7f90579c 48 }
91d95589 49
3419e0e1 50 goOnP2PMediaLoaderEmbed () {
12d6b873 51 return go(FIXTURE_URLS.HLS_EMBED)
7f90579c 52 }
cd4d7a2c 53
3419e0e1 54 goOnP2PMediaLoaderPlaylistEmbed () {
12d6b873 55 return go(FIXTURE_URLS.HLS_PLAYLIST_EMBED)
5f92c4dc
C
56 }
57
e69cb173 58 async clickOnUpdate () {
3cf68b86 59 await this.clickOnMoreDropdownIcon()
e69cb173 60
3419e0e1 61 const items = await $$('.dropdown-menu.show .dropdown-item')
e69cb173
C
62
63 for (const item of items) {
64 const href = await item.getAttribute('href')
65
3419e0e1 66 if (href?.includes('/update/')) {
e69cb173
C
67 await item.click()
68 return
69 }
70 }
71 }
72
3419e0e1
C
73 clickOnSave () {
74 return $('.action-button-save').click()
e69cb173
C
75 }
76
bbe078ba 77 async createPlaylist (name: string) {
3419e0e1
C
78 const newPlaylistButton = () => $('.new-playlist-button')
79
80 await newPlaylistButton().waitForClickable()
81 await newPlaylistButton().click()
82
83 const displayName = () => $('#displayName')
bbe078ba 84
3419e0e1
C
85 await displayName().waitForDisplayed()
86 await displayName().setValue(name)
bbe078ba 87
3419e0e1 88 return $('.new-playlist-block input[type=submit]').click()
bbe078ba
C
89 }
90
91 async saveToPlaylist (name: string) {
3419e0e1
C
92 const playlist = () => $('my-video-add-to-playlist').$(`.playlist=${name}`)
93
94 await playlist().waitForDisplayed()
95
96 return playlist().click()
e69cb173
C
97 }
98
99 waitUntilVideoName (name: string, maxTime: number) {
3419e0e1
C
100 return browser.waitUntil(async () => {
101 return (await this.getVideoName()) === name
102 }, { timeout: maxTime })
e69cb173
C
103 }
104
3cf68b86
C
105 async clickOnMoreDropdownIcon () {
106 const dropdown = $('my-video-actions-dropdown .action-button')
107 await dropdown.click()
108
109 await $('.dropdown-menu.show .dropdown-item').waitForDisplayed()
110 }
111
3419e0e1 112 private async getVideoNameElement () {
e69cb173 113 // We have 2 video info name block, pick the first that is not empty
3419e0e1
C
114 const elem = async () => {
115 const elems = await $$('.video-info-first-row .video-info-name').filter(e => e.isDisplayed())
116
117 return elems[0]
118 }
119
120 await browser.waitUntil(async () => {
121 const e = await elem()
122
123 return e?.isDisplayed()
124 })
125
126 return elem()
e69cb173 127 }
5f92c4dc 128}