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,