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.
125 lines
4.0 KiB
Dart
125 lines
4.0 KiB
Dart
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/core/transport/connection_state.dart';
|
|
import 'package:pipelines_app/features/runs/actions/retry_wording.dart';
|
|
|
|
import 'retry_test_support.dart';
|
|
|
|
void main() {
|
|
testWidgets('confirm cannot submit twice while the retry is in flight', (
|
|
tester,
|
|
) async {
|
|
final reply = Completer<JsonMap>();
|
|
final gateway = FakeRetryGateway((type, fields) => reply.future);
|
|
final changed = <JsonMap>[];
|
|
await pumpRetry(tester, gateway: gateway, changed: changed);
|
|
|
|
await tester.tap(find.byKey(retryActionKey));
|
|
await tester.pumpAndSettle();
|
|
final confirm = find.byKey(retryConfirmKey);
|
|
await tester.tap(confirm);
|
|
await tester.tap(confirm);
|
|
await tester.pump();
|
|
|
|
expect(gateway.retries, hasLength(1));
|
|
expect(
|
|
tester.widget<FilledButton>(find.byKey(retryConfirmKey)).onPressed,
|
|
isNull,
|
|
);
|
|
expect(
|
|
tester.widget<TextButton>(find.byKey(retryKeepKey)).onPressed,
|
|
isNull,
|
|
);
|
|
expect(find.byType(AlertDialog), findsOneWidget);
|
|
|
|
reply.complete({'run_detail': retriedRun()});
|
|
await tester.pumpAndSettle();
|
|
expect(find.byType(AlertDialog), findsNothing);
|
|
expect(changed, hasLength(1));
|
|
});
|
|
|
|
testWidgets('a late retry reply after disposal is ignored safely', (
|
|
tester,
|
|
) async {
|
|
final reply = Completer<JsonMap>();
|
|
final gateway = FakeRetryGateway((type, fields) => reply.future);
|
|
final changed = <JsonMap>[];
|
|
await pumpRetry(tester, gateway: gateway, changed: changed);
|
|
|
|
await tester.tap(find.byKey(retryActionKey));
|
|
await tester.pumpAndSettle();
|
|
await tester.tap(find.byKey(retryConfirmKey));
|
|
await tester.pump();
|
|
expect(gateway.retries, hasLength(1));
|
|
|
|
await tester.pumpWidget(const SizedBox());
|
|
reply.complete({'run_detail': retriedRun()});
|
|
await tester.pump();
|
|
|
|
expect(tester.takeException(), isNull);
|
|
expect(changed, isEmpty);
|
|
});
|
|
|
|
testWidgets('a late resync after disposal is ignored safely', (tester) async {
|
|
final resync = Completer<JsonMap>();
|
|
final gateway = FakeRetryGateway((type, fields) {
|
|
if (type == 'retry_run') throw const ProtocolError('refused');
|
|
return resync.future;
|
|
});
|
|
final changed = <JsonMap>[];
|
|
await pumpRetry(tester, gateway: gateway, changed: changed);
|
|
|
|
await tester.tap(find.byKey(retryActionKey));
|
|
await tester.pumpAndSettle();
|
|
await tester.tap(find.byKey(retryConfirmKey));
|
|
await tester.pump();
|
|
expect(gateway.calls.map((call) => call.type), ['retry_run', 'get_run']);
|
|
|
|
await tester.pumpWidget(const SizedBox());
|
|
resync.complete({'run_detail': retriedRun()});
|
|
await tester.pump();
|
|
|
|
expect(tester.takeException(), isNull);
|
|
expect(changed, isEmpty);
|
|
});
|
|
|
|
testWidgets('both confirmations fit 2x text at a narrow width', (
|
|
tester,
|
|
) async {
|
|
tester.view.physicalSize = const Size(320, 480);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
|
|
final gateway = FakeRetryGateway(
|
|
(type, fields) async => {'run_detail': retriedRun()},
|
|
);
|
|
await pumpRetry(
|
|
tester,
|
|
gateway: gateway,
|
|
changed: <JsonMap>[],
|
|
textScale: 2,
|
|
);
|
|
|
|
await tester.tap(find.byKey(retryActionKey));
|
|
await tester.pumpAndSettle();
|
|
expect(tester.takeException(), isNull);
|
|
expect(find.text(retryDialogTitle(7)), findsOneWidget);
|
|
expect(find.text(retryDialogMessage), findsOneWidget);
|
|
expect(find.byType(AlertDialog), findsOneWidget);
|
|
|
|
await tester.tap(find.byKey(retryRestartKey));
|
|
await tester.pumpAndSettle();
|
|
expect(tester.takeException(), isNull);
|
|
expect(find.text(restartDialogTitle(7)), findsOneWidget);
|
|
expect(find.text(restartDialogMessage), findsOneWidget);
|
|
|
|
await tester.tap(find.byKey(retryKeepKey));
|
|
await tester.pumpAndSettle();
|
|
expect(gateway.calls, isEmpty);
|
|
});
|
|
}
|