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>
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
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());
|
||||
});
|
||||
}
|
||||
@@ -221,12 +221,19 @@ void main() {
|
||||
'background_tasks': 2,
|
||||
'seq': 9,
|
||||
}, sessionId: 's1'),
|
||||
(sessionId: 's1', turnRunning: true, backgroundTasks: 2, seq: 9),
|
||||
(
|
||||
sessionId: 's1',
|
||||
turnRunning: true,
|
||||
backgroundTasks: 2,
|
||||
awaitingOperator: 0,
|
||||
seq: 9,
|
||||
),
|
||||
);
|
||||
expect(chatListActivityOf({'session_id': 's2'}), (
|
||||
sessionId: 's2',
|
||||
turnRunning: false,
|
||||
backgroundTasks: 0,
|
||||
awaitingOperator: 0,
|
||||
seq: 0,
|
||||
));
|
||||
expect(chatListActivityOf({'background_tasks': 1}), isNull);
|
||||
|
||||
Reference in New Issue
Block a user