Files
pipelines/app/test/features/chat/ui/sessions/chat_awaiting_test.dart
T
alan 4c82a9637e Show loudly in the chat list when a chat is waiting on the operator
The server's chat activity now counts each session's unanswered
approvals and questions (awaiting_operator) and pushes it to every
connection when it changes. A waiting chat's list row pulses in the
error colour with a solid bar on its leading edge, its avatar wears a
ringing bell in place of the spinner, and its state line leads with a
bold "Waiting for you". Reduced motion holds the pulse and the bell
still.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 22:54:38 +00:00

76 lines
2.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/domain/chat_list_activity.dart';
import 'package:pipelines_app/features/chat/ui/sessions/chat_awaiting.dart';
import 'package:pipelines_app/features/chat/ui/sessions/session_activity_badge.dart';
void main() {
test('the list activity carries what waits on the operator', () {
final activity = chatListActivityOf({
'session_id': 's',
'turn_running': true,
'awaiting_operator': 2,
'seq': 5,
})!;
expect(activity.awaitingOperator, 2);
final row = chatListActivityRowFields(activity);
expect(chatSessionAwaitingOperator(row), 2);
expect(chatSessionAwaitingOperator(const {}), 0);
});
testWidgets('waiting on the operator outranks the working spinner', (
tester,
) async {
await tester.pumpWidget(
MaterialApp(
home: Center(
child: chatSessionActivityBadge(
running: true,
backgroundTasks: 1,
awaitingOperator: 1,
),
),
),
);
expect(find.byKey(const Key('chat-row-awaiting')), findsOneWidget);
expect(find.byKey(const Key('chat-row-working')), findsNothing);
expect(find.bySemanticsLabel('Waiting for your reply'), findsOneWidget);
await tester.pumpWidget(const SizedBox());
});
testWidgets('a waiting row pulses; reduced motion holds it still', (
tester,
) async {
Widget host({required bool still}) => MaterialApp(
home: MediaQuery(
data: MediaQueryData(disableAnimations: still),
child: const Scaffold(
body: ChatAwaitingHighlight(
waiting: true,
child: SizedBox(height: 60, child: Text('Caplens PI')),
),
),
),
);
Color tint() =>
((tester
.widget<DecoratedBox>(
find.byKey(const Key('chat-row-awaiting-highlight')),
)
.decoration
as BoxDecoration)
.color!);
await tester.pumpWidget(host(still: false));
final first = tint();
await tester.pump(const Duration(milliseconds: 550));
expect(tint(), isNot(first));
await tester.pumpWidget(host(still: true));
await tester.pump();
final held = tint();
await tester.pump(const Duration(milliseconds: 550));
expect(tint(), held);
await tester.pumpWidget(const SizedBox());
});
}