X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fe2e%2Fsrc%2Fpo%2Fvideo-watch.po.ts;h=fb9c3a000661e8628f42c3023c3a3a1043ff3378;hb=6b88559babc1e0490119a6b52411b10910d9da9d;hp=19d02ff51b422f16f7331e2bf41f85d46b88e402;hpb=d1bd87e066633b8a66266b280327ec828980916b;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/e2e/src/po/video-watch.po.ts b/client/e2e/src/po/video-watch.po.ts index 19d02ff51..fb9c3a000 100644 --- a/client/e2e/src/po/video-watch.po.ts +++ b/client/e2e/src/po/video-watch.po.ts @@ -1,20 +1,21 @@ -import { by, element, browser } from 'protractor' +import { browser, by, element, ElementFinder, ExpectedConditions } from 'protractor' +import { browserSleep, isMobileDevice } from '../utils' export class VideoWatchPage { - async goOnVideosList (isIphoneDevice: boolean, isSafari: boolean) { + async goOnVideosList (isMobileDevice: boolean, isSafari: boolean) { let url: string - if (isIphoneDevice === true) { - // Local testing is buggy :/ + // We did not upload a file on a mobile device + if (isMobileDevice === true || isSafari === true) { url = 'https://peertube2.cpy.re/videos/local' } else { url = '/videos/recently-added' } - await browser.get(url) + await browser.get(url, 20000) // Waiting the following element does not work on Safari... - if (isSafari === true) return browser.sleep(3000) + if (isSafari) return browserSleep(3000) const elem = element.all(by.css('.videos .video-miniature .video-miniature-name')).first() return browser.wait(browser.ExpectedConditions.visibilityOf(elem)) @@ -23,46 +24,44 @@ export class VideoWatchPage { getVideosListName () { return element.all(by.css('.videos .video-miniature .video-miniature-name')) .getText() - .then((texts: any) => texts.map(t => t.trim())) + .then((texts: any) => texts.map((t: any) => t.trim())) } - waitWatchVideoName (videoName: string) { - const elem = element(by.css('.video-info .video-info-name')) + waitWatchVideoName (videoName: string, isMobileDevice: boolean, isSafari: boolean) { + if (isSafari) return browserSleep(5000) + + // 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) return browser.wait(browser.ExpectedConditions.textToBePresentInElement(elem, videoName)) } - getWatchVideoPlayerCurrentTime () { - return element(by.css('.video-js .vjs-current-time-display')) - .getText() - .then((t: string) => t.split(':')[1]) - .then(seconds => parseInt(seconds, 10)) + getVideoName () { + return this.getVideoNameElement().getText() } - async pauseVideo (pauseAfterMs: number, isAutoplay: boolean, isSafari: boolean) { - if (isAutoplay === false) { - const playButton = element(by.css('.vjs-big-play-button')) - await browser.wait(browser.ExpectedConditions.elementToBeClickable(playButton)) - await playButton.click() - } - - if (isSafari === true) { - await browser.sleep(1000) - await element(by.css('.vjs-play-control')).click() - } - - await browser.sleep(1000) - await browser.wait(browser.ExpectedConditions.invisibilityOf(element(by.css('.vjs-loading-spinner')))) + async goOnAssociatedEmbed () { + let url = await browser.getCurrentUrl() + url = url.replace('/watch/', '/embed/') + url = url.replace(':3333', ':9001') - const el = element(by.css('div.video-js')) - await browser.wait(browser.ExpectedConditions.elementToBeClickable(el)) + return browser.get(url) + } - await browser.sleep(pauseAfterMs) + async goOnP2PMediaLoaderEmbed () { + return browser.get('https://peertube2.cpy.re/videos/embed/969bf103-7818-43b5-94a0-de159e13de50') + } - return el.click() + async goOnP2PMediaLoaderPlaylistEmbed () { + return browser.get('https://peertube2.cpy.re/video-playlists/embed/73804a40-da9a-40c2-b1eb-2c6d9eec8f0a') } async clickOnVideo (videoName: string) { - const video = element(by.css('.videos .video-miniature .video-thumbnail[title="' + videoName + '"]')) + const video = element.all(by.css('.videos .video-miniature .video-miniature-name')) + .filter(e => e.getText().then(t => t === videoName )) + .first() + await browser.wait(browser.ExpectedConditions.elementToBeClickable(video)) await video.click() @@ -70,21 +69,63 @@ export class VideoWatchPage { } async clickOnFirstVideo () { - const video = element.all(by.css('.videos .video-miniature .video-miniature-name')).first() + 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() + + // Don't know why but the expectation fails on Safari await browser.wait(browser.ExpectedConditions.elementToBeClickable(video)) - const textToReturn = video.getText() + const textToReturn = videoName.getText() await video.click() await browser.wait(browser.ExpectedConditions.urlContains('/watch/')) return textToReturn } - async goOnAssociatedEmbed () { - let url = await browser.getCurrentUrl() - url = url.replace('/watch/', '/embed/') - url = url.replace(':3333', ':9001') + async clickOnUpdate () { + const dropdown = element(by.css('my-video-actions-dropdown .action-button')) + await dropdown.click() - return browser.get(url) + const items: ElementFinder[] = await element.all(by.css('my-video-actions-dropdown .dropdown-menu .dropdown-item')) + + 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() + } + + 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() + } + + 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 + return element.all(by.css('.video-info-first-row .video-info-name')) + .filter(e => e.getText().then(t => !!t)) + .first() } }