e34fa1050e
- SegmentedBar.titleWidget (and ShellBar/ShellBarSpec titleWidget, backgroundColor): a bar's main pill can be an input in place of the title; Search uses it so the field fills the bar with Kind and info, capped at the result column width so field and results share edges on wide windows. - Templates page/frame drop the top SafeArea again (BelowTopBar gate, TopBarNotices banners); Cupertino uses the grouped background. - Settings on Cupertino in the shell publishes the grouped background so the bar scrim matches the page (no white band or seam). - TopGlassStrip: the run detail header (status, actions, decision, notices) and the Schedules search/filter toolbar float as glass under the bar; tabs and lists scroll behind both. - Stage page: stage title and Visit/Run subtitle in the bar, facts lead the Summary scroll, sections scroll behind the bar under floating tabs. - Tests for content-behind-bar on each page and the title-widget bar mode; notes/chrome-gaps-fixes.md.
208 lines
7.2 KiB
Dart
208 lines
7.2 KiB
Dart
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/glass_pill.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),
|
|
);
|
|
});
|
|
|
|
for (final width in [390.0, 1200.0]) {
|
|
testWidgets('$host: 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(
|
|
cupertino,
|
|
SearchScreen(
|
|
gateway: gateway,
|
|
onOpen: (_) {},
|
|
cupertino: cupertino,
|
|
),
|
|
),
|
|
);
|
|
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);
|
|
expect(
|
|
pill.width,
|
|
width - 2 * kSearchContentInset < kSearchPillMaxWidth
|
|
? width - 2 * kSearchContentInset
|
|
: kSearchPillMaxWidth,
|
|
);
|
|
// 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.
|
|
final row = tester.getRect(
|
|
find.byKey(const ValueKey('search.result.pipeline:7')),
|
|
);
|
|
expect(row.left, pill.left);
|
|
expect(row.right, pill.right);
|
|
});
|
|
}
|
|
}
|
|
}
|