test(mobile): wait for picker loads to start instead of a fixed delay

Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
Signed-off-by: Tom Brow <tomb@squareup.com>
This commit is contained in:
Tom Brow
2026-11-13 11:44:54 -08:00
parent 913eb4c939
commit 359fdc805c

View File

@@ -858,9 +858,16 @@ void main() {
}), }),
throwsA(isA<PlatformException>()), throwsA(isA<PlatformException>()),
); );
await Future<void>.delayed(const Duration(milliseconds: 50)); // Each load checks the disk cache first, so wait for the four to
expect(mediaClient.requests, hasLength(4)); // reach the network rather than for a fixed time.
// An emoji already saved on disk does not wait for a slot. 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<void>.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( await diskCache.write(
'https://example.test/saved.png', 'https://example.test/saved.png',
_pngBytes, _pngBytes,