emberjs / emberjs/ember-test-helpers
triggerEvent for a "change" event for a file input does not set the value of the input correctly
- Dominant language
- JavaScript
- Stars
- 188
- Forks
- 254
- PR merge metrics
- No merged PRs in 30d
Description
My app relies on the buildt-in native browser constraint validation API, which uses the value of the input.
Facing an issue with a test with the value of a file input (``) being empty ('') after triggering a file upload using triggerEvent, which makes the validation fail
```
const file = new Blob(['candidate referral with resume upload'],
{ type: 'application/pdf' }
);
file.name = 'Foo-bar.pdf';
await triggerEvent(SELECTORS.FILE_INPUT, 'change',
{ files: [file] }
);
```
there seems to be a problem with `triggerEvent` helper, which does not properly set the value of the input
I also tried passing in additional options, but this has not helped:
```
await triggerEvent(SELECTORS.FILE_INPUT, 'change', {
files: [file],
srcElement : { value: 'C:\\fakepath\\Foo-bar.pdf' },
target : { value: 'C:\\fakepath\\Foo-bar.pdf' }
});
```
Steps to reproduce the problem:
- create a test with a file input;
- trigger a change event using `triggerEvent`
- check the value of the input and observing that it's empty
Contributor guide
Assessment
This issue has not been assessed yet.