a3a59adb30
- 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>
106 lines
3.4 KiB
Dart
106 lines
3.4 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/conversation/chat_question_group.dart';
|
|
|
|
const _answer =
|
|
'Postgres 16 on the managed cluster, with read replicas in both regions '
|
|
'and nightly backups kept for thirty days';
|
|
|
|
JsonMap _form() => {
|
|
'id': 'form-1',
|
|
'title': 'Database',
|
|
'resolved': true,
|
|
'answers': {'q0': _answer},
|
|
'fields': [
|
|
{
|
|
'key': 'q0',
|
|
'title': 'Which database should the release use?',
|
|
'type': 'string',
|
|
'custom': true,
|
|
'options': [
|
|
{'value': 'Postgres', 'label': 'Postgres'},
|
|
],
|
|
},
|
|
],
|
|
};
|
|
|
|
final _chip = find.byKey(const ValueKey('chat-question-chip-form-1'));
|
|
final _answerLine = find.byKey(const ValueKey('chat-question-answer-form-1'));
|
|
|
|
Future<void> _pump(WidgetTester tester) async {
|
|
await tester.binding.setSurfaceSize(const Size(390, 844));
|
|
addTearDown(() => tester.binding.setSurfaceSize(null));
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: Scaffold(
|
|
body: Align(
|
|
alignment: AlignmentDirectional.topStart,
|
|
child: ChatQuestionChip(form: _form()),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
void main() {
|
|
test('the summary splits into the question and its outcome', () {
|
|
final parts = chatQuestionSummaryParts(_form());
|
|
expect(parts.question, 'Which database should the release use?');
|
|
expect(parts.outcome, _answer);
|
|
expect(
|
|
chatQuestionSummary(_form()),
|
|
'Which database should the release use? · $_answer',
|
|
);
|
|
});
|
|
|
|
testWidgets('a settled question shows its whole answer on its own line', (
|
|
tester,
|
|
) async {
|
|
await _pump(tester);
|
|
final question = find.text('Which database should the release use?');
|
|
expect(question, findsOneWidget);
|
|
expect(find.text(_answer), findsOneWidget);
|
|
// The answer wraps in full rather than ellipsizing on the question's line.
|
|
final answer = tester.widget<Text>(_answerLine);
|
|
expect(answer.maxLines, isNull);
|
|
expect(answer.overflow, isNot(TextOverflow.ellipsis));
|
|
final line = tester.getRect(question);
|
|
final rect = tester.getRect(_answerLine);
|
|
expect(rect.top, greaterThanOrEqualTo(line.bottom));
|
|
expect(rect.height, greaterThan(line.height * 1.5));
|
|
// Both lines start together, after the leading icon.
|
|
expect(rect.left, line.left);
|
|
// It is emphasised above the muted question.
|
|
final context = tester.element(_answerLine);
|
|
expect(answer.style?.color, Theme.of(context).colorScheme.onSurface);
|
|
expect(tester.takeException(), isNull);
|
|
});
|
|
|
|
testWidgets('its chevron is the expand affordance and turns while open', (
|
|
tester,
|
|
) async {
|
|
await _pump(tester);
|
|
expect(find.byIcon(Icons.expand_less), findsNothing);
|
|
expect(
|
|
find.descendant(of: _chip, matching: find.byIcon(Icons.chevron_right)),
|
|
findsOneWidget,
|
|
);
|
|
double turns() => tester
|
|
.widget<AnimatedRotation>(
|
|
find.descendant(of: _chip, matching: find.byType(AnimatedRotation)),
|
|
)
|
|
.turns;
|
|
expect(turns(), 0);
|
|
await tester.tap(_chip);
|
|
await tester.pumpAndSettle();
|
|
expect(find.byKey(const Key('chat-question-sheet')), findsOneWidget);
|
|
expect(turns(), 0.25);
|
|
Navigator.of(
|
|
tester.element(find.byKey(const Key('chat-question-sheet'))),
|
|
).pop();
|
|
await tester.pumpAndSettle();
|
|
expect(turns(), 0);
|
|
});
|
|
}
|