Skip to content

fix(api): await every seeded dog in the suggestion preference tests - #297

Merged
GSTJ merged 1 commit into
mainfrom
fix/api-suggestion-test-race
Sep 7, 2026
Merged

fix(api): await every seeded dog in the suggestion preference tests#297
GSTJ merged 1 commit into
mainfrom
fix/api-suggestion-test-race

Conversation

@GSTJ

@GSTJ GSTJ commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Summary

The color and size preference tests in the suggestion service suite raced against their own fixture setup, so they sometimes counted dogs that had not finished being created yet.

Details

  • Both tests placed a batch of Array.from({ length }).map(...) promises as a single array element inside Promise.all, instead of spreading them, so Promise.all did not wait for that batch to resolve.
  • Spread the batches with ...Array.from(...) so every seeded dog is awaited before the assertions run.
  • Checked the age preference test as well. It derives birth dates from new Date() in JS while the service compares ages using SQL NOW(), so there is a theoretical year boundary gap between the two. The service has no injectable clock to pin against, so this is left as is; the gap only matters if the suite happens to run at the exact moment a fixture crosses a year mark, which is not the source of the observed flakiness.

Testing steps

  1. Open the suggestion service test file for the api package.
  2. Run the suggestion service tests five times in a row using the tracked test environment file.
  3. Confirm all tests pass every time, including the color and size preference tests.

Screenshots

Not applicable

@GSTJ
GSTJ merged commit f16737b into main Sep 7, 2026
16 checks passed
@GSTJ
GSTJ deleted the fix/api-suggestion-test-race branch September 7, 2026 10:22
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.

1 participant