Runs: failure banner actions, immediate run menu; pipeline rows get Run

- "Why it failed" banner offers Retry (the retry prompt), Run again… (New
  run form pre-filled; now allowed for failed runs from the banner) and
  Open in chat (the run's existing send-to-chat flow).
- The run ⋮ menu shows while the detail loads: items listed from the run's
  list row, disabled until get_run answers (the loading placeholder had no
  actions, so the menu waited for the full detail).
- Pipelines list rows: Run… in the row menu (not for archived pipelines)
  and a trailing Run button when the list sits beside its detail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 00:32:57 +00:00
parent accb9970b6
commit 072db8f749
15 changed files with 578 additions and 22 deletions
@@ -0,0 +1,156 @@
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/retry_wording.dart';
import 'package:pipelines_app/features/runs/actions/title_wording.dart';
import 'package:pipelines_app/features/runs/screen.dart';
import 'package:pipelines_app/features/runs/ui/run_failure_actions.dart';
import 'package:pipelines_app/features/runs/ui/run_more_menu.dart';
import 'run_retry_wiring_support.dart';
Future<void> _mount(
WidgetTester tester,
ApiGateway gateway, {
Future<void> Function(BuildContext, JsonMap)? onOpenInChat,
bool settle = true,
}) async {
tester.view.physicalSize = const Size(1200, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: RunsScreen(
gateway: gateway,
initialRunId: 7,
onOpenInChat: onOpenInChat,
),
),
),
);
if (settle) await tester.pumpAndSettle();
}
/// A gateway that lists run 7 but never answers its detail.
class _SlowDetailGateway implements ApiGateway {
final pending = Completer<JsonMap>();
@override
Stream<JsonMap> get frames => const Stream.empty();
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) =>
switch (type) {
'list_runs' => Future.value({
'runs': [
{'id': 7, 'title': 'Slow run', 'status': 'failed', 'name': 'p'},
],
}),
'get_run' => pending.future,
_ => Future.error(UnsupportedError(type)),
};
}
void main() {
testWidgets('the failure banner offers Retry, Run again… and Open in chat', (
tester,
) async {
final gateway = RetryWiringGateway();
addTearDown(gateway.framesController.close);
gateway.details[7] = {
...retryFailedDetail(),
'pipeline_id': 3,
'version': 2,
'failure_reason': 'The build stage exited with status 2.',
};
final opened = <JsonMap>[];
await _mount(
tester,
gateway,
onOpenInChat: (context, run) async => opened.add(run),
);
expect(find.text('The build stage exited with status 2.'), findsOneWidget);
expect(find.byKey(runFailureRetryKey), findsOneWidget);
expect(find.byKey(runFailureRunAgainKey), findsOneWidget);
expect(find.byKey(runFailureOpenInChatKey), findsOneWidget);
// Retry is the menu's retry prompt; nothing is sent until its confirm.
await tester.tap(find.byKey(runFailureRetryKey));
await tester.pumpAndSettle();
expect(find.text(retryDialogTitle(7)), findsOneWidget);
await tester.tap(find.byKey(retryKeepKey));
await tester.pumpAndSettle();
expect(gateway.retryCalls, isEmpty);
// Open in chat hands the run to the host's send-to-chat flow.
await tester.tap(find.byKey(runFailureOpenInChatKey));
await tester.pumpAndSettle();
expect(opened.single['id'], 7);
// Run again reads the run's pipeline for the pre-filled New run form.
await tester.tap(find.byKey(runFailureRunAgainKey));
await tester.pumpAndSettle();
expect(gateway.calls.map((call) => call.type), contains('get_pipeline'));
});
testWidgets('a failed run without a pipeline offers no Run again', (
tester,
) async {
final gateway = RetryWiringGateway();
addTearDown(gateway.framesController.close);
gateway.details[7] = {...retryFailedDetail(), 'failure_reason': 'Boom.'};
await _mount(tester, gateway);
expect(find.byKey(runFailureRetryKey), findsOneWidget);
expect(find.byKey(runFailureRunAgainKey), findsNothing);
expect(find.byKey(runFailureOpenInChatKey), findsNothing);
});
testWidgets('the more menu shows while the detail loads, items disabled', (
tester,
) async {
final gateway = _SlowDetailGateway();
await _mount(tester, gateway, settle: false);
await tester.pump();
await tester.pump(const Duration(milliseconds: 50));
expect(find.text('Loading run details…'), findsOneWidget);
expect(find.byKey(runMoreMenuKey), findsOneWidget);
await tester.tap(find.byKey(runMoreMenuKey));
await tester.pump();
await tester.pump(const Duration(milliseconds: 400));
final rename = tester.widget<PopupMenuItem<Object?>>(
find.ancestor(
of: find.text(runTitleActionLabel),
matching: find.byWidgetPredicate((w) => w is PopupMenuItem),
),
);
expect(rename.enabled, isFalse);
gateway.pending.complete({
'run_detail': {
'id': 7,
'title': 'Slow run',
'status': 'failed',
'name': 'p',
'steps': const <JsonMap>[],
},
});
await tester.tapAt(const Offset(2, 2));
await tester.pumpAndSettle();
await tester.tap(find.byKey(runMoreMenuKey));
await tester.pumpAndSettle();
final loaded = tester.widget<PopupMenuItem<Object?>>(
find.ancestor(
of: find.text(runTitleActionLabel),
matching: find.byWidgetPredicate((w) => w is PopupMenuItem),
),
);
expect(loaded.enabled, isTrue);
});
}