]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/e2e/src/po/video-watch.po.ts
Ability for admins to set default upload values
[github/Chocobozzz/PeerTube.git] / client / e2e / src / po / video-watch.po.ts
1 import { browserSleep, FIXTURE_URLS, go } from '../utils'
2
3 export class VideoWatchPage {
4
5 constructor (private isMobileDevice: boolean, private isSafari: boolean) {
6
7 }
8
9 waitWatchVideoName (videoName: string) {
10 if (this.isSafari) return browserSleep(5000)
11
12 // On mobile we display the first node, on desktop the second
13 const index = this.isMobileDevice ? 0 : 1
14
15 return browser.waitUntil(async () => {
16 return (await $$('.video-info .video-info-name')[index].getText()).includes(videoName)
17 })
18 }
19
20 getVideoName () {
21 return this.getVideoNameElement().then(e => e.getText())
22 }
23
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
42 async goOnAssociatedEmbed () {
43 let url = await browser.getUrl()
44 url = url.replace('/w/', '/videos/embed/')
45 url = url.replace(':3333', ':9001')
46
47 return go(url)
48 }
49
50 goOnP2PMediaLoaderEmbed () {
51 return go(FIXTURE_URLS.HLS_EMBED)
52 }
53
54 goOnP2PMediaLoaderPlaylistEmbed () {
55 return go(FIXTURE_URLS.HLS_PLAYLIST_EMBED)
56 }
57
58 async clickOnUpdate () {
59 await this.clickOnMoreDropdownIcon()
60
61 const items = await $$('.dropdown-menu.show .dropdown-item')
62
63 for (const item of items) {
64 const href = await item.getAttribute('href')
65
66 if (href?.includes('/update/')) {
67 await item.click()
68 return
69 }
70 }
71 }
72
73 clickOnSave () {
74 return $('.action-button-save').click()
75 }
76
77 async createPlaylist (name: string) {
78 const newPlaylistButton = () => $('.new-playlist-button')
79
80 await newPlaylistButton().waitForClickable()
81 await newPlaylistButton().click()
82
83 const displayName = () => $('#displayName')
84
85 await displayName().waitForDisplayed()
86 await displayName().setValue(name)
87
88 return $('.new-playlist-block input[type=submit]').click()
89 }
90
91 async saveToPlaylist (name: string) {
92 const playlist = () => $('my-video-add-to-playlist').$(`.playlist=${name}`)
93
94 await playlist().waitForDisplayed()
95
96 return playlist().click()
97 }
98
99 waitUntilVideoName (name: string, maxTime: number) {
100 return browser.waitUntil(async () => {
101 return (await this.getVideoName()) === name
102 }, { timeout: maxTime })
103 }
104
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
112 private async getVideoNameElement () {
113 // We have 2 video info name block, pick the first that is not empty
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()
127 }
128 }