Show harness identity beside chat titles and keep only the actionable star
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/session_harness_icon.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/session_list_cupertino.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/session_list_material.dart';
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
for (final backend in ['opencode', 'claude']) {
|
||||
testWidgets(
|
||||
'$backend identity beside title, one actionable star ($cupertino)',
|
||||
(tester) async {
|
||||
var starred = true;
|
||||
final body = StatefulBuilder(
|
||||
builder: (context, setState) {
|
||||
final sections = [
|
||||
(
|
||||
title: 'Chats',
|
||||
sessions: [
|
||||
<String, dynamic>{
|
||||
'id': 's',
|
||||
'title': 'Harness chat',
|
||||
'backend': backend,
|
||||
'starred': starred,
|
||||
'running': true,
|
||||
},
|
||||
],
|
||||
),
|
||||
];
|
||||
void star(Map<String, dynamic> _) =>
|
||||
setState(() => starred = !starred);
|
||||
return cupertino
|
||||
? CupertinoSessionList(
|
||||
sections: sections,
|
||||
emptyMessage: null,
|
||||
duplicateTitles: const {},
|
||||
onOpen: (_) {},
|
||||
onRename: (_) {},
|
||||
onClose: (_) {},
|
||||
onReopen: (_) {},
|
||||
onStar: star,
|
||||
onHide: (_) {},
|
||||
onClearSearch: null,
|
||||
isUnseen: (_) => false,
|
||||
errorFor: (_) => null,
|
||||
)
|
||||
: MaterialSessionList(
|
||||
sections: sections,
|
||||
emptyMessage: null,
|
||||
duplicateTitles: const {},
|
||||
onOpen: (_) {},
|
||||
onRename: (_) {},
|
||||
onClose: (_) {},
|
||||
onReopen: (_) {},
|
||||
onStar: star,
|
||||
onHide: (_) {},
|
||||
onClearSearch: null,
|
||||
isUnseen: (_) => false,
|
||||
errorFor: (_) => null,
|
||||
);
|
||||
},
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: body))
|
||||
: MaterialApp(home: Scaffold(body: body)),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final mark = find.byType(SessionHarnessIcon);
|
||||
expect(mark, findsOneWidget);
|
||||
expect(
|
||||
tester.widget<ImageIcon>(find.byType(ImageIcon)).image,
|
||||
AssetImage('assets/harnesses/$backend.png'),
|
||||
);
|
||||
final title = tester.getRect(find.text('Harness chat'));
|
||||
final icon = tester.getRect(mark);
|
||||
expect(icon.right, lessThanOrEqualTo(title.left));
|
||||
expect(icon.top, lessThan(title.bottom));
|
||||
expect(icon.bottom, greaterThan(title.top));
|
||||
expect(
|
||||
find.byIcon(cupertino ? CupertinoIcons.star_fill : Icons.star),
|
||||
findsOneWidget,
|
||||
);
|
||||
await tester.tap(find.byKey(const Key('chat-star-s')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(starred, isFalse);
|
||||
expect(
|
||||
find.byIcon(cupertino ? CupertinoIcons.star : Icons.star_border),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.byType(SessionHarnessIcon),
|
||||
findsOneWidget,
|
||||
reason: 'Changing favorite must not change harness identity',
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user