From 67bacac84b6f988af72918722e569922016070e0 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Thu, 14 May 2026 15:59:16 -0400 Subject: [PATCH] fix(test): capture cacheFirst stream Future before feeding controller --- flutter_client/test/cache/cache_first_test.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/flutter_client/test/cache/cache_first_test.dart b/flutter_client/test/cache/cache_first_test.dart index 9f99e2be..ff286873 100644 --- a/flutter_client/test/cache/cache_first_test.dart +++ b/flutter_client/test/cache/cache_first_test.dart @@ -36,7 +36,11 @@ void main() { // (still-empty) rows after the fetch returns, so the stream // never hangs when populate is a no-op for this filter. The // simulated drift re-emit then yields the populated rows. - final emissions = await results.take(2).toList(); + // Capture the Future *before* feeding the controller so the + // listener is subscribed when the first add() lands. + final emissionsFuture = results.take(2).toList(); + controller.add([]); + final emissions = await emissionsFuture; expect(emissions, [0, 42]); expect(fetchCalled, 1); await controller.close();