From 7c1af48ae7c4692f5bdd788c0a9959afde0ec141 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 1 May 2026 20:26:18 +0000 Subject: [PATCH] fix(nestsClient): wait for mute replay in setMuted_intent_replays test ScriptedSpeaker publishes startCount > 0 from inside startBroadcasting, so polling startCount alone races the wrapper pump's subsequent `if (desiredMuted) handle.setMuted(true)` step. Under load (full suite run on CI) the assertion fired before the pump replayed mute intent, producing setMutedCalls=0. Wait for the post-condition the assertion checks instead. --- .../nestsclient/ReconnectingNestsSpeakerTest.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/nestsClient/src/commonTest/kotlin/com/vitorpamplona/nestsclient/ReconnectingNestsSpeakerTest.kt b/nestsClient/src/commonTest/kotlin/com/vitorpamplona/nestsclient/ReconnectingNestsSpeakerTest.kt index debd337ee..948edddc9 100644 --- a/nestsClient/src/commonTest/kotlin/com/vitorpamplona/nestsclient/ReconnectingNestsSpeakerTest.kt +++ b/nestsClient/src/commonTest/kotlin/com/vitorpamplona/nestsclient/ReconnectingNestsSpeakerTest.kt @@ -346,9 +346,16 @@ class ReconnectingNestsSpeakerTest { } assertTrue(first.handles[0].isMuted, "first handle should be muted by user toggle") - // Wait for refresh to swap to the second session. + // Wait for refresh to swap to the second session AND + // for the pump to replay mute intent on the new handle. + // `startCount > 0` is published from inside + // ScriptedSpeaker.startBroadcasting BEFORE the pump + // gets to run `if (desiredMuted) handle.setMuted(true)`, + // so polling startCount alone races the replay step + // under load (observed flake on CI). Wait for the + // post-condition the assertion is about instead. withTimeout(5_000L) { - while (second.startCount == 0) delay(5) + while (second.handles.isEmpty() || !second.handles[0].isMuted) delay(5) } // Critical postcondition: the new underlying handle