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,
@@ -124,10 +124,12 @@ void main() {
reason:
'The main-screen Back interceptor must not block an open chat',
);
// The visible Back closes the chat page's own route explicitly (the
// same path the system gesture takes), never the nearest route.
expect(
tester.widget<BackButton>(findNativeBack()).onPressed,
isNull,
reason: 'Use the stock Navigator Back action without a chat override',
isNotNull,
reason: 'Back pops the chat page itself, not whichever route is near',
);
final transcript = find.byKey(const ValueKey('chat-thread-s'));
final scroll = tester
@@ -11,6 +11,7 @@ import 'package:pipelines_app/application/pipelines_app.dart';
import 'package:pipelines_app/application/server_endpoint.dart';
import 'package:pipelines_app/core/transport/pipelines_client.dart';
import 'package:pipelines_app/features/pipelines/screen.dart';
import 'package:pipelines_app/features/walkthrough/walkthrough_store.dart';
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
import '../features/pipelines/fixtures.dart';
@@ -21,6 +22,15 @@ ServerEndpoint webServer() => ServerEndpoint.resolve(
web: true,
);
/// Preferences for a device that has finished the first-run walkthrough and
/// was already offered it for [webServer]. With them the Pipelines page shows
/// no walkthrough dialog over its rows and bar, and issues no empty-server
/// check (whose unanswered reads would hold the serialized request queue).
Map<String, Object> walkthroughDonePreferences() => {
walkthroughSeenKey: true,
walkthroughOfferedKey: <String>[webServer().uri.toString()],
};
Map<String, dynamic>? requestOf(FakeChannel channel, String type) => channel
.outgoing
.map((frame) => jsonDecode(frame as String) as Map<String, dynamic>)
@@ -9,7 +9,7 @@ import 'package:pipelines_app/features/pipelines/ui/run_pipeline_wording.dart';
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
import '../features/pipelines/fixtures.dart';
import 'pipelines_app_test.dart' show webServer;
import 'pipelines_app_test.dart' show walkthroughDonePreferences, webServer;
import 'pipelines_replies.dart';
List<Map<String, dynamic>> requestsOf(FakeChannel channel, String type) =>
@@ -55,7 +55,11 @@ Future<void> reply(
void main() {
// The Run dialog reads the device's pending launch store before it opens.
setUp(() => SharedPreferences.setMockInitialValues({}));
// A device that has seen the first-run walkthrough has no dialog over the
// Pipelines page to absorb the row taps.
setUp(
() => SharedPreferences.setMockInitialValues(walkthroughDonePreferences()),
);
testWidgets('an accepted launch opens the returned run and re-reads the '
'runs list exactly once', (tester) async {
tester.view.physicalSize = const Size(1100, 900);
+18 -2
View File
@@ -560,7 +560,8 @@ void main() {
expect(find.byType(ArtifactViewerPage), findsOneWidget);
// Leave the viewer for the Artifacts tab, then a retired field hit opens
// the plain Summary with no visit.
// the plain Summary with no visit, in its default sections (Output open,
// Input closed).
await closeViewer(tester);
expectArtifactsTabSelecting(tester, '/artifacts/7/2/report.txt');
await sendSearch(query: 'retired', index: 1, hit: retiredFieldHit());
@@ -579,6 +580,17 @@ void main() {
findsOneWidget,
);
expect(find.text('ship it'), findsNothing);
expect(find.text('ok'), findsOneWidget);
// The operator closes Output, so the next hit must reopen it itself.
final outputTitle = find.descendant(
of: find.byKey(const ValueKey('run-detail-summary-output')),
matching: find.text('Output'),
);
await tester.ensureVisible(outputTitle.first);
await tester.pumpAndSettle();
await tester.tap(outputTitle.first);
await tester.pumpAndSettle();
expect(find.text('ok'), findsNothing);
// A current field hit opens the same run at the Summary section holding the
@@ -710,12 +722,16 @@ void main() {
await replyRunDetailFor(tester, channel, searchSelectionDetail(), index: 1);
await tester.pumpAndSettle();
expect(find.byType(ArtifactViewerPage), findsNothing);
expect(find.byKey(const Key('run-visit-pane')), findsNothing);
expect(
find.byKey(const Key('run-detail-tab-body-summary')),
findsOneWidget,
);
expect(find.text('ok'), findsNothing);
// An ordinary visit shows the Summary's default sections: Output open,
// Input closed.
expect(find.text('ok'), findsOneWidget);
expect(find.text('ship it'), findsNothing);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
@@ -9,13 +9,16 @@ import 'package:shared_preferences/shared_preferences.dart';
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
import '../features/pipelines/fixtures.dart';
import 'pipelines_app_test.dart' show webServer, requestOf;
import 'pipelines_app_test.dart'
show walkthroughDonePreferences, webServer, requestOf;
import 'pipelines_replies.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
void main() {
testWidgets('Settings shares socket and one native bar', (tester) async {
SharedPreferences.setMockInitialValues({});
// A device that has seen the first-run walkthrough: no dialog over the
// Pipelines page absorbs the bar tap.
SharedPreferences.setMockInitialValues(walkthroughDonePreferences());
final channel = FakeChannel()..readyCompleter.complete();
var sockets = 0;
final client = PipelinesClient(