Files
pipelines/app/test/features/pipelines/pipeline_summary_schedules_test.dart
T

85 lines
2.8 KiB
Dart

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);
});
}