]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/e2e/src/po/my-account.ts
Support '/w/' and '/w/p/' for watch page
[github/Chocobozzz/PeerTube.git] / client / e2e / src / po / my-account.ts
1 import { by, element, browser } from 'protractor'
2
3 export class MyAccountPage {
4
5 navigateToMyVideos () {
6 return element(by.css('a[href="/my-library/videos"]')).click()
7 }
8
9 navigateToMyPlaylists () {
10 return element(by.css('a[href="/my-library/video-playlists"]')).click()
11 }
12
13 navigateToMyHistory () {
14 return element(by.css('a[href="/my-library/history/videos"]')).click()
15 }
16
17 // My account Videos
18
19 async removeVideo (name: string) {
20 const container = this.getVideoElement(name)
21
22 await container.element(by.css('.dropdown-toggle')).click()
23
24 const dropdownMenu = container.element(by.css('.dropdown-menu .dropdown-item:nth-child(2)'))
25 await browser.wait(browser.ExpectedConditions.presenceOf(dropdownMenu))
26
27 return dropdownMenu.click()
28 }
29
30 validRemove () {
31 return element(by.css('input[type=submit]')).click()
32 }
33
34 countVideos (names: string[]) {
35 return element.all(by.css('.video'))
36 .filter(e => {
37 return e.element(by.css('.video-miniature-name'))
38 .getText()
39 .then(t => names.some(n => t.includes(n)))
40 })
41 .count()
42 }
43
44 // My account playlists
45
46 getPlaylistVideosText (name: string) {
47 return this.getPlaylist(name).element(by.css('.miniature-playlist-info-overlay')).getText()
48 }
49
50 clickOnPlaylist (name: string) {
51 return this.getPlaylist(name).element(by.css('.miniature-thumbnail')).click()
52 }
53
54 countTotalPlaylistElements () {
55 return element.all(by.css('my-video-playlist-element-miniature')).count()
56 }
57
58 playPlaylist () {
59 return element(by.css('.playlist-info .miniature-thumbnail')).click()
60 }
61
62 async goOnAssociatedPlaylistEmbed () {
63 let url = await browser.getCurrentUrl()
64 url = url.replace('/w/p/', '/video-playlists/embed/')
65 url = url.replace(':3333', ':9001')
66
67 return browser.get(url)
68 }
69
70 // My account Videos
71
72 private getVideoElement (name: string) {
73 return element.all(by.css('.video'))
74 .filter(e => e.element(by.css('.video-miniature-name')).getText().then(t => t.includes(name)))
75 .first()
76 }
77
78 // My account playlists
79
80 private getPlaylist (name: string) {
81 return element.all(by.css('my-video-playlist-miniature'))
82 .filter(e => e.element(by.css('.miniature-name')).getText().then(t => t.includes(name)))
83 .first()
84 }
85 }