X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/8b04ced586931e1dd6b4759c2b972a01d877fe03..f067862049a3be1faa5ff1a2535ea6362cea23de:/src/fileupload/static/lib/jQuery-File-Upload-10.32.0/wdio/test/pages/file-upload.js diff --git a/src/fileupload/static/lib/jQuery-File-Upload-10.32.0/wdio/test/pages/file-upload.js b/src/fileupload/static/lib/jQuery-File-Upload-10.32.0/wdio/test/pages/file-upload.js new file mode 100644 index 00000000..32ba5c39 --- /dev/null +++ b/src/fileupload/static/lib/jQuery-File-Upload-10.32.0/wdio/test/pages/file-upload.js @@ -0,0 +1,79 @@ +'use strict' + +/* global browser, $, $$ */ +/* eslint-disable class-methods-use-this */ + +class FileUpload { + get fileinput() { + return $('.fileinput-button input') + } + get start() { + return $('.fileupload-buttonbar .start') + } + get toggle() { + return $('.fileupload-buttonbar .toggle') + } + get remove() { + return $('.fileupload-buttonbar .delete') + } + get processing() { + return $$('.files .processing') + } + get uploads() { + return $$('.files .template-upload') + } + get downloads() { + return $$('.files .template-download') + } + get checked() { + return $$('.files .toggle:checked') + } + /** + * Opens the file upload form. + * + * @param {number} [timeout] Wait timeout + */ + async open(timeout) { + await browser.url('/') + await this.fileinput.waitForExist({ timeout }) + } + /** + * Uploads files. + * + * @param {Array} files Files to upload + * @param {number} [timeout] Wait timeout + */ + async upload(files, timeout) { + await this.fileinput.addValue(files.join('\n')) + await browser.waitUntil(async () => !(await this.processing.length), { + timeout + }) + await this.start.click() + await browser.waitUntil(async () => !!(await this.downloads.length), { + timeout + }) + await browser.waitUntil(async () => !(await this.uploads.length), { + timeout + }) + } + /** + * Deletes uploaded files. + * + * @param {number} [timeout] Wait timeout + */ + async delete(timeout) { + await this.toggle.click() + await browser.waitUntil( + async () => (await this.downloads.length) === (await this.checked.length), + { + timeout + } + ) + await this.remove.click() + await browser.waitUntil(async () => !(await this.downloads.length), { + timeout + }) + } +} + +module.exports = new FileUpload()