feat(app): chat sections are clear collapsible dividers; closed chats start collapsed

This commit is contained in:
2026-10-24 00:22:18 +01:00
parent d0b1c8e524
commit 1e55b8d2b3
16 changed files with 293 additions and 161 deletions
@@ -253,9 +253,7 @@ void main() {
) async {
final semantics = tester.ensureSemantics();
await tester.pumpWidget(
scrollHost(
ChatQuestionCard(form: question(), onSubmit: (_, _) async {}),
),
scrollHost(ChatQuestionCard(form: question(), onSubmit: (_, _) async {})),
);
final node = tester.getSemantics(
find.byKey(const ValueKey<String>('chat-question-input-note')),
@@ -296,65 +294,67 @@ void main() {
expect(sent!['count'], isA<int>());
});
testWidgets('decline and cancel send their recorded actions with no answers', (
tester,
) async {
final actions = <String>[];
final answers = <Map<String, dynamic>>[];
await tester.pumpWidget(
scrollHost(
ChatQuestionCard(
form: question(),
onSubmit: (sent, action) async {
actions.add(action);
answers.add(sent);
},
testWidgets(
'decline and cancel send their recorded actions with no answers',
(tester) async {
final actions = <String>[];
final answers = <Map<String, dynamic>>[];
await tester.pumpWidget(
scrollHost(
ChatQuestionCard(
form: question(),
onSubmit: (sent, action) async {
actions.add(action);
answers.add(sent);
},
),
),
),
);
await tester.tap(find.text('Decline'));
await tester.pumpAndSettle();
await tester.tap(find.text('Cancel question'));
await tester.pumpAndSettle();
expect(actions, ['decline', 'cancel']);
expect(answers, [<String, dynamic>{}, <String, dynamic>{}]);
});
);
await tester.tap(find.text('Decline'));
await tester.pumpAndSettle();
await tester.tap(find.text('Cancel question'));
await tester.pumpAndSettle();
expect(actions, ['decline', 'cancel']);
expect(answers, [<String, dynamic>{}, <String, dynamic>{}]);
},
);
testWidgets('an all-external form confirms completion without field answers', (
tester,
) async {
Map<String, dynamic>? sent;
String? action;
await tester.pumpWidget(
scrollHost(
ChatQuestionCard(
form: {
'id': 'form-external',
'title': 'Open the form',
'actions': ['accept'],
'fields': [
{
'key': 'form',
'title': 'External form',
'type': 'external',
'url': 'https://example.com/complete',
},
],
},
onSubmit: (answers, next) async {
sent = answers;
action = next;
},
testWidgets(
'an all-external form confirms completion without field answers',
(tester) async {
Map<String, dynamic>? sent;
String? action;
await tester.pumpWidget(
scrollHost(
ChatQuestionCard(
form: {
'id': 'form-external',
'title': 'Open the form',
'actions': ['accept'],
'fields': [
{
'key': 'form',
'title': 'External form',
'type': 'external',
'url': 'https://example.com/complete',
},
],
},
onSubmit: (answers, next) async {
sent = answers;
action = next;
},
),
),
),
);
expect(find.text('Confirm completion'), findsOneWidget);
expect(find.text('https://example.com/complete'), findsOneWidget);
await tester.tap(find.text('Confirm completion'));
await tester.pumpAndSettle();
expect(sent, isEmpty);
expect(action, 'accept');
});
);
expect(find.text('Confirm completion'), findsOneWidget);
expect(find.text('https://example.com/complete'), findsOneWidget);
await tester.tap(find.text('Confirm completion'));
await tester.pumpAndSettle();
expect(sent, isEmpty);
expect(action, 'accept');
},
);
testWidgets('an unsupported external URL shows the web alert wording', (
tester,
@@ -405,7 +405,12 @@ void main() {
'resolved': true,
'answers': {'enabled': true, 'extra': 'kept'},
'fields': [
{'key': 'enabled', 'title': '', 'description': '', 'type': 'boolean'},
{
'key': 'enabled',
'title': '',
'description': '',
'type': 'boolean',
},
],
},
onSubmit: (_, _) async {},