Merge branch 'main' into pipelines/run-20261111-0323-cupertino-out-shell-eacf
# Conflicts: # app/test/application/search_artifact_open_test.dart # app/test/application/search_chat_open_test.dart
This commit is contained in:
@@ -294,59 +294,46 @@ void main() {
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('a file opens as a page that steps to the previous and next '
|
||||
'file (${cupertino ? 'cupertino' : 'material'})', (tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
final viewer = ChangesViewer(
|
||||
steps: [
|
||||
stepFixture(
|
||||
fileChanges: captureFixture(
|
||||
files: [
|
||||
fileChangeFixture(
|
||||
path: 'lib/first.dart',
|
||||
patch: multiHunkPatch,
|
||||
),
|
||||
fileChangeFixture(
|
||||
path: 'lib/second.dart',
|
||||
patch: multiHunkPatch,
|
||||
),
|
||||
],
|
||||
),
|
||||
testWidgets('a file opens as a page that steps to the previous and next '
|
||||
'file', (tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
final viewer = ChangesViewer(
|
||||
steps: [
|
||||
stepFixture(
|
||||
fileChanges: captureFixture(
|
||||
files: [
|
||||
fileChangeFixture(path: 'lib/first.dart', patch: multiHunkPatch),
|
||||
fileChangeFixture(path: 'lib/second.dart', patch: multiHunkPatch),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino ? cupertinoHost(viewer) : materialHost(viewer),
|
||||
);
|
||||
await tester.tap(find.byKey(const ValueKey('change-1-lib/first.dart')));
|
||||
await tester.pumpAndSettle();
|
||||
),
|
||||
],
|
||||
);
|
||||
await tester.pumpWidget(materialHost(viewer));
|
||||
await tester.tap(find.byKey(const ValueKey('change-1-lib/first.dart')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
Finder control(String label) =>
|
||||
cupertino ? find.bySemanticsLabel(label) : find.byTooltip(label);
|
||||
expect(find.byType(FileDiffPage), findsOneWidget);
|
||||
expect(find.text('first.dart'), findsOneWidget);
|
||||
expect(find.text('1 of 2'), findsOneWidget);
|
||||
// The pager sits at the bottom right.
|
||||
final pager = tester.getRect(
|
||||
find.byKey(const ValueKey('file-diff-pager')),
|
||||
);
|
||||
expect(pager.bottom, greaterThan(844 - 120));
|
||||
final next = tester.getRect(control('Next file'));
|
||||
expect(next.right, greaterThan(390 - 80));
|
||||
Finder control(String label) => find.byTooltip(label);
|
||||
expect(find.byType(FileDiffPage), findsOneWidget);
|
||||
expect(find.text('first.dart'), findsOneWidget);
|
||||
expect(find.text('1 of 2'), findsOneWidget);
|
||||
// The pager sits at the bottom right.
|
||||
final pager = tester.getRect(find.byKey(const ValueKey('file-diff-pager')));
|
||||
expect(pager.bottom, greaterThan(844 - 120));
|
||||
final next = tester.getRect(control('Next file'));
|
||||
expect(next.right, greaterThan(390 - 80));
|
||||
|
||||
await tester.tap(control('Next file'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('second.dart'), findsOneWidget);
|
||||
expect(find.text('2 of 2'), findsOneWidget);
|
||||
await tester.tap(control('Previous file'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('first.dart'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
await tester.tap(control('Next file'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('second.dart'), findsOneWidget);
|
||||
expect(find.text('2 of 2'), findsOneWidget);
|
||||
await tester.tap(control('Previous file'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('first.dart'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
final diffFile = FileChange(
|
||||
path: 'lib/feature.dart',
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
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';
|
||||
@@ -85,33 +84,28 @@ void main() {
|
||||
expect(next.bottom, greaterThan(844 - 80));
|
||||
});
|
||||
|
||||
for (final host in ['Material', 'Cupertino']) {
|
||||
for (final size in [
|
||||
const Size(390, 844),
|
||||
const Size(880, 1000),
|
||||
const Size(1100, 800),
|
||||
]) {
|
||||
testWidgets('$host pager clears an inherited stacked bar at $size', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = size;
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
final child = ChangesViewer(steps: twoVisitRun());
|
||||
final hosted = host == 'Material'
|
||||
? materialHost(child)
|
||||
: cupertinoHost(child);
|
||||
await tester.pumpWidget(
|
||||
MediaQuery(
|
||||
data: const MediaQueryData(padding: EdgeInsets.only(bottom: 120)),
|
||||
child: hosted,
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
final pager = tester.getRect(find.byKey(ChangesVisitPager.nextKey));
|
||||
expect(pager.bottom, lessThanOrEqualTo(size.height - 120));
|
||||
});
|
||||
}
|
||||
for (final size in [
|
||||
const Size(390, 844),
|
||||
const Size(880, 1000),
|
||||
const Size(1100, 800),
|
||||
]) {
|
||||
testWidgets('Material pager clears an inherited stacked bar at $size', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = size;
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
final child = ChangesViewer(steps: twoVisitRun());
|
||||
await tester.pumpWidget(
|
||||
MediaQuery(
|
||||
data: const MediaQueryData(padding: EdgeInsets.only(bottom: 120)),
|
||||
child: materialHost(child),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
final pager = tester.getRect(find.byKey(ChangesVisitPager.nextKey));
|
||||
expect(pager.bottom, lessThanOrEqualTo(size.height - 120));
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('paging stops at both ends instead of wrapping', (tester) async {
|
||||
@@ -220,31 +214,4 @@ void main() {
|
||||
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
||||
expect(find.text('lib/c.dart'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino pages with native buttons at both ends', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(cupertinoHost(ChangesViewer(steps: twoVisitRun())));
|
||||
|
||||
final previous = tester.widget<CupertinoButton>(
|
||||
find.byKey(ChangesVisitPager.previousKey),
|
||||
);
|
||||
final next = tester.widget<CupertinoButton>(
|
||||
find.byKey(ChangesVisitPager.nextKey),
|
||||
);
|
||||
expect(previous.onPressed, isNull);
|
||||
expect(next.onPressed, isNotNull);
|
||||
expect(find.byKey(ChangesVisitPager.previousKey), findsOneWidget);
|
||||
expect(find.byKey(ChangesVisitPager.nextKey), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
||||
await tester.pump();
|
||||
expect(find.text('reviewer'), findsNothing);
|
||||
expect(
|
||||
tester
|
||||
.widget<CupertinoButton>(find.byKey(ChangesVisitPager.nextKey))
|
||||
.onPressed,
|
||||
isNull,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ void main() {
|
||||
await mount(tester, onSelected: (id) => selectedRun = id);
|
||||
|
||||
// The text filter lives in the filter sheet.
|
||||
expect(find.byType(TextField), findsNothing);
|
||||
expect(find.text('Alpha'), findsOneWidget);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.filter')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
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';
|
||||
@@ -39,11 +38,7 @@ void main() {
|
||||
await gateway.framesController.close();
|
||||
});
|
||||
|
||||
Future<void> mount(
|
||||
WidgetTester tester, {
|
||||
required bool cupertino,
|
||||
String? createdAt,
|
||||
}) async {
|
||||
Future<void> mount(WidgetTester tester, {String? createdAt}) async {
|
||||
tester.view.physicalSize = const Size(800, 1400);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
@@ -67,54 +62,44 @@ void main() {
|
||||
builder: (context, _) =>
|
||||
RunsList(controller: controller, onSelected: (_) {}),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: list))
|
||||
: MaterialApp(home: Scaffold(body: list)),
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: list)));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
testWidgets('filter sheet has a header whose Done closes it', (tester) async {
|
||||
await mount(tester);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.filter')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
testWidgets('$host filter sheet has a header whose Done closes it', (
|
||||
tester,
|
||||
) async {
|
||||
await mount(tester, cupertino: cupertino);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.filter')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(AppSheetHeader), findsOneWidget);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byType(AppSheetHeader),
|
||||
matching: find.text(runsFilterTitle),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Queued'), findsOneWidget);
|
||||
expect(find.text('queued'), findsNothing);
|
||||
expect(find.byKey(runsFilterClearKey), findsNothing);
|
||||
|
||||
expect(find.byType(AppSheetHeader), findsOneWidget);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byType(AppSheetHeader),
|
||||
matching: find.text(runsFilterTitle),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Queued'), findsOneWidget);
|
||||
expect(find.text('queued'), findsNothing);
|
||||
expect(find.byKey(runsFilterClearKey), findsNothing);
|
||||
await tester.tap(find.text('Last 7 days'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.timeRange, 'last_7_days');
|
||||
// An active filter offers Clear in the header.
|
||||
expect(find.byKey(runsFilterClearKey), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text('Last 7 days'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.timeRange, 'last_7_days');
|
||||
// An active filter offers Clear in the header.
|
||||
expect(find.byKey(runsFilterClearKey), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(runsFilterDoneKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const ValueKey('runs.filter.sheet')), findsNothing);
|
||||
// The applied chip reads in sentence case too.
|
||||
expect(find.textContaining('Last 7 days'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
await tester.tap(find.byKey(runsFilterDoneKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const ValueKey('runs.filter.sheet')), findsNothing);
|
||||
// The applied chip reads in sentence case too.
|
||||
expect(find.textContaining('Last 7 days'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Material single-choice groups are check rows, not checkboxes', (
|
||||
tester,
|
||||
) async {
|
||||
await mount(tester, cupertino: false);
|
||||
await mount(tester);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.filter')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -139,7 +124,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Material sort opens an anchored choice menu', (tester) async {
|
||||
await mount(tester, cupertino: false);
|
||||
await mount(tester);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.sort')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const ValueKey('app-choice-menu')), findsOneWidget);
|
||||
@@ -153,7 +138,6 @@ void main() {
|
||||
) async {
|
||||
await mount(
|
||||
tester,
|
||||
cupertino: false,
|
||||
createdAt: DateTime(2020, 1, 1).toIso8601String(),
|
||||
);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.stats')));
|
||||
@@ -171,7 +155,7 @@ void main() {
|
||||
testWidgets('the 7-day chart shows bars over an axis when runs started', (
|
||||
tester,
|
||||
) async {
|
||||
await mount(tester, cupertino: true);
|
||||
await mount(tester);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.stats')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const ValueKey('runs.stats.days')), findsOneWidget);
|
||||
|
||||
@@ -146,13 +146,13 @@ void main() {
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'cupertino: the filter sheet filters and its chip clears the facet',
|
||||
'the filter sheet filters and its chip clears the facet',
|
||||
(tester) async {
|
||||
await mount(tester, cupertino: true);
|
||||
await mount(tester, cupertino: false);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.filter')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(CupertinoSearchTextField), findsOneWidget);
|
||||
final failed = find.widgetWithText(CupertinoListTile, 'Failed');
|
||||
expect(find.byType(TextField), findsOneWidget);
|
||||
final failed = find.widgetWithText(ListTile, 'Failed');
|
||||
await reveal(tester, failed);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(failed);
|
||||
@@ -160,10 +160,12 @@ void main() {
|
||||
expect(controller.statuses, {'failed'});
|
||||
await closeSheet(tester);
|
||||
|
||||
final failedChip = find.widgetWithText(CupertinoButton, 'Failed');
|
||||
final failedChip = find.widgetWithText(InputChip, 'Failed');
|
||||
expect(failedChip, findsOneWidget);
|
||||
expect(find.text('Alpha'), findsNothing);
|
||||
await tester.tap(failedChip);
|
||||
await tester.tap(
|
||||
find.descendant(of: failedChip, matching: find.byType(Tooltip)),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.statuses, isEmpty);
|
||||
expect(find.text('Alpha'), findsOneWidget);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
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';
|
||||
@@ -12,7 +11,7 @@ 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 {
|
||||
Future<void> pump(WidgetTester tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
@@ -20,19 +19,15 @@ void main() {
|
||||
(type, fields) async => schedulesReply(longScheduleList(30)),
|
||||
);
|
||||
final screen = SchedulesScreen(gateway: gateway, onOpen: (_) {});
|
||||
final bar = SegmentedBar(cupertino: cupertino, title: 'Schedules');
|
||||
final bar = const SegmentedBar(cupertino: false, title: 'Schedules');
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(
|
||||
home: CupertinoPageScaffold(navigationBar: bar, child: screen),
|
||||
)
|
||||
: MaterialApp(
|
||||
home: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: bar,
|
||||
body: screen,
|
||||
),
|
||||
),
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: bar,
|
||||
body: screen,
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
@@ -41,53 +36,47 @@ void main() {
|
||||
find.descendant(of: owner, matching: find.byType(GlassPill)).first,
|
||||
);
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
testWidgets('the toolbar floats under the bar and the list '
|
||||
'scrolls behind it', (tester) async {
|
||||
await pump(tester);
|
||||
|
||||
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 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));
|
||||
|
||||
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));
|
||||
});
|
||||
|
||||
await tester.drag(list, const Offset(0, -120));
|
||||
await tester.pump();
|
||||
expect(tester.getTopLeft(firstRow).dy, lessThan(strip.bottom));
|
||||
});
|
||||
testWidgets('a query that empties the list keeps the field', (tester) async {
|
||||
await pump(tester);
|
||||
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();
|
||||
|
||||
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);
|
||||
});
|
||||
}
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/schedules/ui/list/schedule_list_controller.dart';
|
||||
@@ -9,69 +8,55 @@ import 'schedule_list_test_support.dart';
|
||||
import 'schedule_screen_harness.dart';
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
for (final textScale in [1.0, 2.0]) {
|
||||
testWidgets('${cupertino ? 'Cupertino' : 'Material'} list at 390px and '
|
||||
'${textScale}x text shows server values with native controls', (
|
||||
for (final textScale in [1.0, 2.0]) {
|
||||
testWidgets('list at 390px and ${textScale}x text shows server values with '
|
||||
'standard controls', (tester) async {
|
||||
final gateway = FakeSchedulesGateway(
|
||||
(type, fields) async => schedulesReply([
|
||||
scheduleRecord(nextDue: '2026-10-22T09:00:00'),
|
||||
pausedRecord(),
|
||||
]),
|
||||
);
|
||||
await pumpSchedules(
|
||||
tester,
|
||||
) async {
|
||||
final gateway = FakeSchedulesGateway(
|
||||
(type, fields) async => schedulesReply([
|
||||
scheduleRecord(nextDue: '2026-10-22T09:00:00'),
|
||||
pausedRecord(),
|
||||
]),
|
||||
);
|
||||
await pumpSchedules(
|
||||
tester,
|
||||
cupertino: cupertino,
|
||||
gateway: gateway,
|
||||
textScale: textScale,
|
||||
);
|
||||
cupertino: false,
|
||||
gateway: gateway,
|
||||
textScale: textScale,
|
||||
);
|
||||
|
||||
expect(find.text('2 schedules'), findsOneWidget);
|
||||
// The strip carries the count only; the helper line lives in the
|
||||
// empty state.
|
||||
expect(find.textContaining('not pipeline definitions'), findsNothing);
|
||||
// Two lines per row: the name with its next run, then the timer
|
||||
// and pinned pipeline version. The editor holds the rest.
|
||||
expect(find.text('Research batteries'), findsOneWidget);
|
||||
expect(find.text('22 Oct'), findsOneWidget);
|
||||
expect(
|
||||
find.text('Every 24h · mon, wed · Pipeline 4 · v2'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Find battery chemistry sources'), findsNothing);
|
||||
expect(find.text('2 schedules'), findsOneWidget);
|
||||
// The strip carries the count only; the helper line lives in the
|
||||
// empty state.
|
||||
expect(find.textContaining('not pipeline definitions'), findsNothing);
|
||||
// Two lines per row: the name with its next run, then the timer
|
||||
// and pinned pipeline version. The editor holds the rest.
|
||||
expect(find.text('Research batteries'), findsOneWidget);
|
||||
expect(find.text('22 Oct'), findsOneWidget);
|
||||
expect(
|
||||
find.text('Every 24h · mon, wed · Pipeline 4 · v2'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Find battery chemistry sources'), findsNothing);
|
||||
|
||||
await tester.scrollUntilVisible(
|
||||
find.text('Nightly report'),
|
||||
300,
|
||||
scrollable: find.descendant(
|
||||
of: find.byKey(scheduleListKey),
|
||||
matching: find.byType(Scrollable),
|
||||
),
|
||||
);
|
||||
expect(find.text('Nightly report'), findsOneWidget);
|
||||
expect(find.text('10:00, 18:30 · Pipeline 7 · v5'), findsOneWidget);
|
||||
expect(find.text('Paused'), findsOneWidget);
|
||||
await tester.scrollUntilVisible(
|
||||
find.text('Nightly report'),
|
||||
300,
|
||||
scrollable: find.descendant(
|
||||
of: find.byKey(scheduleListKey),
|
||||
matching: find.byType(Scrollable),
|
||||
),
|
||||
);
|
||||
expect(find.text('Nightly report'), findsOneWidget);
|
||||
expect(find.text('10:00, 18:30 · Pipeline 7 · v5'), findsOneWidget);
|
||||
expect(find.text('Paused'), findsOneWidget);
|
||||
|
||||
if (cupertino) {
|
||||
expect(find.byType(CupertinoSearchTextField), findsOneWidget);
|
||||
expect(
|
||||
find.byType(CupertinoSlidingSegmentedControl<ScheduleListFilter>),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byType(CupertinoButton), findsWidgets);
|
||||
expect(find.byType(TextField), findsNothing);
|
||||
} else {
|
||||
expect(find.byKey(scheduleSearchFieldKey), findsOneWidget);
|
||||
expect(
|
||||
find.byType(SegmentedButton<ScheduleListFilter>),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byType(TextField), findsOneWidget);
|
||||
}
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
expect(find.byKey(scheduleSearchFieldKey), findsOneWidget);
|
||||
expect(
|
||||
find.byType(SegmentedButton<ScheduleListFilter>),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byType(TextField), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,60 +9,52 @@ import 'schedule_list_test_support.dart';
|
||||
import 'schedule_screen_harness.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('search covers name, prompt and pipeline in both themes', (
|
||||
tester,
|
||||
) async {
|
||||
for (final cupertino in [false, true]) {
|
||||
final gateway = FakeSchedulesGateway(
|
||||
(type, fields) async =>
|
||||
schedulesReply([scheduleRecord(), pausedRecord()]),
|
||||
);
|
||||
await pumpSchedules(tester, cupertino: cupertino, gateway: gateway);
|
||||
testWidgets('search covers name, prompt and pipeline', (tester) async {
|
||||
final gateway = FakeSchedulesGateway(
|
||||
(type, fields) async =>
|
||||
schedulesReply([scheduleRecord(), pausedRecord()]),
|
||||
);
|
||||
await pumpSchedules(tester, cupertino: false, gateway: gateway);
|
||||
|
||||
await tester.enterText(find.byKey(scheduleSearchFieldKey), 'pipeline 7');
|
||||
await tester.pump();
|
||||
expect(find.text('Nightly report'), findsOneWidget);
|
||||
expect(find.text('Research batteries'), findsNothing);
|
||||
expect(find.text('1 of 2 schedules'), findsOneWidget);
|
||||
await tester.enterText(find.byKey(scheduleSearchFieldKey), 'pipeline 7');
|
||||
await tester.pump();
|
||||
expect(find.text('Nightly report'), findsOneWidget);
|
||||
expect(find.text('Research batteries'), findsNothing);
|
||||
expect(find.text('1 of 2 schedules'), findsOneWidget);
|
||||
|
||||
await tester.enterText(
|
||||
find.byKey(scheduleSearchFieldKey),
|
||||
'battery chemistry',
|
||||
);
|
||||
await tester.pump();
|
||||
expect(find.text('Research batteries'), findsOneWidget);
|
||||
expect(find.text('Nightly report'), findsNothing);
|
||||
await tester.enterText(
|
||||
find.byKey(scheduleSearchFieldKey),
|
||||
'battery chemistry',
|
||||
);
|
||||
await tester.pump();
|
||||
expect(find.text('Research batteries'), findsOneWidget);
|
||||
expect(find.text('Nightly report'), findsNothing);
|
||||
|
||||
await tester.enterText(find.byKey(scheduleSearchFieldKey), 'no match');
|
||||
await tester.pump();
|
||||
expect(find.text('No schedules match this search.'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
}
|
||||
await tester.enterText(find.byKey(scheduleSearchFieldKey), 'no match');
|
||||
await tester.pump();
|
||||
expect(find.text('No schedules match this search.'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('enabled filter removes paused schedules in both themes', (
|
||||
tester,
|
||||
) async {
|
||||
for (final cupertino in [false, true]) {
|
||||
final gateway = FakeSchedulesGateway(
|
||||
(type, fields) async =>
|
||||
schedulesReply([scheduleRecord(), pausedRecord()]),
|
||||
);
|
||||
await pumpSchedules(tester, cupertino: cupertino, gateway: gateway);
|
||||
testWidgets('enabled filter removes paused schedules', (tester) async {
|
||||
final gateway = FakeSchedulesGateway(
|
||||
(type, fields) async =>
|
||||
schedulesReply([scheduleRecord(), pausedRecord()]),
|
||||
);
|
||||
await pumpSchedules(tester, cupertino: false, gateway: gateway);
|
||||
|
||||
await tester.tap(
|
||||
find.descendant(
|
||||
of: find.byKey(scheduleFilterKey),
|
||||
matching: find.text('Enabled'),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(
|
||||
find.descendant(
|
||||
of: find.byKey(scheduleFilterKey),
|
||||
matching: find.text('Enabled'),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Research batteries'), findsOneWidget);
|
||||
expect(find.text('Nightly report'), findsNothing);
|
||||
expect(find.text('1 of 2 schedules'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
}
|
||||
expect(find.text('Research batteries'), findsOneWidget);
|
||||
expect(find.text('Nightly report'), findsNothing);
|
||||
expect(find.text('1 of 2 schedules'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('row selection opens the exact record and never mutates', (
|
||||
|
||||
@@ -10,45 +10,41 @@ import 'schedule_screen_harness.dart';
|
||||
/// On a wide window the rows share the toolbar strip's width, and the strip
|
||||
/// is one row: the field, the filter and the count as a muted label.
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
testWidgets('Material 1200: rows end under the strip and the strip is one '
|
||||
'row', (tester) async {
|
||||
await pumpSchedules(
|
||||
tester,
|
||||
cupertino: false,
|
||||
size: const Size(1200, 800),
|
||||
gateway: FakeSchedulesGateway(
|
||||
(type, fields) async => schedulesReply([
|
||||
scheduleRecord(nextDue: '2026-10-22T09:00:00'),
|
||||
pausedRecord(),
|
||||
]),
|
||||
),
|
||||
);
|
||||
final strip = tester.getRect(find.byKey(scheduleToolbarKey));
|
||||
final row = tester.getRect(find.byKey(appListRowSurfaceKey).first);
|
||||
expect(row.left, 0);
|
||||
expect(row.width, kScheduleListMaxWidth);
|
||||
// The row's trailing time ends inside the strip's trailing edge.
|
||||
// The trailing time is the row's rightmost text, whatever its wording.
|
||||
final time = find
|
||||
.descendant(
|
||||
of: find.byKey(appListRowSurfaceKey).first,
|
||||
matching: find.byType(Text),
|
||||
)
|
||||
.evaluate()
|
||||
.map((element) => tester.getRect(find.byWidget(element.widget)))
|
||||
.reduce((a, b) => a.right >= b.right ? a : b);
|
||||
expect(time.right, lessThanOrEqualTo(strip.right - 12 + 0.5));
|
||||
|
||||
testWidgets('$host 1200: rows end under the strip and the strip is one '
|
||||
'row', (tester) async {
|
||||
await pumpSchedules(
|
||||
tester,
|
||||
cupertino: cupertino,
|
||||
size: const Size(1200, 800),
|
||||
gateway: FakeSchedulesGateway(
|
||||
(type, fields) async => schedulesReply([
|
||||
scheduleRecord(nextDue: '2026-10-22T09:00:00'),
|
||||
pausedRecord(),
|
||||
]),
|
||||
),
|
||||
);
|
||||
final strip = tester.getRect(find.byKey(scheduleToolbarKey));
|
||||
final row = tester.getRect(find.byKey(appListRowSurfaceKey).first);
|
||||
expect(row.left, 0);
|
||||
expect(row.width, kScheduleListMaxWidth);
|
||||
// The row's trailing time ends inside the strip's trailing edge.
|
||||
// The trailing time is the row's rightmost text, whatever its wording.
|
||||
final time = find
|
||||
.descendant(
|
||||
of: find.byKey(appListRowSurfaceKey).first,
|
||||
matching: find.byType(Text),
|
||||
)
|
||||
.evaluate()
|
||||
.map((element) => tester.getRect(find.byWidget(element.widget)))
|
||||
.reduce((a, b) => a.right >= b.right ? a : b);
|
||||
expect(time.right, lessThanOrEqualTo(strip.right - 12 + 0.5));
|
||||
|
||||
// Field, filter and count on one line.
|
||||
final field = tester.getRect(find.byKey(scheduleSearchFieldKey));
|
||||
final filter = tester.getRect(find.byKey(scheduleFilterKey));
|
||||
final count = tester.getRect(find.text('2 schedules'));
|
||||
expect((field.center.dy - filter.center.dy).abs(), lessThan(4));
|
||||
expect((count.center.dy - filter.center.dy).abs(), lessThan(4));
|
||||
expect(find.textContaining('not pipeline definitions'), findsNothing);
|
||||
});
|
||||
}
|
||||
// Field, filter and count on one line.
|
||||
final field = tester.getRect(find.byKey(scheduleSearchFieldKey));
|
||||
final filter = tester.getRect(find.byKey(scheduleFilterKey));
|
||||
final count = tester.getRect(find.text('2 schedules'));
|
||||
expect((field.center.dy - filter.center.dy).abs(), lessThan(4));
|
||||
expect((count.center.dy - filter.center.dy).abs(), lessThan(4));
|
||||
expect(find.textContaining('not pipeline definitions'), findsNothing);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
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';
|
||||
@@ -25,177 +24,141 @@ Future<void> _search(WidgetTester tester, String query) async {
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
Widget _app(bool cupertino, Widget child) =>
|
||||
cupertino ? CupertinoApp(home: child) : MaterialApp(home: child);
|
||||
Widget _app(Widget child) => MaterialApp(home: child);
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
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: (_) {}, cupertino: false)),
|
||||
);
|
||||
|
||||
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 are the shared row: title, kind-led 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(tester.widget<AppListRow>(row).cupertino, cupertino);
|
||||
// The kind leads the one muted line, before the snippet.
|
||||
expect(
|
||||
find.descendant(of: row, matching: find.textContaining('Field · ')),
|
||||
findsOneWidget,
|
||||
);
|
||||
for (final key in [searchFieldKey, searchKindKey, searchHelpKey]) {
|
||||
expect(
|
||||
find.descendant(
|
||||
of: row,
|
||||
matching: find.textContaining('the release is ready'),
|
||||
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('$host: results run behind the bar in a capped column', (
|
||||
tester,
|
||||
) async {
|
||||
_size(tester, 1200);
|
||||
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: (_) {}, cupertino: false)),
|
||||
);
|
||||
|
||||
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: (_) {}, cupertino: false)),
|
||||
);
|
||||
await _search(tester, 'release');
|
||||
|
||||
final row = find.byKey(const ValueKey('search.result.run:11:4:output'));
|
||||
expect(row, findsOneWidget);
|
||||
expect(tester.widget<AppListRow>(row).cupertino, isFalse);
|
||||
// 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: (_) {}, cupertino: false)),
|
||||
);
|
||||
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(
|
||||
cupertino,
|
||||
SearchScreen(gateway: gateway, onOpen: (_) {}, cupertino: cupertino),
|
||||
),
|
||||
_app(SearchScreen(gateway: gateway, onOpen: (_) {}, cupertino: false)),
|
||||
);
|
||||
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);
|
||||
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);
|
||||
});
|
||||
|
||||
for (final width in [390.0, 880.0, 1200.0, 1400.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);
|
||||
// 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);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
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';
|
||||
@@ -17,67 +16,59 @@ JsonMap replies(String query, String kind) => kind == 'chat'
|
||||
])
|
||||
: response([field]);
|
||||
|
||||
Widget host(Widget child, {required bool cupertino}) =>
|
||||
cupertino ? CupertinoApp(home: child) : MaterialApp(home: child);
|
||||
Widget host(Widget child) => MaterialApp(home: child);
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
final platform = cupertino ? 'Cupertino' : 'Material';
|
||||
|
||||
testWidgets('$platform: chat hits lead as a Chats group with title, '
|
||||
'harness, directory and snippet, and open their chat', (tester) async {
|
||||
useNarrowSurface(tester);
|
||||
final gateway = ImmediateGateway(replies);
|
||||
JsonMap? opened;
|
||||
await tester.pumpWidget(
|
||||
host(
|
||||
SearchScreen(
|
||||
gateway: gateway,
|
||||
onOpen: (value) => opened = value,
|
||||
cupertino: cupertino,
|
||||
),
|
||||
cupertino: cupertino,
|
||||
testWidgets('chat hits lead as a Chats group with title, '
|
||||
'harness, directory and snippet, and open their chat', (tester) async {
|
||||
useNarrowSurface(tester);
|
||||
final gateway = ImmediateGateway(replies);
|
||||
JsonMap? opened;
|
||||
await tester.pumpWidget(
|
||||
host(
|
||||
SearchScreen(
|
||||
gateway: gateway,
|
||||
onOpen: (value) => opened = value,
|
||||
cupertino: false,
|
||||
),
|
||||
);
|
||||
await search(tester, 'release');
|
||||
),
|
||||
);
|
||||
await search(tester, 'release');
|
||||
|
||||
expect(gateway.calls.single['search'], {
|
||||
'query': 'release',
|
||||
'kind': '',
|
||||
'limit': 0,
|
||||
});
|
||||
expect(gateway.chatCalls.single['search'], {
|
||||
'query': 'release',
|
||||
'kind': 'chat',
|
||||
'limit': 0,
|
||||
});
|
||||
expect(find.text('Chats (2)'), findsOneWidget);
|
||||
expect(find.text('Pipelines and runs'), findsOneWidget);
|
||||
final chats = tester.getTopLeft(find.byKey(searchChatsSectionKey));
|
||||
final others = tester.getTopLeft(find.byKey(searchOthersSectionKey));
|
||||
final chatRow = find.byKey(const ValueKey('search.result.chat:ses_a'));
|
||||
final runRow = find.byKey(
|
||||
const ValueKey('search.result.run:11:4:output'),
|
||||
);
|
||||
expect(chats.dy, lessThan(tester.getTopLeft(chatRow).dy));
|
||||
expect(tester.getTopLeft(chatRow).dy, lessThan(others.dy));
|
||||
expect(others.dy, lessThan(tester.getTopLeft(runRow).dy));
|
||||
|
||||
expect(find.text('API refactor'), findsOneWidget);
|
||||
expect(find.text('Release notes'), findsOneWidget);
|
||||
expect(
|
||||
find.textContaining('Chat · Claude Code · /work/api'),
|
||||
findsNWidgets(2),
|
||||
);
|
||||
expect(find.textContaining('the release retry'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
|
||||
await tester.tap(chatRow);
|
||||
await tester.pump();
|
||||
expect(opened?['target'], 'chat:ses_a');
|
||||
expect((opened?['chat'] as Map)['session_id'], 'ses_a');
|
||||
expect(gateway.calls.single['search'], {
|
||||
'query': 'release',
|
||||
'kind': '',
|
||||
'limit': 0,
|
||||
});
|
||||
}
|
||||
expect(gateway.chatCalls.single['search'], {
|
||||
'query': 'release',
|
||||
'kind': 'chat',
|
||||
'limit': 0,
|
||||
});
|
||||
expect(find.text('Chats (2)'), findsOneWidget);
|
||||
expect(find.text('Pipelines and runs'), findsOneWidget);
|
||||
final chats = tester.getTopLeft(find.byKey(searchChatsSectionKey));
|
||||
final others = tester.getTopLeft(find.byKey(searchOthersSectionKey));
|
||||
final chatRow = find.byKey(const ValueKey('search.result.chat:ses_a'));
|
||||
final runRow = find.byKey(const ValueKey('search.result.run:11:4:output'));
|
||||
expect(chats.dy, lessThan(tester.getTopLeft(chatRow).dy));
|
||||
expect(tester.getTopLeft(chatRow).dy, lessThan(others.dy));
|
||||
expect(others.dy, lessThan(tester.getTopLeft(runRow).dy));
|
||||
|
||||
expect(find.text('API refactor'), findsOneWidget);
|
||||
expect(find.text('Release notes'), findsOneWidget);
|
||||
expect(
|
||||
find.textContaining('Chat · Claude Code · /work/api'),
|
||||
findsNWidgets(2),
|
||||
);
|
||||
expect(find.textContaining('the release retry'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
|
||||
await tester.tap(chatRow);
|
||||
await tester.pump();
|
||||
expect(opened?['target'], 'chat:ses_a');
|
||||
expect((opened?['chat'] as Map)['session_id'], 'ses_a');
|
||||
});
|
||||
|
||||
testWidgets('Chats selected alone lists chats without group headings', (
|
||||
tester,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
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';
|
||||
@@ -145,34 +144,6 @@ void main() {
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets(
|
||||
'Cupertino search uses native controls and opens the real target',
|
||||
(tester) async {
|
||||
useNarrowSurface(tester);
|
||||
final gateway = ImmediateGateway((_, _) => response([pipeline]));
|
||||
JsonMap? opened;
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: largeText(
|
||||
SearchScreen(
|
||||
gateway: gateway,
|
||||
onOpen: (value) => opened = value,
|
||||
cupertino: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(CupertinoSearchTextField), findsOneWidget);
|
||||
await search(tester, 'release');
|
||||
|
||||
expect(find.text('Release planner'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.tap(find.byKey(const ValueKey('search.result.pipeline:7')));
|
||||
expect(opened?['target'], 'pipeline:7');
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('a read-only hit cannot be opened', (tester) async {
|
||||
useNarrowSurface(tester);
|
||||
final unknown = hit(
|
||||
|
||||
Reference in New Issue
Block a user