X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fe2e%2Fsrc%2Fpo%2Fvideo-watch.po.ts;h=cecda3a8b941a1092d558294ccf10bda4952acc6;hb=a9bfa85d2cdf13670aaced740da5b493fbeddfce;hp=d1e2a73b82851cf14ea3ef2c22008ea7901137dc;hpb=be0f59b4eec3c2c4dcd151e2b174be39dff1568e;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 d1e2a73b8..cecda3a8b 100644 --- a/client/e2e/src/po/video-watch.po.ts +++ b/client/e2e/src/po/video-watch.po.ts @@ -1,100 +1,139 @@ -import { browser, by, element } from 'protractor' +import { browserSleep, FIXTURE_URLS, go } from '../utils' export class VideoWatchPage { - async goOnVideosList (isMobileDevice: boolean, isSafari: boolean) { - let url: string - - // 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) + constructor (private isMobileDevice: boolean, private isSafari: boolean) { + + } - // Waiting the following element does not work on Safari... - if (isSafari === true) return browser.sleep(3000) + waitWatchVideoName (videoName: string) { + if (this.isSafari) return browserSleep(5000) + + // On mobile we display the first node, on desktop the second + const index = this.isMobileDevice ? 0 : 1 - const elem = element.all(by.css('.videos .video-miniature .video-miniature-name')).first() - return browser.wait(browser.ExpectedConditions.visibilityOf(elem)) + return browser.waitUntil(async () => { + return (await $$('.video-info .video-info-name')[index].getText()).includes(videoName) + }) } - getVideosListName () { - return element.all(by.css('.videos .video-miniature .video-miniature-name')) - .getText() - .then((texts: any) => texts.map((t: any) => t.trim())) + getVideoName () { + return this.getVideoNameElement().then(e => e.getText()) } - waitWatchVideoName (videoName: string, isMobileDevice: boolean, isSafari: boolean) { - // On mobile we display the first node, on desktop the second - const index = isMobileDevice ? 0 : 1 + getPrivacy () { + return $('.attribute-privacy .attribute-value').getText() + } - const elem = element.all(by.css('.video-info .video-info-name')).get(index) + getLicence () { + return $('.attribute-licence .attribute-value').getText() + } - if (isSafari) return browser.sleep(5000) + async isDownloadEnabled () { + await this.clickOnMoreDropdownIcon() - return browser.wait(browser.ExpectedConditions.textToBePresentInElement(elem, videoName)) + return $('.dropdown-item .icon-download').isExisting() } - getWatchVideoPlayerCurrentTime () { - return element(by.css('.video-js .vjs-current-time-display')) - .getText() - .then((t: string) => t.split(':')[1]) - .then(seconds => parseInt(seconds, 10)) + areCommentsEnabled () { + return $('my-video-comment-add').isExisting() } - async pauseVideo (isAutoplay: boolean, isMobileDevice: boolean) { - if (isAutoplay === false) { - const playButton = element(by.css('.vjs-big-play-button')) - await browser.wait(browser.ExpectedConditions.elementToBeClickable(playButton)) - await playButton.click() - } + isPrivacyWarningDisplayed () { + return $('my-privacy-concerns').isDisplayed() + } - await browser.sleep(1000) - await browser.wait(browser.ExpectedConditions.invisibilityOf(element(by.css('.vjs-loading-spinner')))) + async goOnAssociatedEmbed () { + let url = await browser.getUrl() + url = url.replace('/w/', '/videos/embed/') + url = url.replace(':3333', ':9001') - const videojsEl = element(by.css('div.video-js')) - await browser.wait(browser.ExpectedConditions.elementToBeClickable(videojsEl)) + await go(url) + await $('.vjs-big-play-button').waitForDisplayed() + } - // On Android, we need to click twice on "play" (BrowserStack particularity) - if (isMobileDevice) { - await browser.sleep(3000) - await videojsEl.click() - } + async isEmbedWarningDisplayed () { + const text = await $('.vjs-dock-description').getText() + + return !!text.trim() + } + + goOnP2PMediaLoaderEmbed () { + return go(FIXTURE_URLS.HLS_EMBED) + } + + goOnP2PMediaLoaderPlaylistEmbed () { + return go(FIXTURE_URLS.HLS_PLAYLIST_EMBED) + } + + async clickOnUpdate () { + await this.clickOnMoreDropdownIcon() + + const items = await $$('.dropdown-menu.show .dropdown-item') - await browser.sleep(7000) + for (const item of items) { + const href = await item.getAttribute('href') + + if (href?.includes('/update/')) { + await item.click() + return + } + } + } - return videojsEl.click() + clickOnSave () { + return $('.action-button-save').click() } - async clickOnVideo (videoName: string) { - const video = element(by.css('.videos .video-miniature .video-thumbnail[title="' + videoName + '"]')) - await browser.wait(browser.ExpectedConditions.elementToBeClickable(video)) - await video.click() + async createPlaylist (name: string) { + const newPlaylistButton = () => $('.new-playlist-button') + + await newPlaylistButton().waitForClickable() + await newPlaylistButton().click() + + const displayName = () => $('#displayName') - await browser.wait(browser.ExpectedConditions.urlContains('/watch/')) + await displayName().waitForDisplayed() + await displayName().setValue(name) + + return $('.new-playlist-block input[type=submit]').click() } - async clickOnFirstVideo () { - 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() + async saveToPlaylist (name: string) { + const playlist = () => $('my-video-add-to-playlist').$(`.playlist=${name}`) - // Don't know why but the expectation fails on Safari - await browser.wait(browser.ExpectedConditions.elementToBeClickable(video)) + await playlist().waitForDisplayed() - const textToReturn = videoName.getText() - await video.click() + return playlist().click() + } - await browser.wait(browser.ExpectedConditions.urlContains('/watch/')) - return textToReturn + waitUntilVideoName (name: string, maxTime: number) { + return browser.waitUntil(async () => { + return (await this.getVideoName()) === name + }, { timeout: maxTime }) } - async goOnAssociatedEmbed () { - let url = await browser.getCurrentUrl() - url = url.replace('/watch/', '/embed/') - url = url.replace(':3333', ':9001') + async clickOnMoreDropdownIcon () { + const dropdown = $('my-video-actions-dropdown .action-button') + await dropdown.click() + + await $('.dropdown-menu.show .dropdown-item').waitForDisplayed() + } + + private async getVideoNameElement () { + // We have 2 video info name block, pick the first that is not empty + const elem = async () => { + const elems = await $$('.video-info-first-row .video-info-name').filter(e => e.isDisplayed()) + + return elems[0] + } + + await browser.waitUntil(async () => { + const e = await elem() + + return e?.isDisplayed() + }) - return browser.get(url) + return elem() } }