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 family requests system spec #4867

Merged

Conversation

coalest
Copy link
Collaborator

@coalest coalest commented Dec 18, 2024

Doesn't resolve any issue, although related to #4557.

Description

This system spec is known to be flaky. See this comment.

Example failure: https://github.com/rubyforgood/human-essentials/actions/runs/12392348304/job/34591567923#step:7:552

Example output:

Failures:

  1) Family requests for children with different items, from different families it creates family requests
     Failure/Error: expect(row).to have_css("td", text: "Item 2, Item 3")
       expected to find visible css "td" with text "Item 2, Item 3" within #<Capybara::Node::Element tag="tr" path="//HTML[1]/BODY[1]/DIV[1]/DIV[1]/SECTION[2]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/FORM[1]/DIV[1]/TABLE[1]/TBODY[1]/TR[3]"> but there were no matches. Also found "Main Family", "Main Items2", "Item 3, Item 2", "Include This Child?", which matched the selector but not all filters. 

     [Screenshot Image]: /home/runner/work/human-essentials/human-essentials/tmp/capybara/failures_r_spec_example_groups_family_requests_for_children_with_different_items_from_different_families_it_creates_family_requests_611.png


     # ./spec/system/partners/family_requests_system_spec.rb:38:in `block (4 levels) in <top (required)>'
     # ./spec/system/partners/family_requests_system_spec.rb:35:in `block (3 levels) in <top (required)>'

Proposed reason behind flakiness:
We are expecting the requested items (Items Needed column) for each child to be in a certain order.
But in the view we are calling child.requested_item_ids to fetch the items which doesn't specify an ORDER BY clause (nor do we sort the items in Ruby), as you can see from development logs:

image
or from Rails console:

Screenshot from 2024-12-18 14-02-38

Type of change

  • Internal

How Has This Been Tested?

I retried this spec 10+ times locally and wasn't and wasn't able to reproduce the failure.
But I changed the order of the requested_item_ids for the partners_child factories and the test still passes afterwards, so I think this will fix the issue.

Screenshots

Which page we are testing for reference:
Screenshot from 2024-12-18 14-21-22

Copy link
Collaborator

@dorner dorner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Love these fixes!

@dorner dorner merged commit 0a2dafc into rubyforgood:main Dec 19, 2024
11 checks passed
Copy link
Contributor

@coalest: Your PR Fix flaky family requests system spec is part of today's Human Essentials production release: 2024.12.22.
Thank you very much for your contribution!

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.

2 participants