-
-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve test-support #641
Comments
I also was about to propose this several times. But the mirage route handler are not only needed in
As an alternative we could move adapter for mirage into a separate addon, which could be installed if needed. This would also reduce some of the complexity regarding Mirage and Embroider caused by this route handlers.
Not sure if I would make them part of the public API to be honest. They are adding a lot of complexity while only adding value for some users. I wouldn't be that much concerned about making them public API if moving them out into standalone package before.
As far as I know Mirage does not have a good solution for deferring and manual resolving regular HTTP requests. Does polly.js has one? As per the other points I fear the complexity added to this library, which already has limited maintaining capacities. I guess being able to iterate on such ideas quicker would be another good argument to move it out into a separate package. |
I like the idea of deprecating the mirage handler and providing it through an optional separate addon. If we want we could still manage it from this repo once we convert to monorepo. |
Thanks @jelhan for explaining the reasons around mirage. As I want to start a monorepo as first PR to #642 - this would fit this situation. I've also realized, this is probably too much business logic for providing imperative control for tests. Instead of providing functionality, as there are libraries available to do that already - this should be handled by docs, showing examples how to do that 👍 |
@gossi did you make any progress on tests? Progress calculation is broken after 8.2.0, so we clearly don't have tests that check a real upload flow to catch this. |
No, not invested further than the investigation. But it needs an API that you can programmatically change the state, or make use of |
When working on #620 my new discovered some shortcomings of the current test-support. This is a spin-off of the mentioned PR to discuss ideas to improve it :)
Utilize Test-Support ;)
Currently, the test-support for mirage is part of the public API for production code. It should be moved
test-support
to not pollute prod builds with that chunk of code.Specifically: move
addon/mirage
to somewhere intoaddon-test-support
Multiple Adapters
At the moment,
ember-file-upload
ships with a handler for mirage. Would be nice to have support for polly.js, too.Even better, I think equally imporant are the test-support utilities, such as
extractFormData()
andextractFileMetadata()
. They are very much suitable for integration tests, ie.As I created those tests myself without/prior to knowing those utils exists, they are likely to work with either polly as well as mirage :)
Imperatively Control the Upload Progress
Writing UIs around upload is definitely part of userland code. Giving developers a good way to test their UIs is key. To test what happens in each
file.state
? Usingawait selectFiles()
would skip theuploading
state and would require devs to eitherwaitFor()
of some dom node to appear or set some timeout on the request itself. Both are not reliable and have high potential to cause flaky tests, read more in this discussion.An idea would be to have an imperative API to programmatically advance the
state
and be in control. Basically, a deferred promise - this is shim code:This is a rough idea but I myself have too many questions how to shape the API around that, when and where to allow business logic, etc. My hope is to get the discussion going.
The text was updated successfully, but these errors were encountered: