2019-06-17 01:11:25 -05:00
|
|
|
import { browser, by, element, ElementFinder, ExpectedConditions } from 'protractor'
|
2020-08-07 03:25:07 -05:00
|
|
|
import { browserSleep, isMobileDevice } from '../utils'
|
2018-05-17 03:55:01 -05:00
|
|
|
|
|
|
|
export class VideoWatchPage {
|
2018-05-24 02:05:58 -05:00
|
|
|
async goOnVideosList (isMobileDevice: boolean, isSafari: boolean) {
|
2018-05-19 06:58:29 -05:00
|
|
|
let url: string
|
|
|
|
|
2018-05-24 02:05:58 -05:00
|
|
|
// We did not upload a file on a mobile device
|
|
|
|
if (isMobileDevice === true || isSafari === true) {
|
2018-05-19 06:58:29 -05:00
|
|
|
url = 'https://peertube2.cpy.re/videos/local'
|
|
|
|
} else {
|
|
|
|
url = '/videos/recently-added'
|
|
|
|
}
|
2018-05-17 03:55:01 -05:00
|
|
|
|
2020-05-12 09:38:55 -05:00
|
|
|
await browser.get(url, 20000)
|
2018-05-22 09:02:29 -05:00
|
|
|
|
|
|
|
// Waiting the following element does not work on Safari...
|
2020-05-12 09:38:55 -05:00
|
|
|
if (isSafari) return browserSleep(3000)
|
2018-05-22 09:02:29 -05:00
|
|
|
|
|
|
|
const elem = element.all(by.css('.videos .video-miniature .video-miniature-name')).first()
|
|
|
|
return browser.wait(browser.ExpectedConditions.visibilityOf(elem))
|
2018-05-17 03:55:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
getVideosListName () {
|
2018-05-22 09:02:29 -05:00
|
|
|
return element.all(by.css('.videos .video-miniature .video-miniature-name'))
|
2018-05-19 06:58:29 -05:00
|
|
|
.getText()
|
2018-10-18 07:35:31 -05:00
|
|
|
.then((texts: any) => texts.map((t: any) => t.trim()))
|
2018-05-17 03:55:01 -05:00
|
|
|
}
|
|
|
|
|
2018-09-20 08:45:11 -05:00
|
|
|
waitWatchVideoName (videoName: string, isMobileDevice: boolean, isSafari: boolean) {
|
2020-05-12 09:38:55 -05:00
|
|
|
if (isSafari) return browserSleep(5000)
|
|
|
|
|
2018-09-20 08:45:11 -05:00
|
|
|
// On mobile we display the first node, on desktop the second
|
|
|
|
const index = isMobileDevice ? 0 : 1
|
|
|
|
|
|
|
|
const elem = element.all(by.css('.video-info .video-info-name')).get(index)
|
2018-05-17 03:55:01 -05:00
|
|
|
return browser.wait(browser.ExpectedConditions.textToBePresentInElement(elem, videoName))
|
|
|
|
}
|
|
|
|
|
2019-06-17 01:11:25 -05:00
|
|
|
getVideoName () {
|
|
|
|
return this.getVideoNameElement().getText()
|
|
|
|
}
|
|
|
|
|
2020-08-07 03:25:07 -05:00
|
|
|
async goOnAssociatedEmbed () {
|
|
|
|
let url = await browser.getCurrentUrl()
|
2021-05-28 04:36:33 -05:00
|
|
|
url = url.replace('/w/', '/embed/')
|
2020-08-07 03:25:07 -05:00
|
|
|
url = url.replace(':3333', ':9001')
|
2020-05-12 09:38:55 -05:00
|
|
|
|
2020-08-07 03:25:07 -05:00
|
|
|
return browser.get(url)
|
|
|
|
}
|
2018-06-08 07:20:43 -05:00
|
|
|
|
2020-08-07 03:25:07 -05:00
|
|
|
async goOnP2PMediaLoaderEmbed () {
|
|
|
|
return browser.get('https://peertube2.cpy.re/videos/embed/969bf103-7818-43b5-94a0-de159e13de50')
|
|
|
|
}
|
2018-05-18 04:02:40 -05:00
|
|
|
|
2020-08-07 03:25:07 -05:00
|
|
|
async goOnP2PMediaLoaderPlaylistEmbed () {
|
|
|
|
return browser.get('https://peertube2.cpy.re/video-playlists/embed/73804a40-da9a-40c2-b1eb-2c6d9eec8f0a')
|
2018-05-17 03:55:01 -05:00
|
|
|
}
|
|
|
|
|
2018-05-18 04:02:40 -05:00
|
|
|
async clickOnVideo (videoName: string) {
|
2020-05-10 03:36:42 -05:00
|
|
|
const video = element.all(by.css('.videos .video-miniature .video-miniature-name'))
|
|
|
|
.filter(e => e.getText().then(t => t === videoName ))
|
|
|
|
.first()
|
|
|
|
|
2018-05-19 06:58:29 -05:00
|
|
|
await browser.wait(browser.ExpectedConditions.elementToBeClickable(video))
|
|
|
|
await video.click()
|
|
|
|
|
2021-05-28 04:36:33 -05:00
|
|
|
await browser.wait(browser.ExpectedConditions.urlContains('/w/'))
|
2018-05-19 06:58:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
async clickOnFirstVideo () {
|
2020-05-11 03:48:42 -05:00
|
|
|
const video = element.all(by.css('.videos .video-miniature .video-thumbnail')).first()
|
|
|
|
const videoName = element.all(by.css('.videos .video-miniature .video-miniature-name')).first()
|
2018-05-24 02:05:58 -05:00
|
|
|
|
|
|
|
// Don't know why but the expectation fails on Safari
|
2018-05-19 06:58:29 -05:00
|
|
|
await browser.wait(browser.ExpectedConditions.elementToBeClickable(video))
|
2018-05-17 03:55:01 -05:00
|
|
|
|
2020-05-11 03:48:42 -05:00
|
|
|
const textToReturn = videoName.getText()
|
2018-05-17 03:55:01 -05:00
|
|
|
await video.click()
|
|
|
|
|
2021-05-28 04:36:33 -05:00
|
|
|
await browser.wait(browser.ExpectedConditions.urlContains('/w/'))
|
2018-05-19 06:58:29 -05:00
|
|
|
return textToReturn
|
2018-05-17 03:55:01 -05:00
|
|
|
}
|
|
|
|
|
2019-06-17 01:11:25 -05:00
|
|
|
async clickOnUpdate () {
|
|
|
|
const dropdown = element(by.css('my-video-actions-dropdown .action-button'))
|
|
|
|
await dropdown.click()
|
|
|
|
|
2021-05-05 02:05:46 -05:00
|
|
|
const items: ElementFinder[] = await element.all(by.css('.dropdown-menu.show .dropdown-item'))
|
2019-06-17 01:11:25 -05:00
|
|
|
|
|
|
|
for (const item of items) {
|
|
|
|
const href = await item.getAttribute('href')
|
|
|
|
|
|
|
|
if (href && href.includes('/update/')) {
|
|
|
|
await item.click()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async clickOnSave () {
|
|
|
|
return element(by.css('.action-button-save')).click()
|
|
|
|
}
|
|
|
|
|
2019-06-18 03:20:55 -05:00
|
|
|
async createPlaylist (name: string) {
|
|
|
|
await element(by.css('.new-playlist-button')).click()
|
|
|
|
|
|
|
|
await element(by.css('#displayName')).sendKeys(name)
|
|
|
|
|
|
|
|
return element(by.css('.new-playlist-block input[type=submit]')).click()
|
|
|
|
}
|
|
|
|
|
|
|
|
async saveToPlaylist (name: string) {
|
|
|
|
return element.all(by.css('my-video-add-to-playlist .playlist'))
|
|
|
|
.filter(p => p.getText().then(t => t === name))
|
|
|
|
.click()
|
2019-06-17 01:11:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
waitUntilVideoName (name: string, maxTime: number) {
|
|
|
|
const elem = this.getVideoNameElement()
|
|
|
|
|
|
|
|
return browser.wait(ExpectedConditions.textToBePresentInElement(elem, name), maxTime)
|
|
|
|
}
|
|
|
|
|
|
|
|
private getVideoNameElement () {
|
|
|
|
// We have 2 video info name block, pick the first that is not empty
|
2020-05-10 03:36:42 -05:00
|
|
|
return element.all(by.css('.video-info-first-row .video-info-name'))
|
2019-06-17 01:11:25 -05:00
|
|
|
.filter(e => e.getText().then(t => !!t))
|
|
|
|
.first()
|
|
|
|
}
|
2018-05-17 03:55:01 -05:00
|
|
|
}
|