aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/e2e/src/po/my-account.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/e2e/src/po/my-account.ts')
-rw-r--r--client/e2e/src/po/my-account.ts102
1 files changed, 67 insertions, 35 deletions
diff --git a/client/e2e/src/po/my-account.ts b/client/e2e/src/po/my-account.ts
index 9866953e9..85dc02805 100644
--- a/client/e2e/src/po/my-account.ts
+++ b/client/e2e/src/po/my-account.ts
@@ -1,85 +1,117 @@
1import { by, element, browser } from 'protractor' 1import { go } from '../utils'
2 2
3export class MyAccountPage { 3export class MyAccountPage {
4 4
5 navigateToMyVideos () { 5 navigateToMyVideos () {
6 return element(by.css('a[href="/my-library/videos"]')).click() 6 return $('a[href="/my-library/videos"]').click()
7 } 7 }
8 8
9 navigateToMyPlaylists () { 9 navigateToMyPlaylists () {
10 return element(by.css('a[href="/my-library/video-playlists"]')).click() 10 return $('a[href="/my-library/video-playlists"]').click()
11 } 11 }
12 12
13 navigateToMyHistory () { 13 navigateToMyHistory () {
14 return element(by.css('a[href="/my-library/history/videos"]')).click() 14 return $('a[href="/my-library/history/videos"]').click()
15 } 15 }
16 16
17 // My account Videos 17 // My account Videos
18 18
19 async removeVideo (name: string) { 19 async removeVideo (name: string) {
20 const container = this.getVideoElement(name) 20 const container = await this.getVideoElement(name)
21 21
22 await container.element(by.css('.dropdown-toggle')).click() 22 await container.$('.dropdown-toggle').click()
23 23
24 const dropdownMenu = container.element(by.css('.dropdown-menu .dropdown-item:nth-child(2)')) 24 const dropdownMenu = () => container.$('.dropdown-menu .dropdown-item:nth-child(2)')
25 await browser.wait(browser.ExpectedConditions.presenceOf(dropdownMenu))
26 25
27 return dropdownMenu.click() 26 await dropdownMenu().waitForDisplayed()
27 return dropdownMenu().click()
28 } 28 }
29 29
30 validRemove () { 30 validRemove () {
31 return element(by.css('input[type=submit]')).click() 31 return $('input[type=submit]').click()
32 } 32 }
33 33
34 countVideos (names: string[]) { 34 async countVideos (names: string[]) {
35 return element.all(by.css('.video')) 35 const elements = await $$('.video').filter(async e => {
36 .filter(e => { 36 const t = await e.$('.video-miniature-name').getText()
37 return e.element(by.css('.video-miniature-name')) 37
38 .getText() 38 return names.some(n => t.includes(n))
39 .then(t => names.some(n => t.includes(n))) 39 })
40 }) 40
41 .count() 41 return elements.length
42 } 42 }
43 43
44 // My account playlists 44 // My account playlists
45 45
46 getPlaylistVideosText (name: string) { 46 async getPlaylistVideosText (name: string) {
47 return this.getPlaylist(name).element(by.css('.miniature-playlist-info-overlay')).getText() 47 const elem = await this.getPlaylist(name)
48
49 return elem.$('.miniature-playlist-info-overlay').getText()
48 } 50 }
49 51
50 clickOnPlaylist (name: string) { 52 async clickOnPlaylist (name: string) {
51 return this.getPlaylist(name).element(by.css('.miniature-thumbnail')).click() 53 const elem = await this.getPlaylist(name)
54
55 return elem.$('.miniature-thumbnail').click()
52 } 56 }
53 57
54 countTotalPlaylistElements () { 58 async countTotalPlaylistElements () {
55 return element.all(by.css('my-video-playlist-element-miniature')).count() 59 await $('<my-video-playlist-element-miniature>').waitForDisplayed()
60
61 return $$('<my-video-playlist-element-miniature>').length
56 } 62 }
57 63
58 playPlaylist () { 64 playPlaylist () {
59 return element(by.css('.playlist-info .miniature-thumbnail')).click() 65 return $('.playlist-info .miniature-thumbnail').click()
60 } 66 }
61 67
62 async goOnAssociatedPlaylistEmbed () { 68 async goOnAssociatedPlaylistEmbed () {
63 let url = await browser.getCurrentUrl() 69 let url = await browser.getUrl()
64 url = url.replace('/w/p/', '/video-playlists/embed/') 70 url = url.replace('/w/p/', '/video-playlists/embed/')
65 url = url.replace(':3333', ':9001') 71 url = url.replace(':3333', ':9001')
66 72
67 return browser.get(url) 73 return go(url)
68 } 74 }
69 75
70 // My account Videos 76 // My account Videos
71 77
72 private getVideoElement (name: string) { 78 private async getVideoElement (name: string) {
73 return element.all(by.css('.video')) 79 const video = async () => {
74 .filter(e => e.element(by.css('.video-miniature-name')).getText().then(t => t.includes(name))) 80 const videos = await $$('.video').filter(async e => {
75 .first() 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()
76 } 94 }
77 95
78 // My account playlists 96 // My account playlists
79 97
80 private getPlaylist (name: string) { 98 private async getPlaylist (name: string) {
81 return element.all(by.css('my-video-playlist-miniature')) 99 const playlist = () => {
82 .filter(e => e.element(by.css('.miniature-name')).getText().then(t => t.includes(name))) 100 return $$('my-video-playlist-miniature')
83 .first() 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()
84 } 116 }
85} 117}