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
@@ -6,6 +6,8 @@ import 'package:pipelines_app/application/app_session.dart';
import 'package:pipelines_app/application/schedules_destination.dart';
import 'package:pipelines_app/application/server_endpoint.dart';
import 'package:pipelines_app/core/transport/pipelines_client.dart';
import 'package:pipelines_app/features/schedules/ui/list/schedule_list_toolbar.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
@@ -67,5 +69,15 @@ void main() {
await tester.pump();
await tester.pump();
expect(find.text('Nightly review'), findsOneWidget);
// Back and Refresh are bar pieces; the body has neither.
Finder inBar(Key key) => find.descendant(
of: find.byType(SegmentedBar),
matching: find.byKey(key),
);
expect(inBar(schedulesPageBackKey), findsOneWidget);
expect(inBar(scheduleRefreshKey), findsOneWidget);
expect(find.byKey(scheduleRefreshKey), findsOneWidget);
expect(find.byType(SegmentedBackButton), findsOneWidget);
});
}
@@ -211,14 +211,31 @@ void main() {
expect(sockets, 1);
expect(requestsOf(channel, 'list_templates'), hasLength(1));
// Refresh sits in the bar's actions pill, not in the body.
Finder inBar(Key key) => find.descendant(
of: find.byType(SegmentedBar),
matching: find.byKey(key),
);
expect(inBar(templatesRefreshKey), findsOneWidget);
expect(find.byKey(templatesRefreshKey), findsOneWidget);
expect(inBar(templatesPageBackKey), findsOneWidget);
await tester.tap(find.byKey(templateRowKey('release')));
await tester.pump();
await tester.pump();
expect(find.text('Definition source'), findsOneWidget);
// One Back at a time, in the bar's round leading piece: the open
// template's Back replaces the page's.
expect(inBar(templateDetailBackKey), findsOneWidget);
expect(find.byKey(templateDetailBackKey), findsOneWidget);
expect(find.byKey(templatesPageBackKey), findsNothing);
// Detail Back returns to the gallery, then the page Back restores the
// same Settings state.
await tester.tap(find.byKey(templateDetailBackKey));
await tester.pump();
// The gallery hands the bar back to the page's Back on the next frame.
await tester.pump();
await tester.tap(find.byKey(templatesPageBackKey));
await tester.pumpAndSettle();
@@ -333,6 +350,8 @@ void main() {
await tester.pump();
await tester.tap(find.byKey(templateDetailBackKey));
await tester.pump();
// The gallery hands the bar back to the page's Back on the next frame.
await tester.pump();
await tester.tap(find.byKey(templatesPageBackKey));
await tester.pumpAndSettle();
await tester.tap(find.text('Pipelines').last);
@@ -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');
@@ -0,0 +1,95 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/input/app_search_field.dart';
import 'package:pipelines_app/ui/navigation/bar_icon_button.dart';
Widget _row(bool cupertino, List<Widget> children) {
final row = Center(
child: Row(mainAxisSize: MainAxisSize.min, children: children),
);
return cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: row))
: MaterialApp(home: Scaffold(body: row));
}
BarIconButton _action(Key key, {bool busy = false}) => BarIconButton(
key: key,
icon: Icons.refresh,
cupertinoIcon: CupertinoIcons.refresh,
label: 'Refresh',
busy: busy,
onPressed: () {},
);
void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
final side = cupertino
? kMinInteractiveDimensionCupertino
: kMinInteractiveDimension;
testWidgets('$host bar actions are whole, evenly sized touch targets', (
tester,
) async {
await tester.pumpWidget(
_row(cupertino, [
_action(const ValueKey('a')),
_action(const ValueKey('b')),
_action(const ValueKey('c'), busy: true),
]),
);
for (final key in const ['a', 'b', 'c']) {
expect(tester.getSize(find.byKey(ValueKey(key))), Size(side, side));
}
// Adjacent actions abut: the spacing is the targets', not padding.
expect(
tester.getTopLeft(find.byKey(const ValueKey('b'))).dx -
tester.getTopLeft(find.byKey(const ValueKey('a'))).dx,
side,
);
if (cupertino) expect(find.byType(Material), findsNothing);
expect(find.bySemanticsLabel('Refresh'), findsWidgets);
});
testWidgets('$host search field is one stadium field with a clear', (
tester,
) async {
final text = TextEditingController();
addTearDown(text.dispose);
var cleared = false;
await tester.pumpWidget(
_row(cupertino, [
SizedBox(
width: 300,
child: AppSearchField(
fieldKey: const ValueKey('field'),
controller: text,
placeholder: 'Search',
onCleared: () => cleared = true,
),
),
]),
);
if (cupertino) {
expect(find.byType(CupertinoSearchTextField), findsOneWidget);
expect(find.byType(Material), findsNothing);
return;
}
final field = tester.widget<TextField>(
find.byKey(const ValueKey('field')),
);
final border = field.decoration!.enabledBorder! as OutlineInputBorder;
expect(border.borderSide, BorderSide.none);
expect(field.decoration!.filled, isTrue);
expect(find.byTooltip('Clear search'), findsNothing);
await tester.enterText(find.byKey(const ValueKey('field')), 'abc');
await tester.pump();
await tester.tap(find.byTooltip('Clear search'));
await tester.pump();
expect(text.text, isEmpty);
expect(cleared, isTrue);
});
}
}