Files
pipelines/app/test/features/runs/ui/run_retry_guard_test.dart
T
alan c53dedc544 feat(app): wire retry and restart into the native run detail
Render Retry beside Rename on a stopped failed run under both native
hosts, send only {run_id, request_key} for resume and add
retry_mode=restart for a fresh start, and open the run the accepted
reply names. Keep hidden actions out of the Wrap so native 8/4 dp
spacing is not doubled, and use a literal 2^32 entropy bound because
dart2js evaluates 1 << 32 as 0.

Adds wiring, guard and layout tests, a browser-only key regression and
the retry probe; notes/R2c-wire.md records the checks and limits.
2026-10-21 22:49:26 +01:00

115 lines
3.6 KiB
Dart

import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/transport/connection_state.dart';
import 'package:pipelines_app/features/runs/actions/retry_wording.dart';
import 'package:pipelines_app/features/runs/actions/title_wording.dart';
import 'run_retry_wiring_support.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,
cupertino: false,
onRunSelected: opened.add,
);
await confirmRetry(tester);
gateway.retries.last.complete({
'run_detail': {'title': 'Unknown run', 'status': 'running'},
});
await tester.pumpAndSettle();
expect(opened, isEmpty);
expect(find.text(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,
cupertino: false,
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(find.text(retryFailedTitle), findsOneWidget);
await tester.tap(find.byKey(retryKeepKey));
await tester.pumpAndSettle();
expect(find.byKey(retryActionKey), findsOneWidget);
});
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,
cupertino: false,
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,
cupertino: false,
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(find.text(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, cupertino: false);
expect(find.byKey(runTitleActionKey), findsOneWidget);
expect(find.byKey(retryActionKey), findsNothing);
});
}