X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fe2e%2Fsrc%2Fpo%2Fvideo-upload.po.ts;h=38395ea2f0b4ed81d44184a5aef24461f4ea924a;hb=c3edc5b074aa4bb1861ed0a94d3713808e87170f;hp=741914d2deaab06e634cdc82fa42587f24c88ae7;hpb=2e8e97f313683bdf8a7448f3d1ba1f1c27f6ad50;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/e2e/src/po/video-upload.po.ts b/client/e2e/src/po/video-upload.po.ts index 741914d2d..38395ea2f 100644 --- a/client/e2e/src/po/video-upload.po.ts +++ b/client/e2e/src/po/video-upload.po.ts @@ -1,34 +1,66 @@ -import { browser, element, by } from 'protractor' import { join } from 'path' -import { FileDetector } from 'selenium-webdriver/remote' +import { getCheckbox, selectCustomSelect } from '../utils' export class VideoUploadPage { - navigateTo () { - return browser.get('/videos/upload') + async navigateTo () { + const publishButton = await $('.header .publish-button') + + await publishButton.waitForClickable() + await publishButton.click() + + await $('.upload-video-container').waitForDisplayed() } async uploadVideo () { - browser.setFileDetector(new FileDetector()) - const fileToUpload = join(__dirname, '../../fixtures/video.mp4') + const fileInputSelector = '.upload-video-container input[type=file]' + const parentFileInput = '.upload-video-container .button-file' + + // Avoid sending keys on non visible element + await browser.execute(`document.querySelector('${fileInputSelector}').style.opacity = 1`) + await browser.execute(`document.querySelector('${parentFileInput}').style.overflow = 'initial'`) - await element(by.css('.upload-video-container input[type=file]')).sendKeys(fileToUpload) + await browser.pause(1000) + + const elem = await $(fileInputSelector) + await elem.chooseFile(fileToUpload) // Wait for the upload to finish - await browser.wait(browser.ExpectedConditions.elementToBeClickable(this.getSecondStepSubmitButton())) + await browser.waitUntil(async () => { + const warning = await $('=Publish will be available when upload is finished').isDisplayed() + const progress = await $('.progress-bar=100%').isDisplayed() + + return !warning && progress + }) + } + + async setAsNSFW () { + const checkbox = await getCheckbox('nsfw') + + return checkbox.click() } async validSecondUploadStep (videoName: string) { - const nameInput = element(by.css('input#name')) - await nameInput.clear() - await nameInput.sendKeys(videoName) + const nameInput = $('input#name') + await nameInput.clearValue() + await nameInput.setValue(videoName) await this.getSecondStepSubmitButton().click() - return browser.wait(browser.ExpectedConditions.urlContains('/watch/')) + return browser.waitUntil(async () => { + return (await browser.getUrl()).includes('/w/') + }) + } + + setAsPublic () { + return selectCustomSelect('privacy', 'Public') + } + + setAsPrivate () { + return selectCustomSelect('privacy', 'Private') } private getSecondStepSubmitButton () { - return element(by.css('.submit-button:not(.disabled) input')) + return $('.submit-container my-button') } }