Skip to content

Update ferrum double_click helper to use their API#5588

Open
stefannibrasil wants to merge 1 commit into
rubyforgood:mainfrom
hexdevs:flaky-distributions-test-5573
Open

Update ferrum double_click helper to use their API#5588
stefannibrasil wants to merge 1 commit into
rubyforgood:mainfrom
hexdevs:flaky-distributions-test-5573

Conversation

@stefannibrasil
Copy link
Copy Markdown
Contributor

Closes #5573

This spec was flaky and can be reproduced with the 61044 seed:

Failures:

  1) Distributions Double clicking distribution complete does not result in the distribution attemping to be completed twice
     Failure/Error: expect(page).not_to have_content("Sorry, we encountered an error when trying to mark this distribution as being completed")
       expected not to find text "Sorry, we encountered an error when trying to mark this distribution as being completed" in "User Guide\nDiaper McDiaperface\n \nDashboard\n \nDonations\n \nPurchases\n \nRequests\n \nDistributions\n \nPick Ups & Deliveries\n \nPartner Agencies\n \nInventory\n \nCommunity\n \nReports\nSorry, we encountered an error when trying to mark this distribution as being completed\nDistribution from Test Storage Location to Test Partner\n Home\nDistributions\nTest Partner (05/22/2026)\nID\tSource location:\tAgency representative:\tDelivery method:\tShipping cost:\tComments:\tStatus:\n5\tTest Storage Location\t\tDelivery\t\t\tComplete\nItem\tValue per item\tTotal value\tQuantity\tPackage count\n23Dont test this\t\t\t15\t\nTotal:\t\t\t15\t\n Make a Correction  Print\nHuman Essentials was built with  by Ruby for Good.\nVersion:"

     [Screenshot Image]: /home/runner/work/human-essentials/human-essentials/tmp/capybara/failures_r_spec_example_groups_distributions_2_double_clicking_distribution_complete_does_not_result_in_the_distribution_attemping_to_be_completed_twice_712.png
     # ./spec/system/distribution_system_spec.rb:932:in 'block (2 levels) in <top (required)>'

Using ferrum's double click with the double: mode makes the
test more consistent: https://github.com/rubycdp/ferrum/blob/main/spec/node_spec.rb#L115

The previous code was a solution shared in this issue: rubycdp/ferrum#529 but the maintainer of the gem commented that this wans't accurate. With rubycdp/ferrum#533, the double_click helper was fixed.

This commit updates the custom helper to use the official ferrum API to simulate double clicks, and hopefully it will prevent more flaky specs from happening.

I also reordered the assertions to check for the content in the page before asserting against what's not present.

How Has This Been Tested?

I ran the test several times with a seed from a previous flaky spec run and did not get another flaky spec with this change.

Closes rubyforgood#5573

This spec was flaky and can be reproduced with the 61044 seed:

```
Failures:

  1) Distributions Double clicking distribution complete does not result in the distribution attemping to be completed twice
     Failure/Error: expect(page).not_to have_content("Sorry, we encountered an error when trying to mark this distribution as being completed")
       expected not to find text "Sorry, we encountered an error when trying to mark this distribution as being completed" in "User Guide\nDiaper McDiaperface\n \nDashboard\n \nDonations\n \nPurchases\n \nRequests\n \nDistributions\n \nPick Ups & Deliveries\n \nPartner Agencies\n \nInventory\n \nCommunity\n \nReports\nSorry, we encountered an error when trying to mark this distribution as being completed\nDistribution from Test Storage Location to Test Partner\n Home\nDistributions\nTest Partner (05/22/2026)\nID\tSource location:\tAgency representative:\tDelivery method:\tShipping cost:\tComments:\tStatus:\n5\tTest Storage Location\t\tDelivery\t\t\tComplete\nItem\tValue per item\tTotal value\tQuantity\tPackage count\n23Dont test this\t\t\t15\t\nTotal:\t\t\t15\t\n Make a Correction  Print\nHuman Essentials was built with  by Ruby for Good.\nVersion:"

     [Screenshot Image]: /home/runner/work/human-essentials/human-essentials/tmp/capybara/failures_r_spec_example_groups_distributions_2_double_clicking_distribution_complete_does_not_result_in_the_distribution_attemping_to_be_completed_twice_712.png
     # ./spec/system/distribution_system_spec.rb:932:in 'block (2 levels) in <top (required)>'
```

Using ferrum's double click with the `double: mode` makes the
test more consistent: https://github.com/rubycdp/ferrum/blob/main/spec/node_spec.rb#L115

The previous code was a solution shared in this issue: rubycdp/ferrum#529
but the maintainer of the gem commented that this wans't accurate. With
rubycdp/ferrum#533, the `double_click` helper
was fixed.

This commit updates the custom helper to use the official ferrum
API to simulate double clicks, and hopefully it will prevent
more flaky specs from happening.

I also reordered the assertions to check for the content in the page
before asserting against what's not present.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Flaky spec - Distributions Double clicking distribution complete does not result in the distribution attemping to be completed twice

1 participant