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:
2026-11-11 03:54:36 +00:00
36 changed files with 1107 additions and 1789 deletions
@@ -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();
+31 -47
View File
@@ -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(
+112 -3
View File
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/windows/window_entry.dart';
import 'package:pipelines_app/shell/windows/window_frame.dart';
import 'package:pipelines_app/shell/windows/window_kind.dart';
import 'package:pipelines_app/shell/windows/window_layer.dart';
import 'package:pipelines_app/shell/windows/window_manager.dart';
@@ -36,6 +37,23 @@ void main() {
ProbeContentState content(WidgetTester tester, String id) =>
tester.state<ProbeContentState>(find.byKey(ValueKey('content-$id')));
Size windowSize(WidgetTester tester, String title) => tester.getSize(
find.ancestor(of: find.text(title), matching: find.byType(WindowFrame)),
);
/// The elements inside the probe windows that depend on the window's size:
/// its buttons and the scroll view around them.
Set<Element> contentElements() => {
for (final id in const ['a', 'b'])
for (final type in const [TextButton, ListView, Scrollable])
...find
.descendant(
of: find.byKey(ValueKey('content-$id')),
matching: find.byType(type),
)
.evaluate(),
};
Future<void> openTwo(WidgetTester tester) async {
manager.open('probe', 'a', frame: const Rect.fromLTWH(100, 80, 360, 420));
manager.open('probe', 'b', frame: const Rect.fromLTWH(600, 200, 360, 420));
@@ -77,6 +95,99 @@ void main() {
expect(content(tester, 'b').builds, beforeB);
});
testWidgets('a fractional title drag keeps the window size exactly and does '
'not rebuild content', (tester) async {
await openTwo(tester);
final start = windowRect(tester, 'Probe a').topLeft;
final startSize = windowSize(tester, 'Probe a');
final watched = contentElements();
expect(watched, isNotEmpty);
final rebuilt = <Element>{};
final gesture = await tester.startGesture(
tester.getCenter(
inWindow('Probe a', find.byKey(const ValueKey('window-title'))),
),
);
// The press raises and focuses the window before the drag starts; only
// the drag's own rebuilds are watched.
await tester.pump();
debugOnRebuildDirtyWidget = (element, builtOnce) {
if (watched.contains(element)) rebuilt.add(element);
};
try {
final a = content(tester, 'a');
final b = content(tester, 'b');
final beforeA = a.builds;
final beforeB = b.builds;
for (var i = 0; i < 8; i++) {
await gesture.moveBy(const Offset(10.3, 4.7));
await tester.pump();
expect(
rebuilt.map((e) => e.widget.runtimeType).toSet(),
isEmpty,
reason: 'window content rebuilt at move $i',
);
expect(
windowSize(tester, 'Probe a'),
startSize,
reason: 'window size changed at move $i',
);
}
await gesture.up();
await tester.pumpAndSettle();
expect(rebuilt, isEmpty);
expect(a.builds, beforeA);
expect(b.builds, beforeB);
// Eight fractional moves, rounded to whole pixels, without drift.
final moved = windowRect(tester, 'Probe a').topLeft - start;
expect(moved.dx, closeTo(8 * 10.3, 1));
expect(moved.dy, closeTo(8 * 4.7, 1));
} finally {
debugOnRebuildDirtyWidget = null;
}
});
testWidgets('resizing by fractional deltas gives whole-pixel sizes', (
tester,
) async {
await openTwo(tester);
final a = content(tester, 'a');
final b = content(tester, 'b');
final beforeA = a.builds;
final beforeB = b.builds;
final startSize = windowSize(tester, 'Probe b');
final startBody = b.lastSize!;
final titleHeight = startSize.height - startBody.height;
final gesture = await tester.startGesture(
tester.getCenter(
inWindow('Probe b', find.byKey(const ValueKey('window-resize'))),
),
);
for (var i = 0; i < 5; i++) {
await gesture.moveBy(const Offset(-10.3, -6.7));
await tester.pump();
final size = windowSize(tester, 'Probe b');
expect(size.width, size.width.roundToDouble(), reason: 'move $i width');
expect(
size.height,
size.height.roundToDouble(),
reason: 'move $i height',
);
expect(a.builds, beforeA, reason: 'other window rebuilt at move $i');
}
await gesture.up();
await tester.pumpAndSettle();
expect(content(tester, 'a').builds, beforeA);
final state = content(tester, 'b');
expect(state.builds, greaterThan(beforeB));
final size = windowSize(tester, 'Probe b');
expect(size.width, closeTo(startSize.width - 5 * 10.3, 1));
expect(size.height, closeTo(startSize.height - 5 * 6.7, 1));
// The content saw the new, whole-pixel size.
expect(state.lastSize!.width, size.width);
expect(state.lastSize!.height, size.height - titleHeight);
});
testWidgets('resizing a window keeps another window and sees the new size', (
tester,
) async {
@@ -108,9 +219,7 @@ void main() {
testWidgets('content still rebuilds when its window is retargeted', (
tester,
) async {
manager = WindowManager(
kinds: WindowKinds()..register(_StableProbeKind()),
);
manager = WindowManager(kinds: WindowKinds()..register(_StableProbeKind()));
final entry = manager.open('stable', 'a');
await pumpProbe(tester, manager);
final state = tester.state<ProbeContentState>(
@@ -162,6 +162,24 @@ void main() {
),
const Rect.fromLTWH(0, 0, 300, 200),
);
// A fractional minimum is never rounded below itself: the whole-pixel
// frame rounds up, and when the bounds cannot hold it the bounds win.
expect(
fitWindowFrame(
const Rect.fromLTWH(0, 0, 320.1, 240.4),
const Size(1000, 800),
const Size(320.1, 240.4),
),
const Rect.fromLTWH(0, 0, 321, 241),
);
expect(
fitWindowFrame(
const Rect.fromLTWH(0, 0, 320.1, 240.4),
const Size(319.6, 239.2),
const Size(320.1, 240.4),
),
const Rect.fromLTWH(0, 0, 319, 239),
);
const entry = WindowEntry(
id: 'w',
kind: 'chat',
+197 -241
View File
@@ -1,7 +1,6 @@
import 'dart:convert';
import 'dart:typed_data';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/artifacts/domain/artifact_groups.dart';
@@ -23,21 +22,18 @@ import '../../features/artifacts/ui/artifact_visit_list_fixture.dart';
import '../../features/chat/conversation/chat_composer_bar_fixtures.dart';
/// Every glass control bar keeps its first and last controls as far from the
/// pill's sides as from its top and bottom, and spaces neighbours evenly, on
/// both hosts, at phone width and at a larger text size.
/// pill's sides as from its top and bottom, and spaces neighbours evenly, at
/// phone width and at a larger text size.
const _phone = Size(390, 844);
const _scales = [1.0, 1.3];
const _hosts = [false, true];
final Uint8List _png = base64Decode(
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAE'
'hQGAhKmMIQAAAABJRU5ErkJggg==',
);
Widget _host(bool cupertino, Widget child) => cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: child))
: MaterialApp(home: Scaffold(body: child));
Widget _host(Widget child) => MaterialApp(home: Scaffold(body: child));
Future<void> _setUp(WidgetTester tester, double scale) async {
tester.view.physicalSize = _phone * tester.view.devicePixelRatio;
@@ -50,9 +46,7 @@ Future<void> _setUp(WidgetTester tester, double scale) async {
List<Rect> _controls(WidgetTester tester, Finder pill) {
final found = find.descendant(
of: pill,
matching: find.byWidgetPredicate(
(widget) => widget is IconButton || widget is CupertinoButton,
),
matching: find.byWidgetPredicate((widget) => widget is IconButton),
);
final rects = [
for (var i = 0; i < found.evaluate().length; i++)
@@ -101,248 +95,210 @@ Rect _pillOf(WidgetTester tester, Finder inside) => tester.getRect(
);
void main() {
for (final cupertino in _hosts) {
final host = cupertino ? 'Cupertino' : 'Material';
for (final scale in _scales) {
final when = '$host, text x$scale';
for (final scale in _scales) {
final when = 'text x$scale';
testWidgets('artifact viewer bar: equal end gaps ($when)', (
tester,
) async {
await _setUp(tester, scale);
for (final count in [1, 3]) {
final artifacts = [
for (var i = 0; i < count; i++)
recordedArtifact(
'shot-$i.png',
url: '/artifacts/1/1/shot-$i.png',
contentType: 'image/png',
),
];
final group = ArtifactGroup(
stageKey: 'review',
visit: 1,
artifacts: artifacts,
);
await tester.pumpWidget(
_host(
cupertino,
ArtifactViewerPage(
key: ValueKey(count),
groups: [group],
selectedIdentity: artifactVisitIdentity(group, artifacts.first),
configuredEndpoint: 'ws://127.0.0.1:8081/connect',
fetch: (_) async =>
ArtifactFetchResult(status: 200, bytes: _png),
markdownBuilder: (context, value) => Text(value),
openExternal: (_) async => true,
),
testWidgets('artifact viewer bar: equal end gaps ($when)', (tester) async {
await _setUp(tester, scale);
for (final count in [1, 3]) {
final artifacts = [
for (var i = 0; i < count; i++)
recordedArtifact(
'shot-$i.png',
url: '/artifacts/1/1/shot-$i.png',
contentType: 'image/png',
),
);
await tester.pumpAndSettle();
final row = find.byKey(const Key('artifact-viewer-actions'));
final pill = _pillOf(tester, row);
final controls = _controls(tester, row);
expect(controls.length, greaterThanOrEqualTo(2));
_expectEqualEnds(pill, controls.first, controls.last);
_expectEvenNeighbours(
count > 1 ? controls.sublist(0, controls.length - 2) : controls,
);
if (count > 1) {
_expectEvenNeighbours(controls.sublist(controls.length - 2));
}
expect(pill.height, closeTo(GlassBarMetrics.height(cupertino), 1));
expect(tester.takeException(), isNull);
}
});
testWidgets('diff page pager: position and chevrons inset ($when)', (
tester,
) async {
await _setUp(tester, scale);
await tester.pumpWidget(
_host(
cupertino,
FileDiffPage(
files: [
for (final name in ['a', 'b', 'c'])
FileChange(
path: 'lib/$name.dart',
kind: ChangeKind.modified,
patch:
'--- a/lib/$name.dart\n+++ b/lib/$name.dart\n'
'@@ -1 +1 @@\n-x\n+y\n',
),
],
),
),
);
await tester.pumpAndSettle();
final pager = find.byKey(const ValueKey('file-diff-pager'));
_expectPager(tester, pager, cupertino, find.text('1 of 3'));
});
testWidgets('changes visit pager: equal end gaps ($when)', (
tester,
) async {
await _setUp(tester, scale);
Map<String, dynamic> visit(String stage, int sequence) => {
'stage': stage,
'sequence': sequence,
'status': 'completed',
'file_changes': {
'status': 'complete',
'scope': 'Git tracked files',
'skipped': 0,
'omitted': 0,
'diagnostic': '',
'files': [
{'path': 'lib/$stage.dart', 'kind': 'added'},
],
},
};
await tester.pumpWidget(
_host(
cupertino,
ChangesViewer(
steps: [visit('build', 1), visit('review', 2)],
showSummary: false,
),
),
);
await tester.pumpAndSettle();
final position = find.byKey(
const ValueKey<String>('changes-visit-position'),
);
_expectPager(
tester,
find.ancestor(of: position, matching: find.byType(Row)).first,
cupertino,
position,
);
});
testWidgets('chat composer: + and Send keep the pill gap ($when)', (
tester,
) async {
await _setUp(tester, scale);
final gateway = ComposerBarGateway();
addTearDown(gateway.close);
final composer = ChatComposerController(
gateway,
's',
drafts: MemoryChatDraftStore(),
);
addTearDown(composer.dispose);
await tester.pumpWidget(
_host(
cupertino,
Align(
alignment: Alignment.bottomCenter,
child: ChatComposerBar(
composer: composer,
running: false,
placeholder: 'Message',
),
),
),
);
await tester.pumpAndSettle();
final pill = tester.getRect(
find.byKey(const Key('chat-composer-pill')),
);
final attach = tester.getRect(
find.byKey(const Key('chat-composer-attach')),
);
final send = tester.getRect(
find.byKey(const Key('chat-composer-primary')),
);
// The controls keep to the field's last line: each end control is as
// far from the pill's side as from its bottom, and while the field is
// one line (no taller than a control) as far from its top.
final row = GlassBarMetrics.controlExtent(cupertino);
final oneLine =
pill.height <= row + 2 * GlassBarMetrics.fieldEdgeGap + 0.5;
for (final (control, start) in [(attach, true), (send, false)]) {
final bottom = pill.bottom - control.bottom;
final side = start
? control.left - pill.left
: pill.right - control.right;
expect(side, closeTo(bottom, 1), reason: 'side vs bottom');
if (oneLine) {
expect(control.top - pill.top, closeTo(bottom, 1), reason: 'top');
expect(bottom, closeTo((pill.height - control.height) / 2, 1));
}
}
if (scale == 1.0) expect(oneLine, isTrue, reason: 'pill $pill');
expect(tester.takeException(), isNull);
});
testWidgets('top bar actions pill: controls fill it evenly ($when)', (
tester,
) async {
await _setUp(tester, scale);
final actions = [
for (final name in ['a', 'b', 'c'])
cupertino
? CupertinoButton(
key: Key('action-$name'),
padding: EdgeInsets.zero,
onPressed: () {},
child: const Icon(CupertinoIcons.info),
)
: IconButton(
key: Key('action-$name'),
onPressed: () {},
icon: const Icon(Icons.info_outline),
),
];
final group = ArtifactGroup(
stageKey: 'review',
visit: 1,
artifacts: artifacts,
);
await tester.pumpWidget(
cupertino
? CupertinoApp(
home: CupertinoPageScaffold(
navigationBar: SegmentedBar(
cupertino: true,
title: 'Title',
actions: actions,
),
child: const SizedBox.expand(),
),
)
: MaterialApp(
home: Scaffold(
appBar: SegmentedBar(
cupertino: false,
title: 'Title',
actions: actions,
),
),
),
_host(
ArtifactViewerPage(
key: ValueKey(count),
groups: [group],
selectedIdentity: artifactVisitIdentity(group, artifacts.first),
configuredEndpoint: 'ws://127.0.0.1:8081/connect',
fetch: (_) async => ArtifactFetchResult(status: 200, bytes: _png),
markdownBuilder: (context, value) => Text(value),
openExternal: (_) async => true,
),
),
);
await tester.pumpAndSettle();
final first = find.byKey(const Key('action-a'));
final pill = _pillOf(tester, first);
final controls = [
for (final name in ['a', 'b', 'c'])
tester.getRect(find.byKey(Key('action-$name'))),
];
final row = find.byKey(const Key('artifact-viewer-actions'));
final pill = _pillOf(tester, row);
final controls = _controls(tester, row);
expect(controls.length, greaterThanOrEqualTo(2));
_expectEqualEnds(pill, controls.first, controls.last);
_expectEvenNeighbours(controls);
_expectEvenNeighbours(
count > 1 ? controls.sublist(0, controls.length - 2) : controls,
);
if (count > 1) {
_expectEvenNeighbours(controls.sublist(controls.length - 2));
}
expect(pill.height, closeTo(GlassBarMetrics.height(false), 1));
expect(tester.takeException(), isNull);
});
}
}
});
testWidgets('diff page pager: position and chevrons inset ($when)', (
tester,
) async {
await _setUp(tester, scale);
await tester.pumpWidget(
_host(
FileDiffPage(
files: [
for (final name in ['a', 'b', 'c'])
FileChange(
path: 'lib/$name.dart',
kind: ChangeKind.modified,
patch:
'--- a/lib/$name.dart\n+++ b/lib/$name.dart\n'
'@@ -1 +1 @@\n-x\n+y\n',
),
],
),
),
);
await tester.pumpAndSettle();
final pager = find.byKey(const ValueKey('file-diff-pager'));
_expectPager(tester, pager, find.text('1 of 3'));
});
testWidgets('changes visit pager: equal end gaps ($when)', (tester) async {
await _setUp(tester, scale);
Map<String, dynamic> visit(String stage, int sequence) => {
'stage': stage,
'sequence': sequence,
'status': 'completed',
'file_changes': {
'status': 'complete',
'scope': 'Git tracked files',
'skipped': 0,
'omitted': 0,
'diagnostic': '',
'files': [
{'path': 'lib/$stage.dart', 'kind': 'added'},
],
},
};
await tester.pumpWidget(
_host(
ChangesViewer(
steps: [visit('build', 1), visit('review', 2)],
showSummary: false,
),
),
);
await tester.pumpAndSettle();
final position = find.byKey(
const ValueKey<String>('changes-visit-position'),
);
_expectPager(
tester,
find.ancestor(of: position, matching: find.byType(Row)).first,
position,
);
});
testWidgets('chat composer: + and Send keep the pill gap ($when)', (
tester,
) async {
await _setUp(tester, scale);
final gateway = ComposerBarGateway();
addTearDown(gateway.close);
final composer = ChatComposerController(
gateway,
's',
drafts: MemoryChatDraftStore(),
);
addTearDown(composer.dispose);
await tester.pumpWidget(
_host(
Align(
alignment: Alignment.bottomCenter,
child: ChatComposerBar(
composer: composer,
running: false,
placeholder: 'Message',
),
),
),
);
await tester.pumpAndSettle();
final pill = tester.getRect(find.byKey(const Key('chat-composer-pill')));
final attach = tester.getRect(
find.byKey(const Key('chat-composer-attach')),
);
final send = tester.getRect(
find.byKey(const Key('chat-composer-primary')),
);
// The controls keep to the field's last line: each end control is as
// far from the pill's side as from its bottom, and while the field is
// one line (no taller than a control) as far from its top.
final row = GlassBarMetrics.controlExtent(false);
final oneLine =
pill.height <= row + 2 * GlassBarMetrics.fieldEdgeGap + 0.5;
for (final (control, start) in [(attach, true), (send, false)]) {
final bottom = pill.bottom - control.bottom;
final side = start
? control.left - pill.left
: pill.right - control.right;
expect(side, closeTo(bottom, 1), reason: 'side vs bottom');
if (oneLine) {
expect(control.top - pill.top, closeTo(bottom, 1), reason: 'top');
expect(bottom, closeTo((pill.height - control.height) / 2, 1));
}
}
if (scale == 1.0) expect(oneLine, isTrue, reason: 'pill $pill');
expect(tester.takeException(), isNull);
});
testWidgets('top bar actions pill: controls fill it evenly ($when)', (
tester,
) async {
await _setUp(tester, scale);
final actions = [
for (final name in ['a', 'b', 'c'])
IconButton(
key: Key('action-$name'),
onPressed: () {},
icon: const Icon(Icons.info_outline),
),
];
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
appBar: SegmentedBar(
cupertino: false,
title: 'Title',
actions: actions,
),
),
),
);
await tester.pumpAndSettle();
final first = find.byKey(const Key('action-a'));
final pill = _pillOf(tester, first);
final controls = [
for (final name in ['a', 'b', 'c'])
tester.getRect(find.byKey(Key('action-$name'))),
];
_expectEqualEnds(pill, controls.first, controls.last);
_expectEvenNeighbours(controls);
expect(tester.takeException(), isNull);
});
}
}
/// A pager row: its position text starts an icon's inset in from the pill's
/// edge (where an icon at that end would be drawn), and its chevrons keep the
/// rule's equal gaps at the other end.
void _expectPager(
WidgetTester tester,
Finder inside,
bool cupertino,
Finder position,
) {
void _expectPager(WidgetTester tester, Finder inside, Finder position) {
final pill = _pillOf(tester, inside);
final controls = _controls(tester, inside);
expect(controls, hasLength(2));
@@ -353,14 +309,14 @@ void _expectPager(
final gap = (pill.height - last.height) / 2;
expect(
text.left - pill.left,
closeTo(gap + GlassBarMetrics.iconInset(cupertino), 1),
closeTo(gap + GlassBarMetrics.iconInset(false), 1),
);
// The chevrons keep the same gap from the position as from each other's
// icons: one icon inset on each side.
expect(
controls.first.left - text.right,
greaterThanOrEqualTo(GlassBarMetrics.iconInset(cupertino) - 1),
greaterThanOrEqualTo(GlassBarMetrics.iconInset(false) - 1),
);
expect(pill.height, closeTo(GlassBarMetrics.height(cupertino), 1));
expect(pill.height, closeTo(GlassBarMetrics.height(false), 1));
expect(tester.takeException(), isNull);
}
@@ -1,89 +0,0 @@
import 'dart:ui' show Tristate;
import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/input/cupertino_web_search_field.dart';
void main() {
for (final provided in [false, true]) {
testWidgets(
'native clear preserves semantics and focus (provided node: $provided)',
(tester) async {
final semantics = tester.ensureSemantics();
try {
final text = TextEditingController();
final focus = FocusNode();
addTearDown(text.dispose);
addTearDown(focus.dispose);
var clears = 0;
await tester.pumpWidget(
CupertinoApp(
home: CupertinoPageScaffold(
child: Center(
child: CupertinoWebSearchField(
controller: text,
placeholder: 'Search',
focusNode: provided ? focus : null,
onCleared: () {
clears++;
text.clear();
},
),
),
),
),
);
final field = find.byType(EditableText);
final effective = tester.widget<EditableText>(field).focusNode;
effective.requestFocus();
await tester.pumpAndSettle();
final height = tester
.getSize(find.byType(CupertinoWebSearchField))
.height;
final before = tester.getSemantics(field);
final identity = before.id;
expect(
before.getSemanticsData().flagsCollection.isEnabled,
Tristate.isTrue,
);
await tester.enterText(
find.byType(CupertinoSearchTextField),
'release',
);
await tester.pumpAndSettle();
final after = tester.getSemantics(field);
expect(after.id, identity);
expect(
tester.getSize(find.byType(CupertinoWebSearchField)).height,
height,
);
expect(
after.getSemanticsData().flagsCollection.isEnabled,
Tristate.isTrue,
);
expect(effective.hasPrimaryFocus, isTrue);
await tester.tap(find.byType(CupertinoButton));
await tester.pumpAndSettle();
expect(text.text, isEmpty);
expect(clears, 1);
expect(
tester.getSize(find.byType(CupertinoWebSearchField)).height,
height,
);
expect(effective.hasPrimaryFocus, isTrue);
expect(tester.getSemantics(field).id, identity);
await tester.enterText(
find.byType(CupertinoSearchTextField),
'again',
);
await tester.pumpAndSettle();
expect(text.text, 'again');
expect(effective.hasPrimaryFocus, isTrue);
} finally {
semantics.dispose();
}
},
);
}
}
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -11,10 +10,9 @@ const _rowColor = Color(0xFFE3F2FD);
/// A list of three rows; tapping one pushes its page, grown from that row.
class _List extends StatelessWidget {
const _List({required this.sources, required this.cupertino});
const _List({required this.sources});
final ContainerTransformSources sources;
final bool cupertino;
@override
Widget build(BuildContext context) => ContainerTransformScope(
@@ -33,8 +31,8 @@ class _List extends StatelessWidget {
onTap: () => Navigator.of(context).push(
ContainerTransformPageRoute<void>(
link: sources.link(() => id),
cupertino: cupertino,
builder: (_) => _Page(id: id, cupertino: cupertino),
cupertino: false,
builder: (_) => _Page(id: id),
),
),
child: SizedBox(height: 72, child: Text('row $id')),
@@ -46,42 +44,31 @@ class _List extends StatelessWidget {
}
class _Page extends StatelessWidget {
const _Page({required this.id, required this.cupertino});
const _Page({required this.id});
final String id;
final bool cupertino;
@override
Widget build(BuildContext context) => cupertino
? CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(),
child: Center(child: Text('page $id')),
)
: Scaffold(
appBar: AppBar(),
body: Center(child: Text('page $id')),
);
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(),
body: Center(child: Text('page $id')),
);
}
Future<ContainerTransformSources> _pump(
WidgetTester tester, {
bool cupertino = false,
bool reduced = false,
}) async {
tester.view.physicalSize = _screen;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final sources = ContainerTransformSources();
final home = _List(sources: sources, cupertino: cupertino);
final home = _List(sources: sources);
Widget media(BuildContext context, Widget? child) => MediaQuery(
data: MediaQuery.of(context).copyWith(disableAnimations: reduced),
child: child!,
);
await tester.pumpWidget(
cupertino
? CupertinoApp(builder: media, home: home)
: MaterialApp(builder: media, home: home),
);
await tester.pumpWidget(MaterialApp(builder: media, home: home));
return sources;
}
@@ -186,7 +173,7 @@ void main() {
ContainerTransformPageRoute<void>(
link: sources.link(() => 'missing'),
cupertino: false,
builder: (_) => const _Page(id: 'x', cupertino: false),
builder: (_) => const _Page(id: 'x'),
),
);
await tester.pump();
@@ -196,54 +183,6 @@ void main() {
expect(find.text('page x'), findsOneWidget);
});
testWidgets('a Cupertino swipe back shrinks the page with the finger', (
tester,
) async {
await _pump(tester, cupertino: true);
final row = tester.getRect(find.byKey(const Key('row-b')));
await tester.tap(find.byKey(const Key('row-b')));
await tester.pumpAndSettle();
expect(_surface(tester), Offset.zero & _screen);
final gesture = await tester.startGesture(const Offset(5, 400));
await gesture.moveBy(const Offset(20, 0));
await gesture.moveBy(const Offset(100, 0));
await tester.pump();
final early = _surface(tester);
_expectBetween(early, row);
await gesture.moveBy(const Offset(100, 0));
await tester.pump();
final later = _surface(tester);
expect(later.height, lessThan(early.height), reason: 'follows the finger');
// Back toward the start edge, the page grows again.
await gesture.moveBy(const Offset(-150, 0));
await tester.pump();
expect(_surface(tester).height, greaterThan(later.height));
await gesture.moveBy(const Offset(200, 0));
await gesture.up();
await tester.pumpAndSettle();
expect(find.text('page b'), findsNothing);
expect(find.byKey(const Key('row-b')), findsOneWidget);
});
testWidgets('a short Cupertino swipe released early stays on the page', (
tester,
) async {
await _pump(tester, cupertino: true);
await tester.tap(find.byKey(const Key('row-b')));
await tester.pumpAndSettle();
final gesture = await tester.startGesture(const Offset(5, 400));
await gesture.moveBy(const Offset(20, 0));
await gesture.moveBy(const Offset(40, 0));
await tester.pump();
await gesture.up();
await tester.pumpAndSettle();
expect(find.text('page b'), findsOneWidget);
expect(_surface(tester), Offset.zero & _screen);
});
testWidgets('Android predictive back drives the shrink, then commits', (
tester,
) async {
@@ -4,13 +4,11 @@ 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) {
Widget _row(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));
return MaterialApp(home: Scaffold(body: row));
}
BarIconButton _action(Key key, {bool busy = false}) => BarIconButton(
@@ -23,73 +21,58 @@ BarIconButton _action(Key key, {bool busy = false}) => BarIconButton(
);
void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
final side = cupertino
? kMinInteractiveDimensionCupertino
: kMinInteractiveDimension;
const side = 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('bar actions are whole, evenly sized touch targets', (
tester,
) async {
await tester.pumpWidget(
_row([
_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,
);
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,
),
testWidgets('search field is one stadium field with a clear', (tester) async {
final text = TextEditingController();
addTearDown(text.dispose);
var cleared = false;
await tester.pumpWidget(
_row([
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);
),
]),
);
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);
});
}
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);
});
}
+29 -61
View File
@@ -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/application/app.dart';
@@ -27,69 +26,38 @@ void main() {
expect(b?.fontSize, a?.fontSize);
expect(b?.fontWeight, a?.fontWeight);
}
expect(
build(
fontFamily: 'Inter',
).cupertinoOverrideTheme?.textTheme?.textStyle.fontFamily,
'Inter',
);
expect(build().cupertinoOverrideTheme, isNull);
}
});
test('the Cupertino theme takes the family in every text role', () {
expect(appCupertinoThemeWith(), same(appCupertinoTheme));
final text = appCupertinoThemeWith(fontFamily: 'Inter').textTheme;
const stock = CupertinoTextThemeData();
for (final (a, b) in <(TextStyle, TextStyle)>[
(stock.textStyle, text.textStyle),
(stock.navTitleTextStyle, text.navTitleTextStyle),
(stock.navLargeTitleTextStyle, text.navLargeTitleTextStyle),
(stock.tabLabelTextStyle, text.tabLabelTextStyle),
(stock.actionTextStyle, text.actionTextStyle),
(stock.pickerTextStyle, text.pickerTextStyle),
]) {
expect(b.fontFamily, 'Inter');
expect(b.fontSize, a.fontSize);
expect(b.fontWeight, a.fontWeight);
}
expect(
appCupertinoThemeWith(fontFamily: 'Inter').scaffoldBackgroundColor,
AppColors.background,
testWidgets('the Material host switches font live, without a restart', (
tester,
) async {
final fonts = AppFontController(
store: MemoryAppFontStore(),
loader: (family, assets) async {},
);
String? family;
await tester.pumpWidget(
MyApp(
fonts: fonts,
destination: AppDestination.settings,
destinationBodies: <AppDestination, WidgetBuilder>{
AppDestination.settings: (context) => Builder(
builder: (context) {
family = DefaultTextStyle.of(context).style.fontFamily;
return const Text('body');
},
),
},
),
);
final before = family;
expect(before, isNot('IBM Plex Sans'));
await fonts.select(AppFont.ibmPlexSans);
await tester.pumpAndSettle();
expect(family, 'IBM Plex Sans');
await fonts.select(AppFont.system);
await tester.pumpAndSettle();
expect(family, before);
});
for (final cupertino in <bool>[false, true]) {
testWidgets('the ${cupertino ? 'Cupertino' : 'Material'} host switches '
'font live, without a restart', (tester) async {
final fonts = AppFontController(
store: MemoryAppFontStore(),
loader: (family, assets) async {},
);
String? family;
await tester.pumpWidget(
MyApp(
cupertino: cupertino,
fonts: fonts,
destination: AppDestination.settings,
destinationBodies: <AppDestination, WidgetBuilder>{
AppDestination.settings: (context) => Builder(
builder: (context) {
family = DefaultTextStyle.of(context).style.fontFamily;
return const Text('body');
},
),
},
),
);
final before = family;
expect(before, isNot('IBM Plex Sans'));
await fonts.select(AppFont.ibmPlexSans);
await tester.pumpAndSettle();
expect(family, 'IBM Plex Sans');
await fonts.select(AppFont.system);
await tester.pumpAndSettle();
expect(family, before);
});
}
}
+5 -4
View File
@@ -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/ui/theme/app_theme.dart';
@@ -20,11 +19,13 @@ void main() {
}
});
test('the Cupertino page is gray in dark mode and unchanged in light', () {
test('page backgrounds are gray in dark mode and unchanged in light', () {
expect(AppColors.background.darkColor, const Color(0xFF141416));
expect(AppColors.background.color, const Color(0xFFFFFFFF));
expect(appCupertinoTheme.scaffoldBackgroundColor, AppColors.background);
expect(AppColors.groupedBackground.darkColor, isNot(CupertinoColors.black));
expect(
AppColors.groupedBackground.darkColor,
isNot(const Color(0xFF000000)),
);
});
test('Android pages retain native predictive Back in both themes', () {