[PM-36604] test: Fix flaky WatchServiceTests#2617
Conversation
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE Reviewed test-only changes to Code Review DetailsNo findings. |
b45e20a to
ca7a047
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2617 +/- ##
=======================================
Coverage 87.31% 87.31%
=======================================
Files 1912 1912
Lines 170379 170400 +21
=======================================
+ Hits 148759 148779 +20
- Misses 21620 21621 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🎟️ Tracking
PM-36604
📔 Objective
Fixes three flaky tests in
WatchServiceTests:syncWithWatch_shouldNotConnect_sendsNeedSetup— captures the application context inside block 2's closure rather than reading the shared mock property afterwards. A still-runningsyncCiphersTaskfrom the first sync could overwriteupdateApplicationContextReceivedApplicationContextbetween theresume()call and the assertion.syncWithWatch_vaultLocked_skipsCipherSync— replacesTask.sleep(10_000_000)with a deterministic barrier sync: after the locked event, ashouldConnect=falseevent triggers a.needSetupresponse (which short-circuits beforedecryptCiphers) and provides a reliable signal that the locked sync was fully processed with no extra decryption.syncWithWatch_vaultUnlocked_syncsAfterUnlock— replacesTask.sleep(10_000_000)+ post-sleep assertion with an in-closure assertion onupdateApplicationContextCallsCount. The locked sync returns early at theisVaultLockedguard without callingupdateApplicationContext, so assertingcallsCount == 1inside the unlock callback is both correct and deterministic.