Cleanup, fix acceptance tests

This commit is contained in:
Artur Paikin 2016-06-02 02:20:01 -04:00
parent 62825e81ac
commit e2cda3a1b5
6 changed files with 21 additions and 84 deletions

View file

@ -133,6 +133,7 @@ export default class DragDrop extends Plugin {
type="file"
name="files[]"
multiple="true"
value=""
onchange=${this.handleInputChange.bind(this)} />
<label class="UppyDragDrop-label" onclick=${onSelect}>
<strong>${this.core.i18n('chooseFile')}</strong>

View file

@ -18,20 +18,27 @@ export default class Formtag extends Plugin {
// Merge default options with the ones set by user
this.opts = Object.assign({}, defaultOptions, opts)
this.render = this.render.bind(this)
}
handleInputChange (ev) {
this.core.log('All right, something selected through input...')
// this added rubbish keys like “length” to the resulting array
//
// const files = Object.keys(ev.target.files).map((key) => {
// return ev.target.files[key]
// })
this.core.emitter.emit('file-add', {
plugin: this,
acquiredFiles: Utils.toArray(ev.target.files)
const files = Utils.toArray(ev.target.files)
files.forEach((file) => {
this.core.emitter.emit('file-add', {
source: this.id,
name: file.name,
type: file.type,
data: file
})
})
}
@ -47,7 +54,8 @@ export default class Formtag extends Plugin {
type="file"
name="files[]"
onchange=${this.handleInputChange.bind(this)}
multiple="${this.opts.multipleFiles ? 'true' : 'false'}">
multiple="${this.opts.multipleFiles ? 'true' : 'false'}"
value="">
${!this.core.opts.autoProceed && this.opts.target.name !== 'Modal'
? yo`<button class="UppyForm-uploadBtn UppyNextBtn"
type="submit"
@ -59,8 +67,9 @@ export default class Formtag extends Plugin {
}
install () {
this.el = this.render(this.core.state)
this.target = this.getTarget(this.opts.target, this, this.el, this.render.bind(this))
const target = this.opts.target
const plugin = this
this.target = this.mount(target, plugin)
}
// run (results) {

View file

@ -1,74 +0,0 @@
import Utils from '../core/Utils'
import yo from 'yo-yo'
/**
* Independent Dummy
*
*/
export default class Dummy {
constructor (core, opts) {
// super(core, opts)
this.type = 'acquirer'
this.id = 'Dummy'
this.title = 'Dummy'
this.core = core
// set default options
const defaultOptions = {}
this.strange = yo`<h1>this is strange 1</h1>`
// merge default options with the ones set by user
this.opts = Object.assign({}, defaultOptions, opts)
}
getTarget (target, caller, el, render) {
const callerPluginName = Utils.getFnName(caller.constructor)
if (typeof target === 'string') {
this.core.log(`Installing ${callerPluginName} to ${target}`)
// clear everything inside the target selector
// if (replaceTargetContent) {
// document.querySelector(target).innerHTML = ''
// }
document.querySelector(target).appendChild(el)
return target
} else {
const targetPluginName = Utils.getFnName(target)
this.core.log(`Installing ${callerPluginName} to ${targetPluginName}`)
let targetPlugin = this.core.getPlugin(targetPluginName)
let selectorTarget = targetPlugin.addTarget(caller, render)
return selectorTarget
}
}
update () {
}
render () {
const bla = yo`<h2>this is strange 2</h2>`
return yo`
<div class="wow-this-works">
<input type="text" value="hello">
I am a dummy plugin, look at me, I was rendered in a modal! Thats crazy, I know.
${this.strange}
${bla}
</div>
`
}
focus () {
const firstInput = document.querySelector(`${this.target} *:input[type!=hidden]:first`)
firstInput.focus()
}
install () {
this.el = this.render()
document.body.appendChild(this.el)
this.target = this.getTarget(this.opts.target, this, this.el, this.render.bind(this))
}
}

View file

@ -19,6 +19,8 @@ export default class ProgressBar extends Plugin {
// merge default options with the ones set by user
this.opts = Object.assign({}, defaultOptions, opts)
this.render = this.render.bind(this)
}
render (state) {

View file

@ -10,7 +10,7 @@ function uppySelectFakeFile () {
{type: 'image/svg+xml'}
)
blob['name'] = 'myDumbSVG'
window.UppyAddFiles([blob], 'smth')
window.UppyAddFile([blob], 'smth')
}
// https://wiki.saucelabs.com/display/DOCS/Annotating+Tests+with+Selenium's+JavaScript+Executor

View file

@ -1,5 +1,5 @@
import Uppy from 'uppy/core'
import { Formtag, Multipart, Tus10, ProgressBar } from 'uppy/plugins'
import { Formtag, Multipart, ProgressBar } from 'uppy/plugins'
const uppy = new Uppy({debug: true, autoProceed: false})
@ -11,7 +11,6 @@ uppy
fieldName: 'files[]'
})
.use(ProgressBar, {target: 'body'})
// .use(Tus10, {endpoint: 'http://master.tus.io:8080/files/'})
.run()
console.log('Uppy ' + uppy.type + ' loaded')