]>
Commit | Line | Data |
---|---|---|
0b33c520 | 1 | import { browser, by, element } from 'protractor' |
2e8e97f3 | 2 | import { FileDetector } from 'selenium-webdriver/remote' |
0b33c520 | 3 | import { join } from 'path' |
5f92c4dc C |
4 | |
5 | export class VideoUploadPage { | |
d1bd87e0 | 6 | async navigateTo () { |
6b88559b | 7 | await element(by.css('.header .publish-button')).click() |
d1bd87e0 C |
8 | |
9 | return browser.wait(browser.ExpectedConditions.visibilityOf(element(by.css('.upload-video-container')))) | |
5f92c4dc C |
10 | } |
11 | ||
12 | async uploadVideo () { | |
2e8e97f3 C |
13 | browser.setFileDetector(new FileDetector()) |
14 | ||
5f92c4dc | 15 | const fileToUpload = join(__dirname, '../../fixtures/video.mp4') |
d1bd87e0 | 16 | const fileInputSelector = '.upload-video-container input[type=file]' |
84c7cde6 | 17 | const parentFileInput = '.upload-video-container .button-file' |
d1bd87e0 C |
18 | |
19 | // Avoid sending keys on non visible element | |
20 | await browser.executeScript(`document.querySelector('${fileInputSelector}').style.opacity = 1`) | |
d1bd87e0 | 21 | await browser.executeScript(`document.querySelector('${parentFileInput}').style.overflow = 'initial'`) |
5f92c4dc | 22 | |
84c7cde6 C |
23 | await browser.sleep(1000) |
24 | ||
d1bd87e0 C |
25 | const elem = element(by.css(fileInputSelector)) |
26 | await elem.sendKeys(fileToUpload) | |
5f92c4dc C |
27 | |
28 | // Wait for the upload to finish | |
3ec535f7 C |
29 | await browser.wait(async () => { |
30 | const actionButton = this.getSecondStepSubmitButton().element(by.css('.action-button')) | |
31 | ||
32 | const klass = await actionButton.getAttribute('class') | |
33 | return !klass.includes('disabled') | |
34 | }) | |
5f92c4dc C |
35 | } |
36 | ||
37 | async validSecondUploadStep (videoName: string) { | |
38 | const nameInput = element(by.css('input#name')) | |
39 | await nameInput.clear() | |
40 | await nameInput.sendKeys(videoName) | |
41 | ||
42 | await this.getSecondStepSubmitButton().click() | |
43 | ||
a1eda903 | 44 | return browser.wait(browser.ExpectedConditions.urlContains('/w/')) |
5f92c4dc C |
45 | } |
46 | ||
47 | private getSecondStepSubmitButton () { | |
1ef7f323 | 48 | return element(by.css('.submit-container my-button')) |
5f92c4dc C |
49 | } |
50 | } |