Skip to content
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

Fix flaky cost_entries/add_cost_entry_spec.rb spec #17714

Merged

Conversation

cbliard
Copy link
Member

@cbliard cbliard commented Jan 24, 2025

Flaky spec was ./modules/costs/spec/features/cost_entries/add_cost_entry_spec.rb:114 It was failing for instance in https://github.com/opf/openproject/actions/runs/12934263465/job/36078482478

The flakiness is due to the js on the page not working until the spent_on date field is fully loaded. When the unit cost values are input, when the js is not working, then the computed "Costs" value is not updated, and so the test fails.

The fix is simple: wait for the spent_on date field to be loaded with page.has_field?(CostEntry.human_attribute_name(:spent_on)).

Then I refactored things a bit to remove some duplicate code and use some accessible selectors instead of css selectors.

And disabled a cop which never made sense to me anyway.

Flaky spec was `./modules/costs/spec/features/cost_entries/add_cost_entry_spec.rb:114`
It was failing for instance in https://github.com/opf/openproject/actions/runs/12934263465/job/36078482478

The flakiness is due to the js on the page not working until the
spent_on date field is fully loaded. When the unit cost values are
input, when the js is not working, then the computed "Costs" value is
not updated, and so the test fails.

The fix is simple: wait for the spent_on date field to be loaded with
`page.has_field?(CostEntry.human_attribute_name(:spent_on))`.

Then I refactored things a bit to remove some duplicate code and use
some accessible selectors instead of css selectors.
@cbliard cbliard merged commit d697f86 into dev Jan 24, 2025
8 of 9 checks passed
@cbliard cbliard deleted the fix-flaky/wait-for-log-unit-costs-page-to-be-fully-loaded branch January 24, 2025 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants