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.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -81,12 +81,38 @@ Future<void> 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<void> 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<void> 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,
|
||||
|
||||
Reference in New Issue
Block a user