]>
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 () { |
ace01da3 | 6 | const publishButton = await $('.root-header .publish-button') |
3c065fe3 C |
7 | |
8 | await publishButton.waitForClickable() | |
9 | await publishButton.click() | |
d1bd87e0 | 10 | |
3419e0e1 | 11 | await $('.upload-video-container').waitForDisplayed() |
5f92c4dc C |
12 | } |
13 | ||
814e9e07 C |
14 | async uploadVideo (fixtureName: 'video.mp4' | 'video2.mp4' | 'video3.mp4') { |
15 | const fileToUpload = join(__dirname, '../../fixtures/' + fixtureName) | |
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 | |
3419e0e1 C |
20 | await browser.execute(`document.querySelector('${fileInputSelector}').style.opacity = 1`) |
21 | await browser.execute(`document.querySelector('${parentFileInput}').style.overflow = 'initial'`) | |
5f92c4dc | 22 | |
3419e0e1 | 23 | await browser.pause(1000) |
84c7cde6 | 24 | |
3419e0e1 C |
25 | const elem = await $(fileInputSelector) |
26 | await elem.chooseFile(fileToUpload) | |
5f92c4dc C |
27 | |
28 | // Wait for the upload to finish | |
3419e0e1 | 29 | await browser.waitUntil(async () => { |
3c065fe3 C |
30 | const warning = await $('=Publish will be available when upload is finished').isDisplayed() |
31 | const progress = await $('.progress-bar=100%').isDisplayed() | |
3ec535f7 | 32 | |
3c065fe3 | 33 | return !warning && progress |
3ec535f7 | 34 | }) |
5f92c4dc C |
35 | } |
36 | ||
3c065fe3 C |
37 | async setAsNSFW () { |
38 | const checkbox = await getCheckbox('nsfw') | |
814e9e07 | 39 | await checkbox.waitForClickable() |
3c065fe3 C |
40 | |
41 | return checkbox.click() | |
6d210220 C |
42 | } |
43 | ||
5f92c4dc | 44 | async validSecondUploadStep (videoName: string) { |
3419e0e1 C |
45 | const nameInput = $('input#name') |
46 | await nameInput.clearValue() | |
47 | await nameInput.setValue(videoName) | |
5f92c4dc | 48 | |
814e9e07 C |
49 | const button = this.getSecondStepSubmitButton() |
50 | await button.waitForClickable() | |
51 | ||
52 | await button.click() | |
5f92c4dc | 53 | |
3419e0e1 C |
54 | return browser.waitUntil(async () => { |
55 | return (await browser.getUrl()).includes('/w/') | |
56 | }) | |
5f92c4dc C |
57 | } |
58 | ||
a9bfa85d C |
59 | setAsPublic () { |
60 | return selectCustomSelect('privacy', 'Public') | |
61 | } | |
62 | ||
3c065fe3 C |
63 | setAsPrivate () { |
64 | return selectCustomSelect('privacy', 'Private') | |
65 | } | |
66 | ||
5f92c4dc | 67 | private getSecondStepSubmitButton () { |
3419e0e1 | 68 | return $('.submit-container my-button') |
5f92c4dc C |
69 | } |
70 | } |