64 lines
2.0 KiB
Dart
64 lines
2.0 KiB
Dart
import 'package:flutter/cupertino.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() {
|
|
for (final cupertino in [false, true]) {
|
|
testWidgets(
|
|
'usage updates leave transcript widgets alone but refresh Info ($cupertino)',
|
|
(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(
|
|
cupertino
|
|
? CupertinoApp(home: CupertinoPageScaffold(child: thread))
|
|
: 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);
|
|
},
|
|
);
|
|
}
|
|
}
|