Sha256: 5c3de75a43741f88012eb1d55a1d44dd8bf88b78668672dbe667ffea97133db9

Contents?: true

Size: 1.77 KB

Versions: 15

Compression:

Stored size: 1.77 KB

Contents

'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<string>} 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()

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
card-mod-format-0.18.1 vendor/jquery_file_upload/wdio/test/pages/file-upload.js
card-mod-format-0.18.0 vendor/jquery_file_upload/wdio/test/pages/file-upload.js
card-mod-format-0.17.0 vendor/jquery_file_upload/wdio/test/pages/file-upload.js
card-mod-format-0.16.0 vendor/jquery_file_upload/wdio/test/pages/file-upload.js
card-mod-format-0.15.6 vendor/jquery_file_upload/wdio/test/pages/file-upload.js
card-mod-format-0.15.5 vendor/jquery_file_upload/wdio/test/pages/file-upload.js
card-mod-format-0.15.4 vendor/jquery_file_upload/wdio/test/pages/file-upload.js
card-mod-format-0.15.3 vendor/jquery_file_upload/wdio/test/pages/file-upload.js
card-mod-format-0.15.2.pre1 vendor/jquery_file_upload/wdio/test/pages/file-upload.js
card-mod-format-0.15.1.1 vendor/jquery_file_upload/wdio/test/pages/file-upload.js
card-mod-format-0.15.1 vendor/jquery_file_upload/wdio/test/pages/file-upload.js
card-mod-format-0.15.0 vendor/jquery_file_upload/wdio/test/pages/file-upload.js
card-mod-script-0.14.2 vendor/jquery_file_upload/wdio/test/pages/file-upload.js
card-mod-script-0.14.1 vendor/jquery_file_upload/wdio/test/pages/file-upload.js
card-mod-script-0.14.0 vendor/jquery_file_upload/wdio/test/pages/file-upload.js