X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fe2e%2Fsrc%2Fpo%2Fvideo-upload.po.ts;h=38395ea2f0b4ed81d44184a5aef24461f4ea924a;hb=c3edc5b074aa4bb1861ed0a94d3713808e87170f;hp=a248912edb55f0b14b7515173e5f14331d617518;hpb=cf21b2cbef61929177b9c09b5e017c3b7eb8535d;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 a248912ed..38395ea2f 100644 --- a/client/e2e/src/po/video-upload.po.ts +++ b/client/e2e/src/po/video-upload.po.ts @@ -1,50 +1,66 @@ -import { browser, by, element } from 'protractor' -import { FileDetector } from 'selenium-webdriver/remote' import { join } from 'path' +import { getCheckbox, selectCustomSelect } from '../utils' export class VideoUploadPage { async navigateTo () { - await element(by.css('.header .publish-button')).click() + const publishButton = await $('.header .publish-button') - return browser.wait(browser.ExpectedConditions.visibilityOf(element(by.css('.upload-video-container')))) + 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.executeScript(`document.querySelector('${fileInputSelector}').style.opacity = 1`) - await browser.executeScript(`document.querySelector('${parentFileInput}').style.overflow = 'initial'`) + await browser.execute(`document.querySelector('${fileInputSelector}').style.opacity = 1`) + await browser.execute(`document.querySelector('${parentFileInput}').style.overflow = 'initial'`) - await browser.sleep(1000) + await browser.pause(1000) - const elem = element(by.css(fileInputSelector)) - await elem.sendKeys(fileToUpload) + const elem = await $(fileInputSelector) + await elem.chooseFile(fileToUpload) // Wait for the upload to finish - await browser.wait(async () => { - const actionButton = this.getSecondStepSubmitButton().element(by.css('.action-button')) + await browser.waitUntil(async () => { + const warning = await $('=Publish will be available when upload is finished').isDisplayed() + const progress = await $('.progress-bar=100%').isDisplayed() - const klass = await actionButton.getAttribute('class') - return !klass.includes('disabled') + 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('/w/')) + 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-container my-button')) + return $('.submit-container my-button') } }