Files
pipelines/app/test/features/chat/conversation/chat_day_divider_test.dart
T
alan a3a59adb30 Quieter transcript metadata: day dividers, time-only rows, muted meta rows
- Date once per calendar day: a muted centred divider above each day's
  first timed row (chatDayDividers); rows show only their time ("10:16"),
  with the full date and time kept in the tooltip and semantics. The user's
  time shares the delivery line; a harness notice's time trails its line.
- Activity line and turn chips are secondary: bodyMedium, regular weight,
  onSurfaceVariant (error colour kept for failures), a small chevron_right
  that turns down while its details are open (replaces expand_less).
- Copy / Read aloud: 18 px muted icons; on pointer devices shown only while
  the reply is hovered or an action is focused (also without the gutter);
  touch keeps them visible with a full tap target. The time leads the
  footer so hidden actions leave no gap.
- Settled questions: the question on one line, the operator's answer in
  full on its own line beneath it.
- Meta rows (activity, chips, notices, compaction line) start at the reply
  text's leading edge; turn chips sit in their own column under the answer.
- Scroll fixture: ?timestamps=1 spreads messages over two days.

Row keys are unchanged; the divider joins a row without replacing it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 11:10:51 +00:00

70 lines
2.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/ui/transcript/chat_message_timestamp.dart';
import '../shell/chat_shell_fixtures.dart';
JsonMap _message(String id, String role, DateTime at) => {
'id': id,
'role': role,
'created_at': at.millisecondsSinceEpoch,
'parts': [
{'type': 'text', 'text': 'Text of $id'},
],
};
void main() {
testWidgets('the transcript dates each day once and each row by its time', (
tester,
) async {
tester.view.physicalSize = const Size(900, 2400);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final gateway = ShellGateway()
..messages = [
_message('u1', 'user', DateTime(2026, 11, 24, 9, 5)),
_message('a1', 'assistant', DateTime(2026, 11, 24, 9, 6)),
_message('u2', 'user', DateTime(2026, 11, 24, 17, 40)),
_message('a2', 'assistant', DateTime(2026, 11, 24, 17, 41)),
_message('u3', 'user', DateTime(2026, 11, 25, 10, 16)),
_message('a3', 'assistant', DateTime(2026, 11, 25, 10, 17)),
];
addTearDown(gateway.close);
await tester.pumpWidget(shellThread(gateway));
await tester.pump();
await tester.pump();
final dividers = find.byType(ChatDayDivider);
expect(dividers, findsNWidgets(2));
expect(find.text('24 November 2026'), findsOneWidget);
expect(find.text('25 November 2026'), findsOneWidget);
// The first day's divider precedes its first message; the second day's
// sits between the last message of the 24th and the first of the 25th.
final first = tester.getRect(find.text('24 November 2026'));
final second = tester.getRect(find.text('25 November 2026'));
expect(first.bottom, lessThan(tester.getRect(find.text('Text of u1')).top));
expect(
second.top,
greaterThan(tester.getRect(find.text('Text of a2')).top),
);
expect(
second.bottom,
lessThan(tester.getRect(find.text('Text of u3')).top),
);
// Every row shows its time alone; no row repeats the date.
expect(find.byType(ChatMessageTimestamp), findsNWidgets(6));
for (final time in ['09:05', '09:06', '17:40', '17:41', '10:16', '10:17']) {
expect(find.text(time), findsOneWidget);
}
expect(find.textContaining('November 2026 ·'), findsNothing);
// The divider names its day for assistive technology as a heading.
expect(
tester.getSemantics(dividers.first),
isSemantics(label: '24 November 2026', isHeader: true),
);
});
}