feat(app): compact runs filter and sort toolbar

Replace the full-width runs dropdowns and status chips with web-shaped
controls: a Material filter popup with checked statuses and triggers, a
sort menu, and removable applied-filter chips; Cupertino gets a compact
Filter/Sort row plus one action sheet with live check marks. Add
RunsController.activeFilterCount and clearFilters(), and use the shared
seven-state run vocabulary. Clarify the singular active-filter tooltip.
This commit is contained in:
2026-10-22 14:20:05 +01:00
parent dc0a52380b
commit 535dee0805
6 changed files with 440 additions and 82 deletions
@@ -380,4 +380,23 @@ void main() {
expect(controller.runs.first['title'], 'Late rename');
},
);
test('active filter count treats each facet once and clears all', () {
expect(controller.activeFilterCount, 0);
controller.setStatus('failed');
controller.setStatus('running');
expect(controller.activeFilterCount, 1);
controller.setScheduled('scheduled');
controller.setPipeline(4);
expect(controller.activeFilterCount, 3);
controller.clearFilters();
expect(controller.activeFilterCount, 0);
expect(controller.statuses, isEmpty);
expect(controller.pipelineId, isNull);
expect(controller.scheduled, 'any');
expect(controller.timeRange, 'any_time');
});
}
@@ -87,12 +87,23 @@ void main() {
expect(find.text('No runs found.'), findsOneWidget);
await tester.enterText(find.byType(CupertinoSearchTextField), '');
await tester.pumpAndSettle();
await tester.tap(find.textContaining('Schedule:'));
await tester.tap(find.text('Filter'));
await tester.pumpAndSettle();
expect(find.text('Scheduled'), findsWidgets);
await tester.tap(find.text('Scheduled').last);
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),
);
@@ -0,0 +1,141 @@
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';
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';
class _Gateway implements ApiGateway {
final framesController = StreamController<JsonMap>.broadcast();
JsonMap? reply;
@override
Stream<JsonMap> get frames => framesController.stream;
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) async =>
reply ?? {'runs': []};
}
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
late _Gateway gateway;
late RunsController controller;
setUp(() {
gateway = _Gateway();
controller = RunsController(RunsRepository(gateway));
});
tearDown(() async {
controller.dispose();
await gateway.framesController.close();
});
Future<void> mount(WidgetTester tester, {required bool cupertino}) async {
gateway.reply = {
'runs': [
{'id': 1, 'name': 'Alpha', 'status': 'running', 'scheduled': true},
{'id': 2, 'name': 'Beta', 'status': 'failed', 'scheduled': false},
],
};
await controller.load();
final list = AnimatedBuilder(
animation: controller,
builder: (context, _) =>
RunsList(controller: controller, onSelected: (_) {}),
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: list))
: MaterialApp(home: Scaffold(body: list)),
);
await tester.pumpAndSettle();
}
testWidgets(
'material toolbar is a compact menu row with removable applied chips',
(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);
await tester.tap(find.text('Filter'));
await tester.pumpAndSettle();
expect(find.text('queued'), findsOneWidget);
expect(find.text('Any trigger'), findsOneWidget);
final failedItem = find.ancestor(
of: find.text('failed'),
matching: find.byWidgetPredicate((widget) => widget is PopupMenuItem),
);
await tester.tap(failedItem);
await tester.pumpAndSettle();
expect(controller.statuses, {'failed'});
expect(find.text('Filter (1)'), findsOneWidget);
expect(find.byType(InputChip), findsOneWidget);
expect(find.text('failed'), findsWidgets);
expect(find.text('Alpha'), findsNothing);
expect(find.text('Beta'), findsOneWidget);
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);
expect(find.byType(InputChip), findsNothing);
expect(find.text('Filter'), findsOneWidget);
expect(find.text('Alpha'), findsOneWidget);
},
variant: TargetPlatformVariant.only(TargetPlatform.android),
);
testWidgets(
'cupertino toolbar filters from one sheet 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.pumpAndSettle();
final failedAction = find.widgetWithText(
CupertinoActionSheetAction,
'failed',
);
await tester.ensureVisible(failedAction);
await tester.tap(failedAction);
await tester.pumpAndSettle();
expect(controller.statuses, {'failed'});
expect(find.text('✓ failed'), findsOneWidget);
expect(find.text('Filter (1)'), findsOneWidget);
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),
);
}