364fd5b538
Keep the Material-only run action behavior while preserving public Cupertino parameters for callers that will be cleaned up separately. Narrow the related tests to the supported Material path.
112 lines
3.5 KiB
Dart
112 lines
3.5 KiB
Dart
import 'package:flutter/widgets.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/runs/ui/run_more_menu.dart';
|
|
import 'package:pipelines_app/core/transport/connection_state.dart';
|
|
import 'package:pipelines_app/features/runs/actions/retry_wording.dart';
|
|
|
|
import 'run_retry_wiring_support.dart';
|
|
import 'run_detail_finders.dart';
|
|
|
|
void main() {
|
|
testWidgets('a reply without an id never opens a guessed run', (
|
|
tester,
|
|
) async {
|
|
final gateway = RetryWiringGateway();
|
|
addTearDown(gateway.framesController.close);
|
|
final opened = <int>[];
|
|
await mountRetryScreen(
|
|
tester,
|
|
gateway,
|
|
onRunSelected: opened.add,
|
|
);
|
|
|
|
await confirmRetry(tester);
|
|
gateway.retries.last.complete({
|
|
'run_detail': {'title': 'Unknown run', 'status': 'running'},
|
|
});
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(opened, isEmpty);
|
|
expect(runDetailText(retryFailedTitle), findsOneWidget);
|
|
expect(find.text('Unknown run'), findsNothing);
|
|
expect(gateway.calls.where((call) => call.type == 'get_run'), hasLength(1));
|
|
});
|
|
|
|
testWidgets('a refused retry stays on the failed run', (tester) async {
|
|
final gateway = RetryWiringGateway();
|
|
addTearDown(gateway.framesController.close);
|
|
final opened = <int>[];
|
|
await mountRetryScreen(
|
|
tester,
|
|
gateway,
|
|
onRunSelected: opened.add,
|
|
);
|
|
|
|
await confirmRetry(tester);
|
|
gateway.refuseRetry(const ProtocolError('the run is still executing'));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('the run is still executing'), findsOneWidget);
|
|
expect(opened, isEmpty);
|
|
expect(runDetailText(retryFailedTitle), findsOneWidget);
|
|
await tester.tap(find.byKey(retryKeepKey));
|
|
await tester.pumpAndSettle();
|
|
expect(await retryOffered(tester), isTrue);
|
|
});
|
|
|
|
testWidgets('a retry reply that lands after leaving is ignored', (
|
|
tester,
|
|
) async {
|
|
final gateway = RetryWiringGateway();
|
|
addTearDown(gateway.framesController.close);
|
|
final opened = <int>[];
|
|
await mountRetryScreen(
|
|
tester,
|
|
gateway,
|
|
onRunSelected: opened.add,
|
|
);
|
|
|
|
await confirmRetry(tester);
|
|
expect(gateway.retryCalls, hasLength(1));
|
|
await tester.pumpWidget(const SizedBox.shrink());
|
|
gateway.acceptRetry(retryCreatedDetail());
|
|
await tester.pump();
|
|
|
|
expect(tester.takeException(), isNull);
|
|
expect(opened, isEmpty);
|
|
expect(gateway.calls.where((call) => call.type == 'get_run'), hasLength(1));
|
|
});
|
|
|
|
testWidgets('a reply naming the source run opens nothing', (tester) async {
|
|
final gateway = RetryWiringGateway();
|
|
addTearDown(gateway.framesController.close);
|
|
final opened = <int>[];
|
|
await mountRetryScreen(
|
|
tester,
|
|
gateway,
|
|
onRunSelected: opened.add,
|
|
);
|
|
|
|
await confirmRetry(tester);
|
|
gateway.acceptRetry(retryCreatedDetail(id: 7));
|
|
await tester.pumpAndSettle();
|
|
|
|
// The accepted detail still folds, but its id is the source run, so there
|
|
// is no new run to open and no second read.
|
|
expect(opened, isEmpty);
|
|
expect(runDetailText(retryCreatedTitle), findsOneWidget);
|
|
expect(gateway.calls.where((call) => call.type == 'get_run'), hasLength(1));
|
|
});
|
|
|
|
testWidgets('a failed run that is still executing exposes no retry', (
|
|
tester,
|
|
) async {
|
|
final gateway = RetryWiringGateway(executing: true);
|
|
addTearDown(gateway.framesController.close);
|
|
await mountRetryScreen(tester, gateway);
|
|
|
|
expect(find.byKey(runMoreMenuKey), findsOneWidget);
|
|
expect(await retryOffered(tester), isFalse);
|
|
});
|
|
}
|