Only commit raw text after OCR for now.
[redakcja.git] / src / fileupload / static / lib / jQuery-File-Upload-10.32.0 / wdio / test / pages / file-upload.js
1 'use strict'
2
3 /* global browser, $, $$ */
4 /* eslint-disable class-methods-use-this */
5
6 class FileUpload {
7   get fileinput() {
8     return $('.fileinput-button input')
9   }
10   get start() {
11     return $('.fileupload-buttonbar .start')
12   }
13   get toggle() {
14     return $('.fileupload-buttonbar .toggle')
15   }
16   get remove() {
17     return $('.fileupload-buttonbar .delete')
18   }
19   get processing() {
20     return $$('.files .processing')
21   }
22   get uploads() {
23     return $$('.files .template-upload')
24   }
25   get downloads() {
26     return $$('.files .template-download')
27   }
28   get checked() {
29     return $$('.files .toggle:checked')
30   }
31   /**
32    * Opens the file upload form.
33    *
34    * @param {number} [timeout] Wait timeout
35    */
36   async open(timeout) {
37     await browser.url('/')
38     await this.fileinput.waitForExist({ timeout })
39   }
40   /**
41    * Uploads files.
42    *
43    * @param {Array<string>} files Files to upload
44    * @param {number} [timeout] Wait timeout
45    */
46   async upload(files, timeout) {
47     await this.fileinput.addValue(files.join('\n'))
48     await browser.waitUntil(async () => !(await this.processing.length), {
49       timeout
50     })
51     await this.start.click()
52     await browser.waitUntil(async () => !!(await this.downloads.length), {
53       timeout
54     })
55     await browser.waitUntil(async () => !(await this.uploads.length), {
56       timeout
57     })
58   }
59   /**
60    * Deletes uploaded files.
61    *
62    * @param {number} [timeout] Wait timeout
63    */
64   async delete(timeout) {
65     await this.toggle.click()
66     await browser.waitUntil(
67       async () => (await this.downloads.length) === (await this.checked.length),
68       {
69         timeout
70       }
71     )
72     await this.remove.click()
73     await browser.waitUntil(async () => !(await this.downloads.length), {
74       timeout
75     })
76   }
77 }
78
79 module.exports = new FileUpload()