Search field in the bar, refresh and Back as bar pieces, even Cupertino actions (F8/F28/F10/F11/F20/F1)

- Search: field, compact Kind menu and syntax help in the bar's actions pill;
  bounds shown only when truncated; rows with bold title, kind tag and one
  muted line; results run behind the bar in a start-aligned 840 column.
- AppSearchField: one search field per platform (Search, Schedules, Runs filter).
- BarIconButton: whole 44pt/48dp bar actions; Runs, bell and Pipelines icons
  use the same 44pt targets on Cupertino.
- Templates and Schedules pages put Refresh in the bar and use the shared
  round SegmentedBackButton; Templates shows one Back at a time.
- PipelineBackButton is the round segmented Back.
- notes/pages-fixes.md records the batch, tests and evidence.
This commit is contained in:
2026-10-31 03:31:25 +00:00
parent 3ec580c2d9
commit 3704d98d4d
27 changed files with 1380 additions and 488 deletions
@@ -0,0 +1,157 @@
import 'package:flutter/cupertino.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/features/search/ui/search_result_view.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(bool cupertino, Widget child) =>
cupertino ? CupertinoApp(home: child) : MaterialApp(home: child);
void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('$host: the field, Kind and help live in the bar pill', (
tester,
) async {
_size(tester, 390);
final gateway = ImmediateGateway((_, _) => response([pipeline]));
await tester.pumpWidget(
_app(
cupertino,
SearchScreen(gateway: gateway, onOpen: (_) {}, cupertino: cupertino),
),
);
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 per platform: no elevated SearchBar, no dropdown.
expect(find.byType(SearchBar), findsNothing);
expect(find.byType(DropdownButton), findsNothing);
expect(
find.byType(CupertinoSearchTextField),
cupertino ? findsOneWidget : 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('$host: 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(
cupertino,
SearchScreen(gateway: gateway, onOpen: (_) {}, cupertino: cupertino),
),
);
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('$host: rows show a bold title, a kind tag and one line', (
tester,
) async {
_size(tester, 390);
final gateway = ImmediateGateway((_, _) => response([field]));
await tester.pumpWidget(
_app(
cupertino,
SearchScreen(gateway: gateway, onOpen: (_) {}, cupertino: cupertino),
),
);
await _search(tester, 'release');
final row = find.byKey(const ValueKey('search.result.run:11:4:output'));
expect(row, findsOneWidget);
expect(
find.descendant(of: row, matching: find.byType(SearchKindTag)),
findsOneWidget,
);
expect(
find.descendant(
of: row,
matching: find.textContaining('the release is ready'),
),
findsOneWidget,
);
});
testWidgets('$host: results run behind the bar in a capped column', (
tester,
) async {
_size(tester, 1200);
final gateway = ImmediateGateway((_, _) => response([pipeline]));
await tester.pumpWidget(
_app(
cupertino,
SearchScreen(gateway: gateway, onOpen: (_) {}, cupertino: cupertino),
),
);
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));
// Start-aligned under the bar's inset, no wider than the cap.
final rect = tester.getRect(row);
expect(rect.left, greaterThanOrEqualTo(kSearchContentInset));
expect(rect.right, lessThanOrEqualTo(kSearchContentInset + 840));
// The search pill keeps to its own cap on a wide window.
expect(
tester.getSize(find.byKey(searchBarControlsKey)).width,
lessThanOrEqualTo(kSearchPillMaxWidth),
);
});
}
}
@@ -1,6 +1,7 @@
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/domain/search_models.dart';
import 'package:pipelines_app/features/search/search_screen.dart';
class RecordingGateway implements ApiGateway {
@@ -135,10 +136,15 @@ void main() {
await tester.tap(find.byKey(const ValueKey('search.kind')));
await tester.pumpAndSettle();
await tester.tap(find.text('Pipelines').last);
await tester.tap(
find.ancestor(
of: find.text('Pipelines').last,
matching: find.byType(CheckedPopupMenuItem<SearchKind>),
),
);
await tester.pumpAndSettle();
final field = tester.widget<SearchBar>(
final field = tester.widget<TextField>(
find.byKey(const ValueKey('search.field')),
);
expect(field.controller!.text.trim(), 'plan');
@@ -2,7 +2,6 @@ import 'package:flutter/cupertino.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/domain/search_models.dart';
import 'package:pipelines_app/features/search/search_screen.dart';
class ImmediateGateway implements ApiGateway {
@@ -116,9 +115,10 @@ void main() {
),
);
expect(find.byType(SearchBar), findsOneWidget);
expect(find.byType(DropdownButton<SearchKind>), findsOneWidget);
expect(find.text('All kinds'), findsOneWidget);
expect(find.byType(SearchBar), findsNothing);
expect(find.byType(TextField), findsOneWidget);
expect(find.byKey(const ValueKey('search.kind')), findsOneWidget);
expect(find.byTooltip('Kind: All kinds'), findsOneWidget);
expect(gateway.calls, isEmpty);
await search(tester, 'release');