feat(app): Runs list filter, sort and usage charts are app-bar icons; the text filter is inside the filter sheet
This commit is contained in:
@@ -77,36 +77,18 @@ void main() {
|
||||
onSelected: (id) => selectedRun = id,
|
||||
);
|
||||
|
||||
expect(find.byType(CupertinoSearchTextField), findsOneWidget);
|
||||
// The text filter lives in the filter sheet.
|
||||
expect(find.byType(CupertinoSearchTextField), findsNothing);
|
||||
expect(find.text('Alpha'), findsOneWidget);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.filter')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.enterText(find.byType(CupertinoSearchTextField), 'Beta');
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Beta'), findsNWidgets(2));
|
||||
await tester.tapAt(const Offset(4, 4));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Alpha'), findsNothing);
|
||||
await tester.tap(find.byKey(const ValueKey('run-row-2')));
|
||||
expect(selectedRun, 2);
|
||||
await tester.enterText(find.byType(CupertinoSearchTextField), 'missing');
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('No runs found.'), findsOneWidget);
|
||||
await tester.enterText(find.byType(CupertinoSearchTextField), '');
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Filter'));
|
||||
await tester.pumpAndSettle();
|
||||
final scheduled = find.widgetWithText(
|
||||
CupertinoActionSheetAction,
|
||||
'Scheduled runs',
|
||||
);
|
||||
await tester.ensureVisible(scheduled);
|
||||
await tester.tap(scheduled);
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.scheduled, 'scheduled');
|
||||
await tester.tap(find.text('Done'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Scheduled runs'), findsOneWidget);
|
||||
await tester.tap(find.text('Scheduled runs'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.scheduled, 'any');
|
||||
expect(find.text('Scheduled runs'), findsNothing);
|
||||
},
|
||||
variant: TargetPlatformVariant.only(TargetPlatform.iOS),
|
||||
);
|
||||
@@ -143,6 +125,8 @@ void main() {
|
||||
};
|
||||
await controller.load();
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const ValueKey('runs.filter')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(TextField), findsOneWidget);
|
||||
final layoutError = tester.takeException();
|
||||
expect(
|
||||
@@ -193,7 +177,7 @@ void main() {
|
||||
);
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('the attention action shares the Filter toolbar row '
|
||||
testWidgets('the attention action heads the list under the actions '
|
||||
'(${cupertino ? 'Cupertino' : 'Material'})', (tester) async {
|
||||
await mount(tester, cupertino: cupertino);
|
||||
await tester.pumpAndSettle();
|
||||
@@ -202,13 +186,11 @@ void main() {
|
||||
matching: find.byType(NeedsYouRunsHeading),
|
||||
);
|
||||
expect(bell, findsOneWidget);
|
||||
final filter = find.descendant(
|
||||
of: find.byType(RunsFilters),
|
||||
matching: find.text('Filter'),
|
||||
);
|
||||
expect(
|
||||
(tester.getCenter(bell).dy - tester.getCenter(filter).dy).abs(),
|
||||
lessThan(1),
|
||||
tester.getTopLeft(bell).dy,
|
||||
greaterThanOrEqualTo(
|
||||
tester.getBottomLeft(find.byKey(const ValueKey('runs.filter'))).dy,
|
||||
),
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/runs/data/runs_repository.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/runs_controller.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/runs_list.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/runs_stats_page.dart';
|
||||
|
||||
class _Gateway implements ApiGateway {
|
||||
final framesController = StreamController<JsonMap>.broadcast();
|
||||
@@ -69,123 +70,126 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
Future<void> reveal(WidgetTester tester, Finder target) =>
|
||||
tester.scrollUntilVisible(
|
||||
target,
|
||||
80,
|
||||
// The sheet's own list, not the search field's inner scrollable.
|
||||
scrollable: find
|
||||
.descendant(
|
||||
of: find.byKey(const ValueKey('runs.filter.sheet')),
|
||||
matching: find.byType(Scrollable),
|
||||
)
|
||||
.first,
|
||||
);
|
||||
|
||||
Future<void> closeSheet(WidgetTester tester) async {
|
||||
await tester.tapAt(const Offset(4, 4));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
testWidgets(
|
||||
'material toolbar is a compact menu row with removable applied chips',
|
||||
'material: filter and sort are icons; the filter sheet holds the search',
|
||||
(tester) async {
|
||||
await mount(tester, cupertino: false);
|
||||
expect(find.byType(DropdownButton<String>), findsNothing);
|
||||
expect(find.byType(FilterChip), findsNothing);
|
||||
expect(find.text('Filter'), findsOneWidget);
|
||||
expect(find.text('Sort: Newest first'), findsOneWidget);
|
||||
expect(find.byType(TextField), findsNothing);
|
||||
expect(find.byKey(const ValueKey('runs.filter')), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('runs.sort')), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('runs.stats')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text('Filter'));
|
||||
await tester.tap(find.byKey(const ValueKey('runs.filter')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('queued'), findsOneWidget);
|
||||
expect(find.text('Pipeline'), findsOneWidget);
|
||||
expect(find.text('Any pipeline'), findsOneWidget);
|
||||
expect(find.text('Time range'), findsOneWidget);
|
||||
expect(find.text('Last 7 days'), findsOneWidget);
|
||||
expect(find.text('Any trigger'), findsOneWidget);
|
||||
final sheet = find.byKey(const ValueKey('runs.filter.sheet'));
|
||||
expect(
|
||||
find.text(
|
||||
'Some records have no scheduling provenance; they stay unclassified.',
|
||||
),
|
||||
find.descendant(of: sheet, matching: find.byType(TextField)),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
final pipelineItem = find.ancestor(
|
||||
of: find.text('Alpha'),
|
||||
matching: find.byWidgetPredicate((widget) => widget is PopupMenuItem),
|
||||
await tester.enterText(
|
||||
find.byKey(const ValueKey('runs.filter.query')),
|
||||
'Beta',
|
||||
);
|
||||
await tester.ensureVisible(pipelineItem);
|
||||
await tester.tap(pipelineItem);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pump();
|
||||
expect(controller.query, 'Beta');
|
||||
|
||||
final alpha = find.descendant(of: sheet, matching: find.text('Alpha'));
|
||||
await reveal(tester, alpha);
|
||||
await tester.tap(alpha);
|
||||
await tester.pump();
|
||||
expect(controller.pipelineId, 9);
|
||||
|
||||
await tester.tap(find.text('Filter (1)'));
|
||||
await tester.pumpAndSettle();
|
||||
final timeItem = find.ancestor(
|
||||
of: find.text('Last 7 days'),
|
||||
matching: find.byWidgetPredicate((widget) => widget is PopupMenuItem),
|
||||
final week = find.descendant(
|
||||
of: sheet,
|
||||
matching: find.text('Last 7 days'),
|
||||
);
|
||||
await tester.ensureVisible(timeItem);
|
||||
await tester.tap(timeItem);
|
||||
await tester.pumpAndSettle();
|
||||
await reveal(tester, week);
|
||||
await tester.tap(week);
|
||||
await tester.pump();
|
||||
expect(controller.timeRange, 'last_7_days');
|
||||
expect(find.text('Filter (2)'), findsOneWidget);
|
||||
await closeSheet(tester);
|
||||
|
||||
// Applied filters stay visible and clearable under the bar.
|
||||
expect(find.byTooltip('Clear filter: Last 7 days'), findsOneWidget);
|
||||
await tester.tap(find.byTooltip('Clear filter: Last 7 days'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.timeRange, 'any_time');
|
||||
|
||||
await tester.tap(find.text('Filter (2)'));
|
||||
await tester.tap(find.byKey(const ValueKey('runs.sort')));
|
||||
await tester.pumpAndSettle();
|
||||
final failedItem = find.ancestor(
|
||||
of: find.text('failed'),
|
||||
matching: find.byWidgetPredicate((widget) => widget is PopupMenuItem),
|
||||
);
|
||||
await tester.tap(failedItem);
|
||||
await tester.tap(find.text('Oldest first'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.statuses, {'failed'});
|
||||
expect(find.text('Filter (3)'), findsOneWidget);
|
||||
expect(find.byType(InputChip), findsNWidgets(3));
|
||||
expect(find.text('failed'), findsWidgets);
|
||||
expect(controller.visibleRuns, isEmpty);
|
||||
|
||||
await tester.tap(find.textContaining('Sort:'));
|
||||
await tester.pumpAndSettle();
|
||||
final statusItem = find.ancestor(
|
||||
of: find.text('Status'),
|
||||
matching: find.byWidgetPredicate((widget) => widget is PopupMenuItem),
|
||||
);
|
||||
await tester.tap(statusItem);
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.sort, 'status');
|
||||
expect(find.text('Sort: Status'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byTooltip('Clear filter: failed'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.statuses, isEmpty);
|
||||
controller.clearFilters();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(InputChip), findsNothing);
|
||||
expect(find.text('Filter'), findsOneWidget);
|
||||
expect(find.text('Alpha'), findsOneWidget);
|
||||
expect(controller.sort, 'oldest_first');
|
||||
},
|
||||
variant: TargetPlatformVariant.only(TargetPlatform.android),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'cupertino toolbar filters from one sheet and its chip clears the facet',
|
||||
'cupertino: the filter sheet filters and its chip clears the facet',
|
||||
(tester) async {
|
||||
await mount(tester, cupertino: true);
|
||||
expect(find.text('Filter'), findsOneWidget);
|
||||
expect(find.text('Sort: Newest first'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text('Filter'));
|
||||
await tester.tap(find.byKey(const ValueKey('runs.filter')));
|
||||
await tester.pumpAndSettle();
|
||||
final failedAction = find.widgetWithText(
|
||||
CupertinoActionSheetAction,
|
||||
'failed',
|
||||
);
|
||||
await tester.ensureVisible(failedAction);
|
||||
await tester.tap(failedAction);
|
||||
expect(find.byType(CupertinoSearchTextField), findsOneWidget);
|
||||
final failed = find.widgetWithText(CupertinoListTile, 'failed');
|
||||
await reveal(tester, failed);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(failed);
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.statuses, {'failed'});
|
||||
expect(find.text('✓ failed'), findsOneWidget);
|
||||
expect(find.text('Pipeline'), findsOneWidget);
|
||||
expect(find.text('Last 7 days'), findsOneWidget);
|
||||
expect(find.text('Filter (1)'), findsOneWidget);
|
||||
await closeSheet(tester);
|
||||
|
||||
await tester.tap(find.text('Done'));
|
||||
await tester.pumpAndSettle();
|
||||
final failedChip = find.widgetWithText(CupertinoButton, 'failed');
|
||||
expect(failedChip, findsOneWidget);
|
||||
expect(find.text('Alpha'), findsNothing);
|
||||
|
||||
await tester.tap(failedChip);
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.statuses, isEmpty);
|
||||
expect(find.text('Filter'), findsOneWidget);
|
||||
expect(find.text('Alpha'), findsOneWidget);
|
||||
},
|
||||
variant: TargetPlatformVariant.only(TargetPlatform.iOS),
|
||||
);
|
||||
|
||||
testWidgets('the stats page shows usage, status pie and runs per day', (
|
||||
tester,
|
||||
) async {
|
||||
await mount(tester, cupertino: false);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.stats')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const ValueKey('runs.stats.page')), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('runs.stats.pie')), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('runs.stats.days')), findsOneWidget);
|
||||
expect(find.text('Runs by status'), findsOneWidget);
|
||||
});
|
||||
|
||||
test('runs per day counts the last seven local days', () {
|
||||
final now = DateTime(2026, 10, 23, 12);
|
||||
final days = runsPerDay([
|
||||
{'created_at': DateTime(2026, 10, 23, 9).toUtc().toIso8601String()},
|
||||
{'created_at': DateTime(2026, 10, 23, 10).toUtc().toIso8601String()},
|
||||
{'created_at': DateTime(2026, 10, 20, 9).toUtc().toIso8601String()},
|
||||
{'created_at': DateTime(2026, 10, 1, 9).toUtc().toIso8601String()},
|
||||
], now);
|
||||
expect(days, hasLength(7));
|
||||
expect(days.last.count, 2);
|
||||
expect(days[3].count, 1);
|
||||
expect(days.fold<int>(0, (sum, day) => sum + day.count), 3);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user