From ee1de88be4a5b8720123fe1409a3532990d71454 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Thu, 22 Oct 2026 18:00:54 +0100 Subject: [PATCH] test(app): answer the task-bar shells snapshot in chat application fixtures The conversation now reads chat_shells on mount and after a reconnect, and the client serializes requests, so the deep-link and reconnect fixtures must answer that snapshot before the history page can leave the queue. --- .../application/chat_destination_test.dart | 11 +++++++- .../application/chat_registration_test.dart | 26 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/app/test/application/chat_destination_test.dart b/app/test/application/chat_destination_test.dart index eaca79ae..aed29da1 100644 --- a/app/test/application/chat_destination_test.dart +++ b/app/test/application/chat_destination_test.dart @@ -11,6 +11,7 @@ import '../core/transport/pipelines_client_test.dart' show FakeChannel; import 'chat_registration_test.dart' show replyHistory, + replyShells, replySessions, replySubscribe, requestOf, @@ -91,12 +92,20 @@ void main() { ); await tester.pump(); + // The task bar re-reads its snapshot on the new socket ahead of the + // thread's own resubscribe; both wait behind the serialized list reply. + await replyShells(tester, second); final resubscribe = await waitForRequest(tester, second, 'chat_subscribe'); second.incoming.add( jsonEncode({'id': resubscribe['id'], 'type': 'chat_subscribe'}), ); await tester.pump(); - await replyHistory(tester, second, text: 'Refreshed after reconnect.'); + await replyHistory( + tester, + second, + text: 'Refreshed after reconnect.', + shells: false, + ); expect(find.byType(ChatThreadView), findsOneWidget); expect(find.text('Refreshed after reconnect.'), findsOneWidget); expect(find.text('The stored reply stays readable.'), findsNothing); diff --git a/app/test/application/chat_registration_test.dart b/app/test/application/chat_registration_test.dart index ef460b1b..440979ef 100644 --- a/app/test/application/chat_registration_test.dart +++ b/app/test/application/chat_registration_test.dart @@ -81,12 +81,38 @@ Future replySubscribe( await tester.pump(); } +/// The mounted thread also reads the session's running background tasks. The +/// client serializes requests, so this snapshot is answered (no running task) +/// before the history page behind it can leave the queue. +Future replyShells( + WidgetTester tester, + FakeChannel channel, { + int index = 0, +}) async { + final request = await waitForRequest( + tester, + channel, + 'chat_shells', + index: index, + ); + channel.incoming.add( + jsonEncode({ + 'id': request['id'], + 'type': 'chat_shells', + 'chat_shells': const [], + }), + ); + await tester.pump(); +} + Future replyHistory( WidgetTester tester, FakeChannel channel, { int index = 0, String text = 'The stored reply stays readable.', + bool shells = true, }) async { + if (shells) await replyShells(tester, channel, index: index); final request = await waitForRequest( tester, channel,