I'd like to create a basic acceptance test in ember that uploads a file.
I can mock the server with Pretender, but I need to know how to fill the input type="file"
field with a file from my filesystem. So the questions are basically:
fillIn
helper?Rails.root
for this purpose.I solved it differently: I don't upload a file from the file system, but create a Blob manually and use triggerHandler on the input element:
let inputElement = $('input[type=file]');
let blob = new Blob(['foo', 'bar'], {type: 'text/plain'});
blob.name = 'foobar.txt';
inputElement.triggerHandler({
type: 'change',
target: {
files: {
0: blob,
length: 1,
item() { return blob; }
}
}
});
This triggers the upload.