3 /* global browser, $, $$ */
4 /* eslint-disable class-methods-use-this */
8 return $('.fileinput-button input')
11 return $('.fileupload-buttonbar .start')
14 return $('.fileupload-buttonbar .toggle')
17 return $('.fileupload-buttonbar .delete')
20 return $$('.files .processing')
23 return $$('.files .template-upload')
26 return $$('.files .template-download')
29 return $$('.files .toggle:checked')
32 * Opens the file upload form.
34 * @param {number} [timeout] Wait timeout
37 await browser.url('/')
38 await this.fileinput.waitForExist({ timeout })
43 * @param {Array<string>} files Files to upload
44 * @param {number} [timeout] Wait timeout
46 async upload(files, timeout) {
47 await this.fileinput.addValue(files.join('\n'))
48 await browser.waitUntil(async () => !(await this.processing.length), {
51 await this.start.click()
52 await browser.waitUntil(async () => !!(await this.downloads.length), {
55 await browser.waitUntil(async () => !(await this.uploads.length), {
60 * Deletes uploaded files.
62 * @param {number} [timeout] Wait timeout
64 async delete(timeout) {
65 await this.toggle.click()
66 await browser.waitUntil(
67 async () => (await this.downloads.length) === (await this.checked.length),
72 await this.remove.click()
73 await browser.waitUntil(async () => !(await this.downloads.length), {
79 module.exports = new FileUpload()