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

[BUG]: Flaky test in children_served_report_service_spec.rb #4297

Closed
elasticspoon opened this issue Apr 21, 2024 · 2 comments
Closed

[BUG]: Flaky test in children_served_report_service_spec.rb #4297

elasticspoon opened this issue Apr 21, 2024 · 2 comments
Labels

Comments

@elasticspoon
Copy link
Collaborator

elasticspoon commented Apr 21, 2024

See #4273 (comment) for full discussion.

rspec ./spec/services/reports/children_served_report_service_spec.rb[1:2:1] --seed 56095 fails on main.
rspec ./spec/services/reports/children_served_report_service_spec.rb --seed 11104 passes.

The test is flaky, it is likely related to the items that are getting created when new kits are created by factory bot in the test. Most likely some of the BaseItem are getting counted as disposables since they sometimes have "Diaper" in their names. We can also tell that the seeded items are the issue since destroying all the items at the start of the test fixes the issue.

To fix this you will need to change

      toddler_disposable_kit = create(:kit, :with_item, organization: organization)
      infant_disposable_kit = create(:kit, :with_item, organization: organization)
      infant_cloth_kit = create(:kit, :with_item, organization: organization)

to ensure that those items do not have diaper in their names (i think 🙂 ).

@cielf
Copy link
Collaborator

cielf commented Apr 22, 2024

I was pondering this, and I'm wondering if what we should do is have the generic Item base off of a 'neutral' base item -- one that doesn't fit in to any of the categories for now. Then it's not going to get counted in on any of the scopes, or in with the diapers or period supplies or adult incontinence for the kits.
or the generic test kit should have no items -- but I suspect we disallow empty kits on validation.

@dorner
Copy link
Collaborator

dorner commented Apr 25, 2024

I'd rather fix this with our bigger push to stop relying on seeded / randomized data for our tests. In this case, if we care what the type of item is, we need to specify it when we create it.

elasticspoon added a commit to elasticspoon/human-essentials that referenced this issue Apr 25, 2024
Changes the test to explicitly create all the items needed. This removes
flakiness surrounding potential situations where generated items get
counted as disposable.
elasticspoon added a commit to elasticspoon/human-essentials that referenced this issue Apr 25, 2024
Changes the test to explicitly create all the items needed. This removes
flakiness surrounding potential situations where generated items get
counted as disposable.
dorner pushed a commit that referenced this issue Apr 26, 2024
Changes the test to explicitly create all the items needed. This removes
flakiness surrounding potential situations where generated items get
counted as disposable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants