Fix the 11 failing application tests: two product fixes, stale fixtures

Product:
- Settings jump index scrolls instead of overflowing a short wide window
  (overflowed by 48 px at 1200x800 once Open in chat added a section).
- Chat: a route to the retained workspace's active pane shows it in the
  same frame again; ec3c1e4c deferred it a frame behind a post-frame callback.

Tests updated to intended behaviour:
- first-run walkthrough (30ba70ad): seed a device that has seen it and was
  offered it for the fixture server;
- Output section open by default (22af093e);
- chat page Back closes its own route explicitly (19b1d132);
- open-chat sync (c48a1559): answer chat_open_workspace statefully;
- keyed session list (0a51add9) no longer re-reads chat_sessions on open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-26 01:58:57 +00:00
parent fc5d3bc42b
commit 0e5a06ae88
9 changed files with 201 additions and 114 deletions
+107 -87
View File
@@ -47,6 +47,9 @@ Future<Map<String, dynamic>> waitForRequest(
// Automation metadata is independently requested before history. This
// fixture has no provider schedules; answer unavailable rather than leave
// the correlated transport blocked behind an unanswered request.
// The open-chat sync reads and writes `chat_open_workspace` around opening
// a chat; the serialized transport holds every later request behind it.
if (type != 'chat_open_workspace') answerOpenWorkspaceRequests(channel);
if (type != 'chat_automations') {
for (final raw in channel.outgoing.toList()) {
final metadata = jsonDecode(raw as String) as Map<String, dynamic>;
@@ -222,36 +225,53 @@ Future<void> replyChatSessions(
await tester.pump();
}
/// Answers the `chat_open_workspace` requests the app sends around opening a
/// chat (main's open-chat sync), so the chat can subscribe. A read gets an
/// empty set; a write is stored at the next revision with its own entries.
/// Each request is answered once.
/// The fixture server's open-chat set per channel, as the real
/// `chat_open_workspace` holds it: a revision and its entries.
final _openWorkspaces = Expando<({int revision, List<Object?> entries})>();
/// Answers every unanswered `chat_open_workspace` request the app has sent
/// (the open-chat sync), so the chat can subscribe. A read gets the stored set
/// (empty at first); a write is stored at the next revision with its own
/// entries. Each request is answered once, sharing [waitForRequest]'s record
/// of replies.
void answerOpenWorkspaceRequests(FakeChannel channel) {
final answered = _fixtureAutomationReplies[channel] ??= <String>{};
for (final raw in channel.outgoing.toList()) {
final message = jsonDecode(raw as String) as Map<String, dynamic>;
if (message['type'] != 'chat_open_workspace' ||
!answered.add('${message['id']}')) {
continue;
}
var stored =
_openWorkspaces[channel] ?? (revision: 0, entries: const <Object?>[]);
final write = message['chat_open_workspace_request'] as Map?;
if (write != null) {
stored = (
revision: stored.revision + 1,
entries: List<Object?>.of(write['entries'] as List),
);
_openWorkspaces[channel] = stored;
}
channel.incoming.add(
jsonEncode({
'id': message['id'],
'type': 'chat_open_workspace',
'chat_open_workspace': {
'revision': stored.revision,
'entries': stored.entries,
},
}),
);
}
}
/// Answers the `chat_open_workspace` requests sent over a few frames.
Future<void> answerOpenWorkspace(
WidgetTester tester,
FakeChannel channel,
) async {
final answered = <Object?>{};
for (var attempt = 0; attempt < 20; attempt++) {
for (final raw in channel.outgoing.toList()) {
final message = jsonDecode(raw as String) as Map<String, dynamic>;
if (message['type'] != 'chat_open_workspace' ||
!answered.add(message['id'])) {
continue;
}
final write = message['chat_open_workspace_request'] as Map?;
channel.incoming.add(
jsonEncode({
'id': message['id'],
'type': 'chat_open_workspace',
'chat_open_workspace': write == null
? {'revision': 0, 'entries': const []}
: {
'revision': (write['base_revision'] as num) + 1,
'entries': write['entries'],
},
}),
);
}
answerOpenWorkspaceRequests(channel);
await tester.pump(const Duration(milliseconds: 5));
}
}
@@ -381,74 +401,73 @@ void main() {
},
);
testWidgets(
'a mounted chat notification route activates a different chat',
(tester) async {
tester.view.physicalSize = const Size(900, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
testWidgets('a mounted chat notification route activates a different chat', (
tester,
) async {
tester.view.physicalSize = const Size(900, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final channel = FakeChannel()..readyCompleter.complete();
final client = PipelinesClient(channelFactory: (_) => channel);
final provider = PlatformRouteInformationProvider(
initialRouteInformation: RouteInformation(uri: Uri.parse('/chat/old')),
);
addTearDown(provider.dispose);
final channel = FakeChannel()..readyCompleter.complete();
final client = PipelinesClient(channelFactory: (_) => channel);
final provider = PlatformRouteInformationProvider(
initialRouteInformation: RouteInformation(uri: Uri.parse('/chat/old')),
);
addTearDown(provider.dispose);
await tester.pumpWidget(
PipelinesApp(
androidSupported: false,
server: webServer(),
client: client,
routeInformationProvider: provider,
),
);
await tester.pump();
await tester.pumpWidget(
PipelinesApp(
androidSupported: false,
server: webServer(),
client: client,
routeInformationProvider: provider,
),
);
await tester.pump();
await replyChatSessions(tester, channel, ['old', 'target']);
await replyChatHistory(
tester,
channel,
subscribeIndex: 0,
historyIndex: 0,
text: 'The retained chat.',
);
expect(find.text('The retained chat.'), findsOneWidget);
await replyChatSessions(tester, channel, ['old', 'target']);
await replyChatHistory(
tester,
channel,
subscribeIndex: 0,
historyIndex: 0,
text: 'The retained chat.',
);
expect(find.text('The retained chat.'), findsOneWidget);
// This is the route delivered by a native chat notification, not a
// direct ChatScreen replacement.
await provider.didPushRouteInformation(
RouteInformation(uri: Uri.parse('/chat/target')),
);
await tester.pump();
expect(provider.value.uri.path, '/chat/target');
// This is the route delivered by a native chat notification, not a
// direct ChatScreen replacement.
await provider.didPushRouteInformation(
RouteInformation(uri: Uri.parse('/chat/target')),
);
await tester.pump();
expect(provider.value.uri.path, '/chat/target');
await replyChatHistory(
tester,
channel,
subscribeIndex: 1,
historyIndex: 1,
text: 'The notified chat.',
);
await tester.pumpAndSettle();
await replyChatHistory(
tester,
channel,
subscribeIndex: 1,
historyIndex: 1,
text: 'The notified chat.',
);
await tester.pumpAndSettle();
expect(requestOf(channel, 'chat_subscribe', index: 1)!['chat_subscribe'], {
'session_id': 'target',
});
expect(requestOf(channel, 'chat_messages', index: 1)!['chat_query'], {
'session_id': 'target',
'limit': 200,
'cursor': '',
});
expect(find.text('The notified chat.'), findsOneWidget);
expect(find.text('The retained chat.'), findsNothing);
expect(provider.value.uri.path, '/chat/target');
expect(requestOf(channel, 'chat_subscribe', index: 1)!['chat_subscribe'], {
'session_id': 'target',
});
expect(requestOf(channel, 'chat_messages', index: 1)!['chat_query'], {
'session_id': 'target',
'limit': 200,
'cursor': '',
});
expect(find.text('The notified chat.'), findsOneWidget);
expect(find.text('The retained chat.'), findsNothing);
expect(provider.value.uri.path, '/chat/target');
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
},
);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
});
testWidgets(
'mobile Chats retap reopens the retained multi-pane workspace after tabs',
@@ -496,7 +515,8 @@ void main() {
await tester.pump();
expect(provider.value.uri.path, '/chat/a');
expect(find.byType(ChatThreadView), findsOneWidget);
await replyChatSessions(tester, channel, ['a', 'b'], index: 1);
// The keyed session list moves beside the chat without remounting, so
// opening a chat issues no second list read.
await replyChatHistory(
tester,
channel,