b6aa820378
Keep the Material-only chat conversation implementation while preserving public Cupertino parameters for downstream compatibility. Narrow the matching tests to the Material path.
55 lines
1.7 KiB
Dart
55 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
|
|
import 'package:pipelines_app/features/chat/ui/transcript/chat_message_view.dart';
|
|
|
|
import 'chat_thread_fixtures.dart';
|
|
|
|
void main() {
|
|
// Chat details is Material only (a dialog, or a sheet on a phone).
|
|
testWidgets('usage updates leave transcript widgets alone but refresh Info', (
|
|
tester,
|
|
) async {
|
|
final gateway = FakeChatGateway();
|
|
addTearDown(gateway.close);
|
|
gateway.history = (_) async => chatPage([
|
|
chatMessage(
|
|
'a1',
|
|
'assistant',
|
|
parts: [
|
|
{'type': 'text', 'text': '**Existing answer**'},
|
|
],
|
|
),
|
|
]);
|
|
final thread = ChatThreadView(
|
|
gateway: gateway,
|
|
sessionId: 's',
|
|
onBack: () {},
|
|
);
|
|
await tester.pumpWidget(MaterialApp(home: Scaffold(body: thread)));
|
|
await tester.pumpAndSettle();
|
|
final answer = tester.widget<ChatMessageView>(find.byType(ChatMessageView));
|
|
gateway.emitEvent({
|
|
'session_id': 's',
|
|
'kind': 'usage',
|
|
'usage': {'scope': 'session', 'total_tokens': 123},
|
|
});
|
|
await tester.pumpAndSettle();
|
|
expect(
|
|
tester.widget<ChatMessageView>(find.byType(ChatMessageView)),
|
|
same(answer),
|
|
);
|
|
await tester.tap(find.byKey(const Key('chat-info')));
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('123'), findsOneWidget);
|
|
gateway.emitEvent({
|
|
'session_id': 's',
|
|
'kind': 'usage',
|
|
'usage': {'scope': 'session', 'total_tokens': 456},
|
|
});
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('456'), findsOneWidget);
|
|
expect(find.text('123'), findsNothing);
|
|
});
|
|
}
|