Deflake ScheduleGeneratorTest — unseeded random dish selection #63
Labels
No labels
app
backlog
bug
ci-cd
contribution welcome
duplicate
enhancement
good first issue
help wanted
question
testing
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lvl0/dishplanner#63
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
tests/Unit/Schedule/ScheduleGeneratorTest.php::test_it_takes_minimum_recurrences_into_accountfails intermittently:at
tests/Unit/Schedule/ScheduleGeneratorTest.php:138.Observed 5 green / 1 red across six runs on an identical tree (2026-08-20, during the #55 flow). It is not a regression — it reproduces without any code change.
Root cause
Schedule generation picks dishes with unseeded
->random():RegenerateScheduleForDateForUsersAction.php:33RegenerateScheduleDayForUserAction.php:28,45DraftScheduleForDateAction.php:22GenerateScheduleForMonthAction.php:90The test fixture creates two dishes — one plain, one with a
MinimumRecurrence. The test then asserts the recurring dish landed on more than one date so it can measure spacing between occurrences. With two candidates and no seeded RNG, whether the recurring dish is chosen twice is effectively a coin flip, so$recurringDates->count()is sometimes exactly 1 and the assertion trips.The assertion is guarding against this case correctly — it is guarding by failing, rather than the outcome being made deterministic.
Note
c3a5532 60 - Make schedule test assertion counts deterministicalready addressed this same class of flakiness in this same file, so this is a second pass at a known problem area rather than a new discovery.Suggested approaches
Not prescriptive — whichever fits the subsystem best:
Acceptance