]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/e2e/src/po/my-account.ts
Fix hls redundancy pruning
[github/Chocobozzz/PeerTube.git] / client / e2e / src / po / my-account.ts
CommitLineData
3419e0e1 1import { 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
17 // My account Videos
18
6b88559b 19 async removeVideo (name: string) {
3419e0e1 20 const container = await this.getVideoElement(name)
6b88559b 21
3419e0e1 22 await container.$('.dropdown-toggle').click()
6b88559b 23
3419e0e1 24 const dropdownMenu = () => container.$('.dropdown-menu .dropdown-item:nth-child(2)')
6b88559b 25
3419e0e1
C
26 await dropdownMenu().waitForDisplayed()
27 return dropdownMenu().click()
e69cb173
C
28 }
29
30 validRemove () {
3419e0e1 31 return $('input[type=submit]').click()
e69cb173
C
32 }
33
3419e0e1
C
34 async countVideos (names: string[]) {
35 const elements = await $$('.video').filter(async e => {
36 const t = await e.$('.video-miniature-name').getText()
37
38 return names.some(n => t.includes(n))
39 })
40
41 return elements.length
e69cb173
C
42 }
43
44 // My account playlists
45
3419e0e1
C
46 async getPlaylistVideosText (name: string) {
47 const elem = await this.getPlaylist(name)
48
49 return elem.$('.miniature-playlist-info-overlay').getText()
e69cb173
C
50 }
51
3419e0e1
C
52 async clickOnPlaylist (name: string) {
53 const elem = await this.getPlaylist(name)
54
55 return elem.$('.miniature-thumbnail').click()
e69cb173
C
56 }
57
3419e0e1
C
58 async countTotalPlaylistElements () {
59 await $('<my-video-playlist-element-miniature>').waitForDisplayed()
60
61 return $$('<my-video-playlist-element-miniature>').length
e69cb173
C
62 }
63
64 playPlaylist () {
3419e0e1 65 return $('.playlist-info .miniature-thumbnail').click()
e69cb173
C
66 }
67
5ab7fd9d 68 async goOnAssociatedPlaylistEmbed () {
3419e0e1 69 let url = await browser.getUrl()
a1eda903 70 url = url.replace('/w/p/', '/video-playlists/embed/')
5ab7fd9d
C
71 url = url.replace(':3333', ':9001')
72
3419e0e1 73 return go(url)
5ab7fd9d
C
74 }
75
e69cb173
C
76 // My account Videos
77
3419e0e1
C
78 private async getVideoElement (name: string) {
79 const video = async () => {
80 const videos = await $$('.video').filter(async e => {
81 const t = await e.$('.video-miniature-name').getText()
82
83 return t.includes(name)
84 })
85
86 return videos[0]
87 }
88
89 await browser.waitUntil(async () => {
90 return (await video()).isDisplayed()
91 })
92
93 return video()
e69cb173
C
94 }
95
96 // My account playlists
97
3419e0e1
C
98 private async getPlaylist (name: string) {
99 const playlist = () => {
100 return $$('my-video-playlist-miniature')
101 .filter(async e => {
102 const t = await e.$('.miniature-name').getText()
103
104 return t.includes(name)
105 })
106 .then(elems => elems[0])
107 }
108
109 await browser.waitUntil(async () => {
110 const el = await playlist()
111
112 return el?.isDisplayed()
113 })
114
115 return playlist()
e69cb173
C
116 }
117}