From 859d06c3a09474ed9a22adaed6414064a7fc3744 Mon Sep 17 00:00:00 2001 From: PJ Date: Sat, 15 Aug 2026 12:46:40 +0530 Subject: [PATCH] test(sidecar): pin the transition cap by driving it it asserted 1500 >= 700 + 300, two constants, which can only fail if someone edits a constant. it now drives awaitSettledTree against a fade that lands after 700ms and asserts it hands back the settled tree before the cap. cut the cap to 1000 and it goes red. --- .../sanderling/sidecar/RouteTransitionTest.kt | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/sidecar/src/test/kotlin/dev/sanderling/sidecar/RouteTransitionTest.kt b/sidecar/src/test/kotlin/dev/sanderling/sidecar/RouteTransitionTest.kt index 41e8e0f..3c7c776 100644 --- a/sidecar/src/test/kotlin/dev/sanderling/sidecar/RouteTransitionTest.kt +++ b/sidecar/src/test/kotlin/dev/sanderling/sidecar/RouteTransitionTest.kt @@ -84,12 +84,25 @@ class RouteTransitionTest { @Test fun capCoversTheNavHostFadePlusTheStreak() { // Compose navigation's default enter and exit are a 700ms tween, and // the fade starts when the action lands, not when the snapshot begins. - // A cap that does not clear the fade and the streak after it leaves the - // frame transitional, which is the whole defect. + // A cap that does not clear the fade and the streak after it hands the + // caller a transitional frame, which is the whole defect. + val fadeMillis = 700L + val start = System.currentTimeMillis() + val settled = awaitSettledTree { + if (System.currentTimeMillis() - start < fadeMillis) crossFade else landed + } + val elapsed = System.currentTimeMillis() - start + + assertEquals(landed, settled, "must hand back the landed tree, not the fade") assertTrue( - TRANSITION_POLL_CAP_MILLIS >= 700L + TRANSITION_STABLE_STREAK_MILLIS, - "cap ${TRANSITION_POLL_CAP_MILLIS}ms cannot cover a 700ms fade plus a " + - "${TRANSITION_STABLE_STREAK_MILLIS}ms streak", + elapsed >= fadeMillis, + "cannot have settled before the fade ended, elapsed=${elapsed}ms", + ) + assertTrue( + elapsed < TRANSITION_POLL_CAP_MILLIS, + "the ${TRANSITION_POLL_CAP_MILLIS}ms cap has to leave room for a ${fadeMillis}ms " + + "fade and the ${TRANSITION_STABLE_STREAK_MILLIS}ms streak after it, but the " + + "wait ran to the cap instead, elapsed=${elapsed}ms", ) } }