Files
pipelines/app/test/features/pipelines/test_helpers.dart
T
alan 5a9284ccf7 App: archive and unarchive pipelines
The pipeline's bar gets a Pipeline actions menu with Archive (confirm
dialog: history is kept) or Unarchive; an archived detail says so and
offers no Run. The list hides archived pipelines and the scope control
gains an Archived view. Server refusals (enabled schedule, newer
version) are shown verbatim. The capture fixture answers archive
requests.
2026-11-04 23:37:25 +00:00

64 lines
2.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/pipelines/screen.dart';
import 'fixtures.dart';
FakeGateway gatewayFor(
PipelineFixture fixture, {
bool listFails = false,
bool runsFail = false,
bool detailFails = false,
List<Map<String, dynamic>>? summaries,
}) => FakeGateway(
(type, fields) => switch (type) {
'list_pipelines' =>
listFails
? errorReply('server offline')
: pipelineListReply(summaries ?? fixture.summaries),
'list_runs' =>
runsFail ? errorReply('runs down') : runListReply(fixture.runs),
'get_pipeline' =>
detailFails
? errorReply('pipeline ${fields['pipeline_id']} was not found')
: pipelineDetailReply(
fixture.detailFor(
fields['pipeline_id'] as int,
fields['version'] as int,
)!,
),
'list_schedules' => {'type': 'schedules', 'schedules': <dynamic>[]},
_ => errorReply('unexpected $type'),
},
);
Future<void> pumpWide(WidgetTester tester, FakeGateway gateway) async {
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();
}
Finder selectableText(String text) => find.byWidgetPredicate(
(widget) => widget is SelectableText && widget.data == text,
);
/// Picks a scope from the segments, or from the menu a pane too narrow for
/// the segments shows instead.
Future<void> pickScope(WidgetTester tester, String label) async {
final segment = find.descendant(
of: find.byKey(const Key('pipeline-scope')),
matching: find.text(label),
);
if (segment.evaluate().isEmpty) {
await tester.tap(find.byKey(const Key('pipeline-scope')));
await tester.pumpAndSettle();
await tester.tap(find.text(label).last);
} else {
await tester.tap(segment);
}
await tester.pumpAndSettle();
}