-
-
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
Tentative fix for flaky specs #3141
Tentative fix for flaky specs #3141
Conversation
This is passing, I rerun this workflow several times and it is always green (first failure is due to a force push, not a real failure). I think we can try to merge this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ran the spec several times locally with no failures whatsoever, 🙏
It failed again on the CI :( https://circleci.com/gh/nebulab/solidus/1625#tests/containers/1 |
By looking at the last failure on CircleCI it's evident what happens: The page fails in this state (at least when the screenshot is taken): and the failure says:
This is the failing code: solidus/core/lib/spree/testing_support/capybara_ext.rb Lines 93 to 98 in 7ca285d
|
55618c9
to
e49cde5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 This works for now.
By checking that select2 has correctly been updated before submitting the form, we ensure that we are passing the right data to the server. I also update the portion of the page where we look for the flash message so it will check for it after the element will be visible on the page (it is displayed after page load with js).
It looks like sometimes active is not recognized as a real method of Spree::StockLocation::ActiveRecord_Relation. Here's an example of the flaky spec failing: https://circleci.com/gh/nebulab/solidus/1701
e49cde5
to
967e2f5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for the select2 fixes. This library causes so many troubles. We really should think about removing it sooner or later.
The second spec should be rewritten IMO
|
||
without_partial_double_verification do | ||
expect(stock_locations).to receive(:active) { active_stock_locations } | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I am not a huge fan of these kind of specs. Could we rewrite the spec into something that actually test the result instead of stubbing the implementation?
Create two stock locations, one active, one not. Expect the active one is the result.
+1 for getting rid of select2. Something I'd love to tackle if I had the time. |
@jacobherrington Awesome! keep in mind, though, that we already only using select2 for multiple selects and autocomplete. Normal selects are already browser selects. John looked into an alternative, but didn’t finished his work. |
In order to avoid stubbing the implementation. This could have benefits in terms of speed but everything is more complex to read and it's causing flaky specs in combination with verifying partial doubles.
This is not releated with this PR but I think we should change this code here to discourage adopting a practice that we don't want to see into other specs.
@tvdeyen I've done the suggested changes to specs. I also changed Stock Location Sorter specs that I wrongly used as a reference when writing these ones. |
Aaaaand... there's another flaky: https://circleci.com/gh/nebulab/solidus/1726#tests/containers/2 |
These feature specs are all written very poorly. One does not expect database changes in a feature spec. One expects changes in the request outcome (html). This particular one should be easily fixed by waiting for a string present on the screen before making that assertion about a change in the database (that happen in another thread and therefore can’t be predictable) |
fc8e82f
to
b5529d3
Compare
They rely on the database to be filled to check things happened correctly. This is a bad practice and we can easily check the same thing by checking the output of the page. This should fix this flaky spec: https://circleci.com/gh/nebulab/solidus/1726#tests/containers/2
b5529d3
to
b7b918a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome. Thank you!
Description
This PR is an attempt to fix flaky specs:
For more info it's better to take a look at individual commits.
Checklist: