-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
RfC: Work around inconsistent button click in promotion order spec #5782
Conversation
b3802d3
to
75382c5
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5782 +/- ##
=======================================
Coverage 88.71% 88.71%
=======================================
Files 712 712
Lines 16893 16895 +2
=======================================
+ Hits 14987 14989 +2
Misses 1906 1906 ☔ View full report in Codecov by Sentry. |
75382c5
to
60fe006
Compare
e87aa77
to
97121d5
Compare
97121d5
to
b9493da
Compare
It's cumbersome to find elements by CSS selectors to click them, and the new admin has a few instances where we have no standalone label.
Apparently, `find_button(...).click` will not consistently wait for the Javascript imported via importmaps to be loaded before execution. This adds a Controller that adds a data attribute to the body element of the page once it connects. This way we know the Stimulus controllers have loaded before testing their behavior in feature specs. See https://gist.github.com/adrienpoly/862846f5882796fdeb4fc85b260b3c5a for a similar solution. I am not a big fan of adding production code just to get specs stable, but this is the only solution I found that reliably works.
I'm getting a code coverage issue because the `ensure_js_is_ready` helper is only used in the `solidus_leagcy_promotions`. Adding a spec here for filtering by payment state.
b9493da
to
46888aa
Compare
We need to wait for the JS to be loaded and connected here, otherwise the click doesn't do anything. There is an alternative fix for this in solidusio#5782
This will keep clicking the Filter button until the promotions menu appears. The problem this fixes is that a few milliseconds after navigation, the JS controller that switches the filter bar out might not have loaded. Alternative fixes here: solidusio#5782 solidusio#5783
I'm keeping this open to see how folks feel about it. We can't keep adding |
Thanks for taking the time here @mamhoff, I've also tried multiple times to fix this spec, without success. If we can't find an "elegant" solution, may I suggest to use the flaky tag on the test? It will retry it a couple of times, making it transparent for us. Not great, but it won't slow us down at least. |
Apparently,
find_button(...).click
will not consistently wait for theStimulus JS to be loaded. This adds a small controller that simply
changes an attribute on the body, and expects that to be present before
running any feature specs.
See https://gist.github.com/adrienpoly/862846f5882796fdeb4fc85b260b3c5a
for inspiration.
I don't love to introduce code into the production build to get the tests stable, but I haven't found another good option that worked.