1 import { go } from '../utils'
3 export class MyAccountPage {
5 navigateToMyVideos () {
6 return $('a[href="/my-library/videos"]').click()
9 navigateToMyPlaylists () {
10 return $('a[href="/my-library/video-playlists"]').click()
13 navigateToMyHistory () {
14 return $('a[href="/my-library/history/videos"]').click()
19 async removeVideo (name: string) {
20 const container = await this.getVideoElement(name)
22 await container.$('.dropdown-toggle').click()
24 const dropdownMenu = () => container.$('.dropdown-menu .dropdown-item:nth-child(2)')
26 await dropdownMenu().waitForDisplayed()
27 return dropdownMenu().click()
31 return $('input[type=submit]').click()
34 async countVideos (names: string[]) {
35 const elements = await $$('.video').filter(async e => {
36 const t = await e.$('.video-miniature-name').getText()
38 return names.some(n => t.includes(n))
41 return elements.length
44 // My account playlists
46 async getPlaylistVideosText (name: string) {
47 const elem = await this.getPlaylist(name)
49 return elem.$('.miniature-playlist-info-overlay').getText()
52 async clickOnPlaylist (name: string) {
53 const elem = await this.getPlaylist(name)
55 return elem.$('.miniature-thumbnail').click()
58 async countTotalPlaylistElements () {
59 await $('<my-video-playlist-element-miniature>').waitForDisplayed()
61 return $$('<my-video-playlist-element-miniature>').length
65 return $('.playlist-info .miniature-thumbnail').click()
68 async goOnAssociatedPlaylistEmbed () {
69 let url = await browser.getUrl()
70 url = url.replace('/w/p/', '/video-playlists/embed/')
71 url = url.replace(':3333', ':9001')
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()
83 return t.includes(name)
89 await browser.waitUntil(async () => {
90 return (await video()).isDisplayed()
96 // My account playlists
98 private async getPlaylist (name: string) {
99 const playlist = () => {
100 return $$('my-video-playlist-miniature')
102 const t = await e.$('.miniature-name').getText()
104 return t.includes(name)
106 .then(elems => elems[0])
109 await browser.waitUntil(async () => {
110 const el = await playlist()
112 return el?.isDisplayed()