-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
{{link-to}} + click action on component has different behavior in test vs. real usage #14071
Comments
@blimmer the click event bubbles up so to prevent that you could return false, e.g. in the case that a clild element like a I don't think this is a bug, the example app is just handling clicks where it should ignore certain click events. |
That definitely seems to fix the problem. Still a bit concerning that it behaves differently in test vs. in real interaction though. I would expect the test and real interaction to exhibit the same behavior. |
@blimmer yeah when I disable testing on the twiddle I made your original use case is broken. The bubbling behavior works different in test and development environments. You can see the difference by using the app below the test output, the outer click no longer works. |
@rwjblue is this fixed by the use real events testing flag? |
@blimmer @krisselden @rwjblue is this still an issue, perhaps we should close or create a new reproduction of this, what do you think? Perhaps using the testing helpers for v3+ this is a non issue, https://guides.emberjs.com/release/testing/testing-helpers/ |
@pixelhandler I just created a new twiddle with the same logic and the tests are still failing: |
Hmph, I don't actually understand what is going on here. Why doesn't it work? Has anyone dug into it? |
OK, I did a bunch of digging on this to figure out what was going on. When running in "normal" mode (e.g. non-tests) when the button is clicked there is no preexisting run loop, however when running in test mode the Now, you ask why the heck do I care if there is a run loop or not?!, and I agree with you that you shouldn't care. So here goes a semi random series of points:
So, given that information, when ran in tests the Now, outside of tests a slightly different thing is happening. When the tldr; this isn't really a bug (though there are a few things to be done to make it better), and you should use |
I noticed this difference between the actually using the app vs. in test. In this case, I have a button inside a component that goes to a different route than the component itself. We could argue about the UX, but that's another story. If you interact with the real component, clicking the button goes to a different route, but this behavior is different in test.
Twiddle with test showing the problem
I wasn't sure if this should be filed here or in the ember-test-helpers project, so please let me know if this isn't the right place and I'll happily file elsewhere.
The text was updated successfully, but these errors were encountered: