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/decision_action.dart'; import 'package:pipelines_app/features/runs/actions/decision_wording.dart'; import '../domain/run_exhausted_decision_fixture.dart'; import 'retry_test_support.dart' show FakeRetryGateway; void main() { testWidgets('an exhaustion decision shows readable options and the visit ' 'count, and sends the option key for the exhausted stage', ( tester, ) async { final gateway = FakeRetryGateway( (type, fields) async => { 'run_detail': {...exhaustedDecisionRun(), 'status': 'running'}, }, ); final changed = []; await tester.pumpWidget( MaterialApp( home: Scaffold( body: Center( child: HumanDecisionAction( run: exhaustedDecisionRun(), gateway: gateway, onRunChanged: changed.add, ), ), ), ), ); await tester.tap(find.byKey(decisionActionKey)); await tester.pumpAndSettle(); expect(find.text('Accept as is'), findsOneWidget); expect(find.text('One more round'), findsOneWidget); expect(find.text('Abort'), findsOneWidget); expect(find.text('→ implement'), findsOneWidget); expect( find.text('review reached its visit limit: visit 3 of 3'), findsOneWidget, ); await tester.tap(find.text('One more round')); await tester.pump(); await tester.tap(find.text(decisionConfirmLabel)); await tester.pumpAndSettle(); final decide = gateway.calls.singleWhere((c) => c.type == 'decide_run'); expect(decide.fields, { 'run_id': 9, 'option': 'continue', 'stage': 'review', }); expect(changed, isNotEmpty); }); }