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.
165 lines
6.1 KiB
Dart
165 lines
6.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/search/search_screen.dart';
|
|
import 'package:pipelines_app/features/search/ui/search_bar_controls.dart';
|
|
import 'package:pipelines_app/features/search/ui/search_bounds_note.dart';
|
|
import 'package:pipelines_app/features/search/ui/search_layout.dart';
|
|
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
|
import 'package:pipelines_app/ui/layout/app_list_row.dart';
|
|
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
|
|
|
import 'search_screen_test.dart'
|
|
show ImmediateGateway, field, pipeline, response;
|
|
|
|
void _size(WidgetTester tester, double width) {
|
|
tester.view.physicalSize = Size(width, 800);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
}
|
|
|
|
Future<void> _search(WidgetTester tester, String query) async {
|
|
await tester.enterText(find.byKey(searchFieldKey), query);
|
|
await tester.pump(const Duration(milliseconds: 300));
|
|
await tester.pumpAndSettle();
|
|
}
|
|
|
|
Widget _app(Widget child) => MaterialApp(home: child);
|
|
|
|
void main() {
|
|
testWidgets('the field, Kind and help live in the bar pill', (tester) async {
|
|
_size(tester, 390);
|
|
final gateway = ImmediateGateway((_, _) => response([pipeline]));
|
|
await tester.pumpWidget(
|
|
_app(SearchScreen(gateway: gateway, onOpen: (_) {})),
|
|
);
|
|
|
|
for (final key in [searchFieldKey, searchKindKey, searchHelpKey]) {
|
|
expect(
|
|
find.descendant(
|
|
of: find.byType(SegmentedBar),
|
|
matching: find.byKey(key),
|
|
),
|
|
findsOneWidget,
|
|
reason: '$key is in the bar',
|
|
);
|
|
}
|
|
// One field: no elevated SearchBar, no dropdown and no native field.
|
|
expect(find.byType(SearchBar), findsNothing);
|
|
expect(find.byType(DropdownButton), findsNothing);
|
|
// The syntax help is behind the info button, not on the page.
|
|
expect(find.text(searchTokenHint), findsNothing);
|
|
await tester.tap(find.byKey(searchHelpKey));
|
|
await tester.pumpAndSettle();
|
|
expect(find.text(searchTokenHint), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('stats appear only for a truncated answer', (tester) async {
|
|
_size(tester, 390);
|
|
var truncated = false;
|
|
final gateway = ImmediateGateway((_, _) {
|
|
final reply = response([pipeline]);
|
|
(reply['search_results'] as Map)['truncated'] = truncated;
|
|
return reply;
|
|
});
|
|
await tester.pumpWidget(
|
|
_app(SearchScreen(gateway: gateway, onOpen: (_) {})),
|
|
);
|
|
|
|
await _search(tester, 'release');
|
|
expect(find.text('Release planner'), findsOneWidget);
|
|
expect(find.byKey(searchBoundsKey), findsNothing);
|
|
expect(find.textContaining('scanned'), findsNothing);
|
|
|
|
truncated = true;
|
|
await _search(tester, 'releases');
|
|
expect(find.byKey(searchBoundsKey), findsOneWidget);
|
|
expect(find.textContaining('Results truncated'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('rows are the shared row: title, kind-led line', (tester) async {
|
|
_size(tester, 390);
|
|
final gateway = ImmediateGateway((_, _) => response([field]));
|
|
await tester.pumpWidget(
|
|
_app(SearchScreen(gateway: gateway, onOpen: (_) {})),
|
|
);
|
|
await _search(tester, 'release');
|
|
|
|
final row = find.byKey(const ValueKey('search.result.run:11:4:output'));
|
|
expect(row, findsOneWidget);
|
|
expect(tester.widget<AppListRow>(row).title, isNotNull);
|
|
// The kind leads the one muted line, before the snippet.
|
|
expect(
|
|
find.descendant(of: row, matching: find.textContaining('Field · ')),
|
|
findsOneWidget,
|
|
);
|
|
expect(
|
|
find.descendant(
|
|
of: row,
|
|
matching: find.textContaining('the release is ready'),
|
|
),
|
|
findsOneWidget,
|
|
);
|
|
});
|
|
|
|
testWidgets('results run behind the bar in a capped column', (tester) async {
|
|
_size(tester, 1200);
|
|
final gateway = ImmediateGateway((_, _) => response([pipeline]));
|
|
await tester.pumpWidget(
|
|
_app(SearchScreen(gateway: gateway, onOpen: (_) {})),
|
|
);
|
|
await _search(tester, 'release');
|
|
|
|
// The scroll view reaches the top edge; its first row starts below
|
|
// the floating bar.
|
|
final scroll = find.byType(CustomScrollView);
|
|
expect(tester.getTopLeft(scroll).dy, 0);
|
|
final barBottom = tester.getBottomLeft(find.byType(SegmentedBar)).dy;
|
|
final row = find.byKey(const ValueKey('search.result.pipeline:7'));
|
|
expect(tester.getTopLeft(row).dy, greaterThanOrEqualTo(barBottom - 8));
|
|
// The row spans the whole window between the bar's insets: no
|
|
// reading-width cap on a wide window.
|
|
final rect = tester.getRect(row);
|
|
expect(rect.left, kSearchContentInset);
|
|
expect(rect.right, 1200 - kSearchContentInset);
|
|
});
|
|
|
|
for (final width in [390.0, 880.0, 1200.0, 1400.0]) {
|
|
testWidgets('at $width the field takes the title\'s place and '
|
|
'the results line up with it', (tester) async {
|
|
_size(tester, width);
|
|
final gateway = ImmediateGateway((_, _) => response([pipeline]));
|
|
await tester.pumpWidget(
|
|
_app(SearchScreen(gateway: gateway, onOpen: (_) {})),
|
|
);
|
|
await _search(tester, 'release');
|
|
|
|
final bar = find.byType(SegmentedBar);
|
|
// No Search title pill: the field's pill is the bar's only piece.
|
|
expect(
|
|
find.descendant(of: bar, matching: find.text('Search')),
|
|
findsNothing,
|
|
);
|
|
expect(
|
|
find.descendant(of: bar, matching: find.byType(GlassPill)),
|
|
findsOneWidget,
|
|
);
|
|
final pill = tester.getRect(
|
|
find.descendant(of: bar, matching: find.byType(GlassPill)),
|
|
);
|
|
expect(pill.left, kSearchContentInset);
|
|
// The pill grows with the bar: the whole width between its insets.
|
|
expect(pill.width, width - 2 * kSearchContentInset);
|
|
// The field fills the pill beside Kind and the help.
|
|
final field = tester.getRect(find.byKey(searchFieldKey));
|
|
expect(field.width, greaterThan(pill.width * 0.6));
|
|
// The result column shares the pill's edges, so it spans the pane.
|
|
final row = tester.getRect(
|
|
find.byKey(const ValueKey('search.result.pipeline:7')),
|
|
);
|
|
expect(row.left, pill.left);
|
|
expect(row.right, pill.right);
|
|
});
|
|
}
|
|
}
|