]>
Commit | Line | Data |
---|---|---|
0b33c520 | 1 | import { join } from 'path' |
a9bfa85d | 2 | import { getCheckbox, selectCustomSelect } from '../utils' |
5f92c4dc C |
3 | |
4 | export class VideoUploadPage { | |
d1bd87e0 | 5 | async navigateTo () { |
3419e0e1 | 6 | await $('.header .publish-button').click() |
d1bd87e0 | 7 | |
3419e0e1 | 8 | await $('.upload-video-container').waitForDisplayed() |
5f92c4dc C |
9 | } |
10 | ||
11 | async uploadVideo () { | |
12 | const fileToUpload = join(__dirname, '../../fixtures/video.mp4') | |
d1bd87e0 | 13 | const fileInputSelector = '.upload-video-container input[type=file]' |
84c7cde6 | 14 | const parentFileInput = '.upload-video-container .button-file' |
d1bd87e0 C |
15 | |
16 | // Avoid sending keys on non visible element | |
3419e0e1 C |
17 | await browser.execute(`document.querySelector('${fileInputSelector}').style.opacity = 1`) |
18 | await browser.execute(`document.querySelector('${parentFileInput}').style.overflow = 'initial'`) | |
5f92c4dc | 19 | |
3419e0e1 | 20 | await browser.pause(1000) |
84c7cde6 | 21 | |
3419e0e1 C |
22 | const elem = await $(fileInputSelector) |
23 | await elem.chooseFile(fileToUpload) | |
5f92c4dc C |
24 | |
25 | // Wait for the upload to finish | |
3419e0e1 C |
26 | await browser.waitUntil(async () => { |
27 | const actionButton = this.getSecondStepSubmitButton().$('.action-button') | |
3ec535f7 C |
28 | |
29 | const klass = await actionButton.getAttribute('class') | |
30 | return !klass.includes('disabled') | |
31 | }) | |
5f92c4dc C |
32 | } |
33 | ||
6d210220 | 34 | setAsNSFW () { |
a9bfa85d | 35 | return getCheckbox('nsfw').click() |
6d210220 C |
36 | } |
37 | ||
5f92c4dc | 38 | async validSecondUploadStep (videoName: string) { |
3419e0e1 C |
39 | const nameInput = $('input#name') |
40 | await nameInput.clearValue() | |
41 | await nameInput.setValue(videoName) | |
5f92c4dc C |
42 | |
43 | await this.getSecondStepSubmitButton().click() | |
44 | ||
3419e0e1 C |
45 | return browser.waitUntil(async () => { |
46 | return (await browser.getUrl()).includes('/w/') | |
47 | }) | |
5f92c4dc C |
48 | } |
49 | ||
a9bfa85d C |
50 | setAsPublic () { |
51 | return selectCustomSelect('privacy', 'Public') | |
52 | } | |
53 | ||
5f92c4dc | 54 | private getSecondStepSubmitButton () { |
3419e0e1 | 55 | return $('.submit-container my-button') |
5f92c4dc C |
56 | } |
57 | } |