Files
pipelines/app/test/features/chat/domain/chat_transcript_days_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

61 lines
1.6 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/domain/chat_transcript_days.dart';
int _at(int day, int hour) =>
DateTime(2026, 11, day, hour).millisecondsSinceEpoch;
JsonMap _user(int? time) => {
'kind': 'user',
'message': {'created_at': ?time},
};
JsonMap _turn(int? time) => {'kind': 'assistant', 'created_at': ?time};
void main() {
test('a row takes its own, its message\'s or its first notice\'s time', () {
expect(chatRowCreatedAt(_turn(_at(24, 9))), _at(24, 9));
expect(chatRowCreatedAt(_user(_at(24, 10))), _at(24, 10));
expect(
chatRowCreatedAt({
'kind': 'task_notices',
'messages': [
{'created_at': 'bad'},
{'created_at': _at(25, 8)},
],
}),
_at(25, 8),
);
expect(chatRowCreatedAt({'kind': 'question', 'form': {}}), isNull);
});
test('one divider per calendar day, at that day\'s first timed row', () {
final rows = [
_turn(null), // an untimed row neither starts nor breaks a day
_user(_at(24, 9)),
_turn(_at(24, 9)),
{'kind': 'questions'},
_user(_at(24, 23)),
_turn(_at(25, 0)),
_user(null),
_user(_at(25, 10)),
_turn(_at(26, 7)),
];
expect(chatDayDividers(rows), [
null,
DateTime(2026, 11, 24),
null,
null,
null,
DateTime(2026, 11, 25),
null,
null,
DateTime(2026, 11, 26),
]);
});
test('no times, no dividers', () {
expect(chatDayDividers([_turn(null), _user(null)]), [null, null]);
});
}