From 359fdc805c4d88e3c374e9e6c532273635e96538 Mon Sep 17 00:00:00 2001 From: Tom Brow Date: Fri, 13 Nov 2026 11:44:54 -0800 Subject: [PATCH] test(mobile): wait for picker loads to start instead of a fixed delay Co-authored-by: studio Signed-off-by: Tom Brow --- .../test/features/channels/emoji_picker_test.dart | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mobile/test/features/channels/emoji_picker_test.dart b/mobile/test/features/channels/emoji_picker_test.dart index e0b9118afb..da15cd6161 100644 --- a/mobile/test/features/channels/emoji_picker_test.dart +++ b/mobile/test/features/channels/emoji_picker_test.dart @@ -858,9 +858,16 @@ void main() { }), throwsA(isA()), ); - await Future.delayed(const Duration(milliseconds: 50)); - expect(mediaClient.requests, hasLength(4)); - // An emoji already saved on disk does not wait for a slot. + // Each load checks the disk cache first, so wait for the four to + // reach the network rather than for a fixed time. + final deadline = DateTime.now().add(const Duration(seconds: 10)); + while (mediaClient.requests.length < 4) { + if (DateTime.now().isAfter(deadline)) fail('loads never started'); + await Future.delayed(const Duration(milliseconds: 10)); + } + // An emoji already saved on disk does not wait for a slot. Its own + // disk round trips also give the queued load time to start, were + // it not waiting for a slot. await diskCache.write( 'https://example.test/saved.png', _pngBytes,