9551eceaed
Remove obsolete control-family flags and icon metadata across all callers, dead alternate themes and host helpers, obsolete test setup, and the unused icon-font dependency. Preserve native Material Back transitions. Make navigation fixtures independent of update plugins and answer auxiliary shell snapshots so the complete application suite can run deterministically.
110 lines
3.9 KiB
Dart
110 lines
3.9 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/search/search_screen.dart';
|
|
import 'package:pipelines_app/features/search/ui/search_result_slivers.dart';
|
|
|
|
import 'search_screen_test.dart'
|
|
show ImmediateGateway, field, response, search, useNarrowSurface;
|
|
import 'search_test_support.dart' show chatHit;
|
|
|
|
/// Run hits for every kind but chat; chat hits for the chat request.
|
|
JsonMap replies(String query, String kind) => kind == 'chat'
|
|
? response([
|
|
chatHit('ses_a', title: 'API refactor', snippet: 'the release retry'),
|
|
chatHit('ses_b', title: 'Release notes'),
|
|
])
|
|
: response([field]);
|
|
|
|
Widget host(Widget child) => MaterialApp(home: child);
|
|
|
|
void main() {
|
|
testWidgets('chat hits lead as a Chats group with title, '
|
|
'harness, directory and snippet, and open their chat', (tester) async {
|
|
useNarrowSurface(tester);
|
|
final gateway = ImmediateGateway(replies);
|
|
JsonMap? opened;
|
|
await tester.pumpWidget(
|
|
host(SearchScreen(gateway: gateway, onOpen: (value) => opened = value)),
|
|
);
|
|
await search(tester, 'release');
|
|
|
|
expect(gateway.calls.single['search'], {
|
|
'query': 'release',
|
|
'kind': '',
|
|
'limit': 0,
|
|
});
|
|
expect(gateway.chatCalls.single['search'], {
|
|
'query': 'release',
|
|
'kind': 'chat',
|
|
'limit': 0,
|
|
});
|
|
expect(find.text('Chats (2)'), findsOneWidget);
|
|
expect(find.text('Pipelines and runs'), findsOneWidget);
|
|
final chats = tester.getTopLeft(find.byKey(searchChatsSectionKey));
|
|
final others = tester.getTopLeft(find.byKey(searchOthersSectionKey));
|
|
final chatRow = find.byKey(const ValueKey('search.result.chat:ses_a'));
|
|
final runRow = find.byKey(const ValueKey('search.result.run:11:4:output'));
|
|
expect(chats.dy, lessThan(tester.getTopLeft(chatRow).dy));
|
|
expect(tester.getTopLeft(chatRow).dy, lessThan(others.dy));
|
|
expect(others.dy, lessThan(tester.getTopLeft(runRow).dy));
|
|
|
|
expect(find.text('API refactor'), findsOneWidget);
|
|
expect(find.text('Release notes'), findsOneWidget);
|
|
expect(
|
|
find.textContaining('Chat · Claude Code · /work/api'),
|
|
findsNWidgets(2),
|
|
);
|
|
expect(find.textContaining('the release retry'), findsOneWidget);
|
|
expect(tester.takeException(), isNull);
|
|
|
|
await tester.tap(chatRow);
|
|
await tester.pump();
|
|
expect(opened?['target'], 'chat:ses_a');
|
|
expect((opened?['chat'] as Map)['session_id'], 'ses_a');
|
|
});
|
|
|
|
testWidgets('Chats selected alone lists chats without group headings', (
|
|
tester,
|
|
) async {
|
|
useNarrowSurface(tester);
|
|
final gateway = ImmediateGateway(replies);
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: SearchScreen(gateway: gateway, onOpen: (_) {}),
|
|
),
|
|
);
|
|
await search(tester, 't:chat release');
|
|
|
|
expect(gateway.calls, isEmpty);
|
|
expect(gateway.chatCalls, hasLength(1));
|
|
expect(find.text('API refactor'), findsOneWidget);
|
|
expect(find.byKey(searchChatsSectionKey), findsNothing);
|
|
expect(find.byKey(searchOthersSectionKey), findsNothing);
|
|
});
|
|
|
|
testWidgets('an older server without chat search keeps its run results and '
|
|
'says chats were not searched', (tester) async {
|
|
useNarrowSurface(tester);
|
|
final gateway = ImmediateGateway((query, kind) {
|
|
if (kind == 'chat') {
|
|
throw StateError('unknown search kind "chat"; use one of pipeline');
|
|
}
|
|
return response([field]);
|
|
});
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: SearchScreen(gateway: gateway, onOpen: (_) {}),
|
|
),
|
|
);
|
|
await search(tester, 'release');
|
|
|
|
expect(
|
|
find.byKey(const ValueKey('search.result.run:11:4:output')),
|
|
findsOneWidget,
|
|
);
|
|
expect(find.byKey(searchChatsNoteKey), findsOneWidget);
|
|
expect(find.textContaining('does not search chats'), findsOneWidget);
|
|
});
|
|
}
|