]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/e2e/src/po/my-account.po.ts
Introduce worker threads to process remote images
[github/Chocobozzz/PeerTube.git] / client / e2e / src / po / my-account.po.ts
CommitLineData
a9bfa85d 1import { getCheckbox, go } from '../utils'
e69cb173
C
2
3export class MyAccountPage {
4
5 navigateToMyVideos () {
3419e0e1 6 return $('a[href="/my-library/videos"]').click()
e69cb173
C
7 }
8
9 navigateToMyPlaylists () {
3419e0e1 10 return $('a[href="/my-library/video-playlists"]').click()
e69cb173
C
11 }
12
13 navigateToMyHistory () {
3419e0e1 14 return $('a[href="/my-library/history/videos"]').click()
e69cb173
C
15 }
16
6d210220
C
17 // Settings
18
19 navigateToMySettings () {
20 return $('a[href="/my-account"]').click()
21 }
22
23 async updateNSFW (newValue: 'do_not_list' | 'blur' | 'display') {
24 const nsfw = $('#nsfwPolicy')
25
26 await nsfw.waitForDisplayed()
27 await nsfw.scrollIntoView(false) // Avoid issues with fixed header on firefox
28 await nsfw.selectByAttribute('value', newValue)
29
a9bfa85d
C
30 await this.submitVideoSettings()
31 }
32
33 async clickOnP2PCheckbox () {
3c065fe3 34 const p2p = await getCheckbox('p2pEnabled')
a9bfa85d
C
35
36 await p2p.waitForClickable()
37 await p2p.scrollIntoView(false) // Avoid issues with fixed header on firefox
38
39 await p2p.click()
40
41 await this.submitVideoSettings()
42 }
43
44 private async submitVideoSettings () {
6d210220
C
45 const submit = $('my-user-video-settings input[type=submit]')
46 await submit.scrollIntoView(false)
47 await submit.click()
48 }
49
e69cb173
C
50 // My account Videos
51
6b88559b 52 async removeVideo (name: string) {
3419e0e1 53 const container = await this.getVideoElement(name)
6b88559b 54
3419e0e1 55 await container.$('.dropdown-toggle').click()
6b88559b 56
a6241926
C
57 const deleteItem = () => {
58 return $$('.dropdown-menu .dropdown-item').find<WebdriverIO.Element>(async v => {
59 const text = await v.getText()
6b88559b 60
a6241926
C
61 return text.includes('Delete')
62 })
63 }
64
65 await (await deleteItem()).waitForClickable()
66
67 return (await deleteItem()).click()
e69cb173
C
68 }
69
70 validRemove () {
3419e0e1 71 return $('input[type=submit]').click()
e69cb173
C
72 }
73
3419e0e1
C
74 async countVideos (names: string[]) {
75 const elements = await $$('.video').filter(async e => {
76 const t = await e.$('.video-miniature-name').getText()
77
78 return names.some(n => t.includes(n))
79 })
80
81 return elements.length
e69cb173
C
82 }
83
84 // My account playlists
85
3419e0e1
C
86 async getPlaylistVideosText (name: string) {
87 const elem = await this.getPlaylist(name)
88
89 return elem.$('.miniature-playlist-info-overlay').getText()
e69cb173
C
90 }
91
3419e0e1
C
92 async clickOnPlaylist (name: string) {
93 const elem = await this.getPlaylist(name)
94
95 return elem.$('.miniature-thumbnail').click()
e69cb173
C
96 }
97
3419e0e1
C
98 async countTotalPlaylistElements () {
99 await $('<my-video-playlist-element-miniature>').waitForDisplayed()
100
101 return $$('<my-video-playlist-element-miniature>').length
e69cb173
C
102 }
103
104 playPlaylist () {
3419e0e1 105 return $('.playlist-info .miniature-thumbnail').click()
e69cb173
C
106 }
107
5ab7fd9d 108 async goOnAssociatedPlaylistEmbed () {
3419e0e1 109 let url = await browser.getUrl()
a1eda903 110 url = url.replace('/w/p/', '/video-playlists/embed/')
5ab7fd9d
C
111 url = url.replace(':3333', ':9001')
112
3419e0e1 113 return go(url)
5ab7fd9d
C
114 }
115
e69cb173
C
116 // My account Videos
117
3419e0e1
C
118 private async getVideoElement (name: string) {
119 const video = async () => {
120 const videos = await $$('.video').filter(async e => {
121 const t = await e.$('.video-miniature-name').getText()
122
123 return t.includes(name)
124 })
125
126 return videos[0]
127 }
128
129 await browser.waitUntil(async () => {
130 return (await video()).isDisplayed()
131 })
132
133 return video()
e69cb173
C
134 }
135
136 // My account playlists
137
3419e0e1
C
138 private async getPlaylist (name: string) {
139 const playlist = () => {
140 return $$('my-video-playlist-miniature')
141 .filter(async e => {
142 const t = await e.$('.miniature-name').getText()
143
144 return t.includes(name)
145 })
146 .then(elems => elems[0])
147 }
148
149 await browser.waitUntil(async () => {
150 const el = await playlist()
151
152 return el?.isDisplayed()
153 })
154
155 return playlist()
e69cb173
C
156 }
157}