feat(app): wire saved schedules into the pipeline summary

This commit is contained in:
2026-10-22 00:41:55 +01:00
parent 2adecfff5e
commit ea2179cd66
22 changed files with 2381 additions and 11 deletions
@@ -0,0 +1,84 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/pipelines/screen.dart';
import 'package:pipelines_app/features/schedules/ui/pipeline/schedule_pipeline_wording.dart';
import 'fixtures.dart';
void main() {
testWidgets('pipeline Summary lists its schedules without changing tabs', (
tester,
) async {
final record = {
'id': 8,
'revision': 3,
'name': 'Research batteries',
'pipeline_id': 1,
'version': 3,
'enabled': true,
'input': {'prompt': 'Find battery chemistry sources'},
'workspace': '/srv/research',
'rule': {
'every': '24h',
'days': ['mon', 'wed'],
'timezone': 'Europe/London',
},
'next_due': '2026-10-22T09:00:00Z',
};
final gateway = FakeGateway((type, fields) {
return switch (type) {
'list_pipelines' => pipelineListReply([
pipelineSummary(id: 1, name: 'Alpha review', version: 3),
]),
'list_runs' => runListReply([]),
'get_pipeline' => pipelineDetailReply(
pipelineDetail(
id: 1,
name: 'Alpha review',
version: 3,
latestVersion: 5,
versions: [versionSummary(3), versionSummary(5)],
),
),
'list_schedules' => {
'type': 'schedules',
'schedules': [record],
},
_ => errorReply('unexpected $type'),
};
});
tester.view.physicalSize = const Size(1100, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(
MaterialApp(home: PipelinesScreen(gateway: gateway)),
);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('pipeline-row-1')));
await tester.pumpAndSettle();
expect(find.text('Schedules (1)'), findsOneWidget);
expect(find.text('Research batteries'), findsOneWidget);
expect(
find.text('Pinned v3 · Every 24h · mon, wed · Europe/London'),
findsOneWidget,
);
expect(find.byKey(scheduleAddKey), findsOneWidget);
expect(find.byKey(scheduleRowEditKey(8)), findsOneWidget);
expect(find.byKey(scheduleRowToggleKey(8)), findsOneWidget);
expect(find.byKey(scheduleRowDeleteKey(8)), findsOneWidget);
expect(gateway.callsOf('list_schedules').single.fields, {'pipeline_id': 1});
await tester.tap(find.text('Source'));
await tester.pump();
expect(find.text('name: alpha'), findsOneWidget);
await tester.tap(find.text('Graph'));
await tester.pump();
await tester.pump();
expect(find.byKey(scheduleAddKey), findsNothing);
await tester.tap(find.text('Summary'));
await tester.pumpAndSettle();
expect(find.text('Research batteries'), findsOneWidget);
});
}
@@ -153,9 +153,8 @@ void main() {
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final controller = PipelinesController(
PipelinesRepository(gatewayFor(PipelineFixture())),
);
final gateway = gatewayFor(PipelineFixture());
final controller = PipelinesController(PipelinesRepository(gateway));
addTearDown(controller.dispose);
await controller.openPipeline(1);
await tester.pumpWidget(
@@ -167,7 +166,11 @@ void main() {
child: child!,
),
home: Scaffold(
body: PipelineDetailPanel(controller: controller, showBack: true),
body: PipelineDetailPanel(
controller: controller,
gateway: gateway,
showBack: true,
),
),
),
);
@@ -27,6 +27,7 @@ FakeGateway gatewayFor(
fields['version'] as int,
)!,
),
'list_schedules' => {'type': 'schedules', 'schedules': <dynamic>[]},
_ => errorReply('unexpected $type'),
},
);