feat(app): run detail's pipeline name opens that pipeline; Retry moves into the more menu

This commit is contained in:
2026-10-23 16:27:20 +01:00
parent 27203fb715
commit 9d61ce1406
13 changed files with 286 additions and 105 deletions
@@ -5,7 +5,8 @@ import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/runs/data/runs_repository.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
import 'package:pipelines_app/features/runs/ui/runs_controller.dart';
import 'package:pipelines_app/ui/status/run_status_icon.dart';
import 'package:pipelines_app/features/runs/ui/run_more_menu.dart';
import 'package:pipelines_app/features/runs/ui/run_pipeline_link.dart';
class _FakeGateway implements ApiGateway {
_FakeGateway(this.detail);
@@ -21,7 +22,12 @@ class _FakeGateway implements ApiGateway {
}
}
Future<void> _pump(WidgetTester tester, String status, bool cupertino) async {
Future<void> _pump(
WidgetTester tester,
String status,
bool cupertino, {
OpenPipeline? onOpenPipeline,
}) async {
tester.view.physicalSize = const Size(390, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
@@ -33,6 +39,8 @@ Future<void> _pump(WidgetTester tester, String status, bool cupertino) async {
'name': 'nightly',
'status': status,
'executing': false,
'pipeline_id': 10,
'version': 3,
}),
),
);
@@ -41,6 +49,7 @@ Future<void> _pump(WidgetTester tester, String status, bool cupertino) async {
controller: controller,
gateway: _FakeGateway(const {}),
onBack: () {},
onOpenPipeline: onOpenPipeline,
);
await tester.pumpWidget(
cupertino
@@ -50,23 +59,42 @@ Future<void> _pump(WidgetTester tester, String status, bool cupertino) async {
await tester.pumpAndSettle();
}
Future<bool> _menuOffersRetry(WidgetTester tester) async {
await tester.tap(find.byKey(runMoreMenuKey));
await tester.pumpAndSettle();
return find.text('Retry').evaluate().isNotEmpty;
}
void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'cupertino' : 'material';
testWidgets('$host: Retry sits beside the failed status', (tester) async {
testWidgets('$host: Retry is a more-menu option for a failed run', (
tester,
) async {
await _pump(tester, 'failed', cupertino);
// Not in the header itself.
expect(find.text('Retry'), findsNothing);
expect(await _menuOffersRetry(tester), isTrue);
});
final retry = find.text('Retry');
expect(retry, findsOneWidget);
final kicker = tester.getRect(find.byType(RunStatusKicker));
final button = tester.getRect(retry);
expect(button.center.dy, moreOrLessEquals(kicker.center.dy, epsilon: 8));
expect(button.left, greaterThan(kicker.right));
testWidgets('$host: the pipeline name opens that pipeline at the run\'s '
'version', (tester) async {
final opened = <(int, int)>[];
await _pump(
tester,
'succeeded',
cupertino,
onOpenPipeline: (id, version) => opened.add((id, version)),
);
await tester.tap(find.byKey(runPipelineLinkKey));
await tester.pump();
expect(opened, [(10, 3)]);
expect(find.bySemanticsLabel('Open pipeline nightly'), findsOneWidget);
});
testWidgets('$host: a succeeded run offers no Retry', (tester) async {
await _pump(tester, 'succeeded', cupertino);
expect(find.text('Retry'), findsNothing);
expect(await _menuOffersRetry(tester), isFalse);
});
}
}
@@ -52,7 +52,7 @@ void main() {
expect(find.text(retryFailedTitle), findsOneWidget);
await tester.tap(find.byKey(retryKeepKey));
await tester.pumpAndSettle();
expect(find.byKey(retryActionKey), findsOneWidget);
expect(await retryOffered(tester), isTrue);
});
testWidgets('a retry reply that lands after leaving is ignored', (
@@ -109,6 +109,6 @@ void main() {
await mountRetryScreen(tester, gateway, cupertino: false);
expect(find.byKey(runMoreMenuKey), findsOneWidget);
expect(find.byKey(retryActionKey), findsNothing);
expect(await retryOffered(tester), isFalse);
});
}
@@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/runs/ui/run_more_menu.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/runs/actions/retry_wording.dart';
import 'package:pipelines_app/features/runs/screen.dart';
@@ -105,9 +106,27 @@ Future<void> mountRetryScreen(
await tester.pumpAndSettle();
}
Future<void> confirmRetry(WidgetTester tester) async {
/// Retry lives in the run detail's more menu.
Future<void> openRetry(WidgetTester tester) async {
await tester.tap(find.byKey(runMoreMenuKey));
await tester.pumpAndSettle();
await tester.tap(find.byKey(retryActionKey));
await tester.pumpAndSettle();
}
/// Whether the more menu offers Retry; the menu is closed again afterwards.
Future<bool> retryOffered(WidgetTester tester) async {
if (find.byKey(runMoreMenuKey).evaluate().isEmpty) return false;
await tester.tap(find.byKey(runMoreMenuKey));
await tester.pumpAndSettle();
final offered = find.byKey(retryActionKey).evaluate().isNotEmpty;
await tester.tapAt(const Offset(2, 2));
await tester.pumpAndSettle();
return offered;
}
Future<void> confirmRetry(WidgetTester tester) async {
await openRetry(tester);
await tester.tap(find.byKey(retryConfirmKey));
await tester.pump();
}
@@ -22,12 +22,11 @@ void main() {
expect(find.text(retryFailedTitle), findsOneWidget);
expect(find.byKey(runMoreMenuKey), findsOneWidget);
expect(find.byKey(retryActionKey), findsOneWidget);
expect(await retryOffered(tester), isTrue);
expect(find.byKey(cancelActionKey), findsNothing);
expect(gateway.retryCalls, isEmpty);
await tester.tap(find.byKey(retryActionKey));
await tester.pumpAndSettle();
await openRetry(tester);
expect(find.text(retryDialogTitle(7)), findsOneWidget);
expect(find.text(retryDialogMessage), findsOneWidget);
expect(gateway.retryCalls, isEmpty);
@@ -36,7 +35,7 @@ void main() {
await tester.pumpAndSettle();
expect(gateway.retryCalls, isEmpty);
expect(opened, isEmpty);
expect(find.byKey(retryActionKey), findsOneWidget);
expect(await retryOffered(tester), isTrue);
await confirmRetry(tester);
expect(gateway.retryCalls, hasLength(1));
@@ -58,7 +57,7 @@ void main() {
expect(opened, [8]);
expect(find.text(retryCreatedTitle), findsOneWidget);
expect(find.text(retryFailedTitle), findsNothing);
expect(find.byKey(retryActionKey), findsNothing);
expect(await retryOffered(tester), isFalse);
expect(
gateway.calls.where((call) => call.type == 'get_run').last.fields,
{'run_id': 8},
@@ -80,8 +79,7 @@ void main() {
onRunSelected: opened.add,
);
await tester.tap(find.byKey(retryActionKey));
await tester.pumpAndSettle();
await openRetry(tester);
await tester.tap(find.byKey(retryRestartKey));
await tester.pumpAndSettle();
expect(find.text(restartDialogTitle(7)), findsOneWidget);