You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are working on a custom file input component, which mostly rely on native elements with a more refined UI. Unfortunately, we are unable to test the "drag and drop" feature of this component using spectator the way we imagined it.
We managed to reproduce the issue in the following minimalist implementation:
Here is how we fake the file drop (complete reproduction repo is also linked):
it('should emit files when the user drops files',fakeAsync(()=>{constemittedFiles: FileList={length: 1,item(): File|null{returnnewFile([],'newFile.pdf');},};letchangeEventEmitted=false;spectator.element.addEventListener('change',(event)=>{constelement=event.targetasHTMLInputElement;expect(element.files!.length).toEqual(1);expect(element.files!.item(0)).toEqual(emittedFiles[0]);changeEventEmitted=true;});constdragEvent: DragEvent={// @ts-ignoredataTransfer: {files: emittedFiles,},};spectator.triggerEventHandler('input','drop',dragEvent);tick(50);expect(changeEventEmitted).toBeTruthy();}));
Is it related to the way we implemented the test? A limitation in the library?
Thanks for the whole project and in advance for this specific issue, have a nice day :D
Please provide a link to a minimal reproduction of the bug
Is this a regression?
No
Description
Hello!
We are working on a custom file input component, which mostly rely on native elements with a more refined UI. Unfortunately, we are unable to test the "drag and drop" feature of this component using
spectator
the way we imagined it.We managed to reproduce the issue in the following minimalist implementation:
In a browser, it all seems to work just fine:
drop
and the wrapper'schange
events are triggered:change
event is also triggered:However, in the test context, when faking a file drop, only the inner input's
drop
event is trigger, not the wrapper'schange
event:LOG: 'onFilesDrop', Object{dataTransfer: Object{files: Object{length: ..., item: ...}}}
Here is how we fake the file drop (complete reproduction repo is also linked):
Is it related to the way we implemented the test? A limitation in the library?
Thanks for the whole project and in advance for this specific issue, have a nice day :D
Please provide a link to a minimal reproduction of the bug
https://gitlab.com/thomas.ferro/spectator-fake-file-drop-event
Please provide the exception or error you saw
Please provide the environment you discovered this bug in
Anything else?
I will be glad to help resolving this issue if indeed it is due to a bug in the library :)
Do you want to create a pull request?
Yes
The text was updated successfully, but these errors were encountered: