merge(app): land chat-activity-overlay micro-slice
This commit is contained in:
@@ -174,6 +174,7 @@ void main() {
|
||||
Future<FakeChatGateway> pumpThread(
|
||||
WidgetTester tester, {
|
||||
required bool cupertino,
|
||||
List<JsonMap>? activityParts,
|
||||
}) async {
|
||||
final gateway = FakeChatGateway();
|
||||
addTearDown(gateway.close);
|
||||
@@ -188,15 +189,17 @@ void main() {
|
||||
chatMessage(
|
||||
'a1',
|
||||
'assistant',
|
||||
parts: [
|
||||
{
|
||||
'type': 'activity',
|
||||
'id': 'e1',
|
||||
'kind': 'compaction',
|
||||
'state': 'running',
|
||||
},
|
||||
{'type': 'text', 'id': 't1', 'text': 'Answer'},
|
||||
],
|
||||
parts:
|
||||
activityParts ??
|
||||
[
|
||||
{
|
||||
'type': 'activity',
|
||||
'id': 'e1',
|
||||
'kind': 'compaction',
|
||||
'state': 'running',
|
||||
},
|
||||
{'type': 'text', 'id': 't1', 'text': 'Answer'},
|
||||
],
|
||||
),
|
||||
]);
|
||||
final view = ChatThreadView(
|
||||
@@ -236,5 +239,125 @@ void main() {
|
||||
expect(find.text('Answer'), findsOneWidget);
|
||||
expect(find.textContaining('Unrecognised part'), findsNothing);
|
||||
});
|
||||
|
||||
group('expanded detail', () {
|
||||
final recorded = <JsonMap>[
|
||||
{
|
||||
'type': 'activity',
|
||||
'id': 'e1',
|
||||
'kind': 'tool',
|
||||
'state': 'completed',
|
||||
'label': 'Ran a tool',
|
||||
'input': {'command': 'ls'},
|
||||
'output': 'two files',
|
||||
'error': 'exit 1',
|
||||
'duration': 1200,
|
||||
'diff': {
|
||||
'file': 'lib/main.dart',
|
||||
'added': 1,
|
||||
'removed': 1,
|
||||
'lines': [
|
||||
{'kind': 'remove', 'text': 'old'},
|
||||
{'kind': 'add', 'text': 'new'},
|
||||
],
|
||||
},
|
||||
},
|
||||
{'type': 'text', 'id': 't1', 'text': 'Answer'},
|
||||
];
|
||||
final sparse = <JsonMap>[
|
||||
{
|
||||
'type': 'activity',
|
||||
'id': 'e1',
|
||||
'kind': 'compaction',
|
||||
'state': 'running',
|
||||
},
|
||||
{'type': 'text', 'id': 't1', 'text': 'Answer'},
|
||||
];
|
||||
|
||||
Future<void> toggle(WidgetTester tester) async {
|
||||
final control = find.byKey(
|
||||
const ValueKey<String>('chat-activity-toggle'),
|
||||
);
|
||||
await tester.ensureVisible(control);
|
||||
await tester.tap(control);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
|
||||
testWidgets('$host shows only the recorded detail values', (
|
||||
tester,
|
||||
) async {
|
||||
await pumpThread(
|
||||
tester,
|
||||
cupertino: cupertino,
|
||||
activityParts: recorded,
|
||||
);
|
||||
await toggle(tester);
|
||||
|
||||
expect(
|
||||
find.byKey(const ValueKey<String>('chat-activity-details')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Lifecycle'), findsOneWidget);
|
||||
expect(find.text('completed'), findsOneWidget);
|
||||
expect(find.textContaining('"command": "ls"'), findsOneWidget);
|
||||
expect(find.text('two files'), findsOneWidget);
|
||||
expect(find.text('exit 1'), findsOneWidget);
|
||||
expect(find.text('1.2s'), findsOneWidget);
|
||||
expect(
|
||||
find.text('lib/main.dart\n+1 -1\n- old\n+ new'),
|
||||
findsOneWidget,
|
||||
);
|
||||
for (final absent in const [
|
||||
'No lifecycle recorded.',
|
||||
'No input recorded.',
|
||||
'No output recorded.',
|
||||
'No error recorded.',
|
||||
'No duration recorded.',
|
||||
'No edit diff recorded.',
|
||||
]) {
|
||||
expect(find.text(absent), findsNothing, reason: absent);
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('$host words every absent field exactly', (tester) async {
|
||||
await pumpThread(tester, cupertino: cupertino, activityParts: sparse);
|
||||
await toggle(tester);
|
||||
|
||||
expect(find.text('running'), findsOneWidget);
|
||||
expect(find.text('No input recorded.'), findsOneWidget);
|
||||
expect(find.text('No output recorded.'), findsOneWidget);
|
||||
expect(find.text('No error recorded.'), findsOneWidget);
|
||||
expect(find.text('No duration recorded.'), findsOneWidget);
|
||||
expect(find.text('No edit diff recorded.'), findsOneWidget);
|
||||
expect(find.text('No lifecycle recorded.'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('$host collapses back to the single line', (tester) async {
|
||||
await pumpThread(
|
||||
tester,
|
||||
cupertino: cupertino,
|
||||
activityParts: recorded,
|
||||
);
|
||||
await toggle(tester);
|
||||
expect(
|
||||
find.byKey(const ValueKey<String>('chat-activity-details')),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
await toggle(tester);
|
||||
|
||||
expect(
|
||||
find.byKey(const ValueKey<String>('chat-activity-details')),
|
||||
findsNothing,
|
||||
);
|
||||
expect(find.text('Input'), findsNothing);
|
||||
expect(find.text('Ran a tool'), findsOneWidget);
|
||||
expect(find.text('Answer'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user