Repository navigation
Conversation
…uler The libraryListRecheck* tests flaked with UncompletedCoroutinesError on CI and locally. Each mock response resumed LibrariesViewModel on an IO thread, so a library load could finish concurrently with the test's next refreshLibraryList(): the call saw the old job still active, queued a re-check the finishing loop never ran, and the test waited a minute for a request that never came. The app runs this on one main thread, so only the test was racy. Run these tests' mock engine on the test scheduler. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe library ViewModel test fixture now accepts an optional dispatcher for mock-engine work. Four library-list recheck tests provide a ChangesLibrary ViewModel test dispatcher
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Other Suggested reviewers: Merge Risk: ⚪ Minimal · up to This change only affects unit tests, so users see no behavior change. It makes the library recheck tests less likely to fail intermittently, and there is no merge-blocking risk. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1⚔️ Resolve merge conflicts 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
pickAnotherReplacesThePickWithAFullCountdownAndStopEndsTheShuffle flaked: the new pick and its reset countdown are published in two updates, and the skip response resumes the view model off the test thread, so the test could see the new episode while the countdown still held the old value. Wait for both. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Problem
Related issue: N/A
Validation tasks: none
Two phone unit tests fail intermittently and block unrelated pull requests:
LibrariesViewModelTest.libraryListRecheck*(from fix(libraries): re-check the library list when the Libraries tab resumes #487) time out withUncompletedCoroutinesErrorafter a minute. They failed on the last CI run of fix(tv): show mixed libraries in movie and series tabs #441 and on fix(mobile): separate movies and series in mixed libraries #447, and on unmodifiedmainabout once in eight runs of the class.PlayerViewModelLoadOwnershipIntegrationTest.pickAnotherReplacesThePickWithAFullCountdownAndStopEndsTheShuffle(from feat(playback): shuffle libraries, series, seasons, and collections on phone and TV #476) failed on fix(mobile): separate movies and series in mixed libraries #447, which changes no player code.Approach
The test fixture's mock engine resumed
LibrariesViewModelon an IO thread after every response. A library load could therefore finish while the test calledrefreshLibraryList()again on the test thread. The call saw the old load still active and queued a re-check, but the finishing loop had already decided not to repeat. No request followed, andawaitRequestwaited until the test timed out. The app runs this code on its single main thread, so the race exists only in the test.Library recheck tests: the fixture now takes an optional engine dispatcher. The four recheck tests run the mock engine on
StandardTestDispatcher(testScheduler), which keeps the view model and the test on one scheduler. Other tests are unchanged.Pick Another test: the view model publishes the new pick and its reset countdown in two updates, and the skip response resumes it off the test thread. The test waited only for the new pick, then read the countdown, which could still hold the old value. It now waits for both.
This changes only test code.
Validation
LibrariesViewModelTest10 times in a row with--rerun-tasks: all passed. Before the change, unmodifiedmainfailed the class 2 of 15 runs, always in a recheck test.PlayerViewModelLoadOwnershipIntegrationTest6 times in a row with--rerun-tasks: all passed.Evidence
Evidence: none, no user-visible change
Risks
None identified. Test-only change.
Checklist
AI Disclosure
claude-opus-5-5[1m]main; no independent agent reviewed it.🤖 Generated with Claude Code
Note
Stop mock-server races in phone unit tests by tying
MockEngineto the test schedulerDeferredLibrariesFixturein LibrariesViewModelTest.kt. Four library-list recheck tests pass aStandardTestDispatcherbacked by the current test scheduler, so mock HTTP handling and view-model resumptions run on the same virtual clock instead of racing real threads.MockEngineConfig.addHandlerand only overrides the dispatcher when one is supplied; callers that omit it keep the defaultMockEnginebehavior.Macroscope summarized 1669a61.