Merge branch 'worktree-agent-a82ec5e9fdf8ca159' into integrate/gaps-e
# Conflicts: # app/test/features/search/search_bar_layout_test.dart
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/schedules/screen.dart';
|
||||
import 'package:pipelines_app/features/schedules/ui/list/schedule_list_toolbar.dart';
|
||||
import 'package:pipelines_app/features/schedules/ui/list/schedule_list_view.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||
|
||||
import 'schedule_list_test_support.dart';
|
||||
|
||||
/// The schedule list under a floating bar: search, filter and count are a
|
||||
/// glass strip under the bar, and the list scrolls behind both.
|
||||
void main() {
|
||||
Future<void> pump(WidgetTester tester, {required bool cupertino}) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
final gateway = FakeSchedulesGateway(
|
||||
(type, fields) async => schedulesReply(longScheduleList(30)),
|
||||
);
|
||||
final screen = SchedulesScreen(gateway: gateway, onOpen: (_) {});
|
||||
final bar = SegmentedBar(cupertino: cupertino, title: 'Schedules');
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(
|
||||
home: CupertinoPageScaffold(navigationBar: bar, child: screen),
|
||||
)
|
||||
: MaterialApp(
|
||||
home: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: bar,
|
||||
body: screen,
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
Rect pieceOf(WidgetTester tester, Finder owner) => tester.getRect(
|
||||
find.descendant(of: owner, matching: find.byType(GlassPill)).first,
|
||||
);
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
|
||||
testWidgets('$host: the toolbar floats under the bar and the list '
|
||||
'scrolls behind it', (tester) async {
|
||||
await pump(tester, cupertino: cupertino);
|
||||
|
||||
final bar = pieceOf(tester, find.byType(SegmentedBar));
|
||||
final strip = pieceOf(tester, find.byKey(scheduleToolbarKey));
|
||||
expect(strip.top, greaterThanOrEqualTo(bar.bottom));
|
||||
expect(strip.top - bar.bottom, lessThan(24));
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(scheduleToolbarKey),
|
||||
matching: find.byKey(scheduleSearchFieldKey),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
final list = find.byKey(scheduleListKey);
|
||||
expect(tester.getTopLeft(list).dy, 0);
|
||||
final firstRow = find.byKey(const ValueKey('schedule-row-0-100'));
|
||||
final rest = tester.getTopLeft(firstRow).dy;
|
||||
expect(rest, greaterThanOrEqualTo(strip.bottom));
|
||||
|
||||
await tester.drag(list, const Offset(0, -120));
|
||||
await tester.pump();
|
||||
expect(tester.getTopLeft(firstRow).dy, lessThan(strip.bottom));
|
||||
});
|
||||
|
||||
testWidgets('$host: a query that empties the list keeps the field', (
|
||||
tester,
|
||||
) async {
|
||||
await pump(tester, cupertino: cupertino);
|
||||
final field = find.byKey(scheduleSearchFieldKey);
|
||||
await tester.tap(field);
|
||||
await tester.pump();
|
||||
final before = tester.element(field);
|
||||
await tester.enterText(field, 'no schedule matches this');
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('No schedules match this search.'), findsOneWidget);
|
||||
expect(tester.element(field), same(before));
|
||||
final editable = tester.state<EditableTextState>(
|
||||
find.descendant(of: field, matching: find.byType(EditableText)),
|
||||
);
|
||||
expect(editable.widget.focusNode.hasFocus, isTrue);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user