aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/e2e/src/po/my-account.po.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/e2e/src/po/my-account.po.ts')
-rw-r--r--client/e2e/src/po/my-account.po.ts150
1 files changed, 150 insertions, 0 deletions
diff --git a/client/e2e/src/po/my-account.po.ts b/client/e2e/src/po/my-account.po.ts
new file mode 100644
index 000000000..13a764e87
--- /dev/null
+++ b/client/e2e/src/po/my-account.po.ts
@@ -0,0 +1,150 @@
1import { getCheckbox, go } from '../utils'
2
3export class MyAccountPage {
4
5 navigateToMyVideos () {
6 return $('a[href="/my-library/videos"]').click()
7 }
8
9 navigateToMyPlaylists () {
10 return $('a[href="/my-library/video-playlists"]').click()
11 }
12
13 navigateToMyHistory () {
14 return $('a[href="/my-library/history/videos"]').click()
15 }
16
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
30 await this.submitVideoSettings()
31 }
32
33 async clickOnP2PCheckbox () {
34 const p2p = getCheckbox('p2pEnabled')
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 () {
45 const submit = $('my-user-video-settings input[type=submit]')
46 await submit.scrollIntoView(false)
47 await submit.click()
48 }
49
50 // My account Videos
51
52 async removeVideo (name: string) {
53 const container = await this.getVideoElement(name)
54
55 await container.$('.dropdown-toggle').click()
56
57 const dropdownMenu = () => container.$$('.dropdown-menu .dropdown-item')[1]
58
59 await dropdownMenu().waitForDisplayed()
60 return dropdownMenu().click()
61 }
62
63 validRemove () {
64 return $('input[type=submit]').click()
65 }
66
67 async countVideos (names: string[]) {
68 const elements = await $$('.video').filter(async e => {
69 const t = await e.$('.video-miniature-name').getText()
70
71 return names.some(n => t.includes(n))
72 })
73
74 return elements.length
75 }
76
77 // My account playlists
78
79 async getPlaylistVideosText (name: string) {
80 const elem = await this.getPlaylist(name)
81
82 return elem.$('.miniature-playlist-info-overlay').getText()
83 }
84
85 async clickOnPlaylist (name: string) {
86 const elem = await this.getPlaylist(name)
87
88 return elem.$('.miniature-thumbnail').click()
89 }
90
91 async countTotalPlaylistElements () {
92 await $('<my-video-playlist-element-miniature>').waitForDisplayed()
93
94 return $$('<my-video-playlist-element-miniature>').length
95 }
96
97 playPlaylist () {
98 return $('.playlist-info .miniature-thumbnail').click()
99 }
100
101 async goOnAssociatedPlaylistEmbed () {
102 let url = await browser.getUrl()
103 url = url.replace('/w/p/', '/video-playlists/embed/')
104 url = url.replace(':3333', ':9001')
105
106 return go(url)
107 }
108
109 // My account Videos
110
111 private async getVideoElement (name: string) {
112 const video = async () => {
113 const videos = await $$('.video').filter(async e => {
114 const t = await e.$('.video-miniature-name').getText()
115
116 return t.includes(name)
117 })
118
119 return videos[0]
120 }
121
122 await browser.waitUntil(async () => {
123 return (await video()).isDisplayed()
124 })
125
126 return video()
127 }
128
129 // My account playlists
130
131 private async getPlaylist (name: string) {
132 const playlist = () => {
133 return $$('my-video-playlist-miniature')
134 .filter(async e => {
135 const t = await e.$('.miniature-name').getText()
136
137 return t.includes(name)
138 })
139 .then(elems => elems[0])
140 }
141
142 await browser.waitUntil(async () => {
143 const el = await playlist()
144
145 return el?.isDisplayed()
146 })
147
148 return playlist()
149 }
150}