fix(app): an in-flight session export repair stays pending across remounts, as the web

This commit is contained in:
2026-10-23 14:32:04 +01:00
parent f9b796a1f9
commit 2eda713014
2 changed files with 87 additions and 8 deletions
@@ -0,0 +1,58 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/runs/actions/session_export_repair_action.dart';
class _HeldGateway implements ApiGateway {
final requests = <JsonMap>[];
final reply = Completer<JsonMap>();
@override
Stream<JsonMap> get frames => const Stream.empty();
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) {
requests.add({'type': type, ...fields});
return reply.future;
}
}
Widget _host(ApiGateway gateway) => MaterialApp(
home: Scaffold(
body: SessionExportRepairAction(
runId: 7,
sequence: 2,
gateway: gateway,
running: false,
onRepaired: (_) {},
),
),
);
void main() {
testWidgets('leaving and returning mid-repair cannot send it twice', (
tester,
) async {
final gateway = _HeldGateway();
await tester.pumpWidget(_host(gateway));
await tester.tap(find.text(sessionExportRepairLabel));
await tester.pump();
expect(gateway.requests, hasLength(1));
// The Session section unmounts and mounts again before the reply.
await tester.pumpWidget(const SizedBox());
await tester.pumpWidget(_host(gateway));
expect(find.text(sessionExportRepairBusyLabel), findsOneWidget);
await tester.tap(find.text(sessionExportRepairBusyLabel));
await tester.pump();
expect(gateway.requests, hasLength(1));
gateway.reply.complete({
'run_detail': {'id': 7},
});
await tester.pumpAndSettle();
expect(find.text(sessionExportRepairLabel), findsOneWidget);
});
}