import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/features/runs/actions/cancel_wording.dart'; import 'package:pipelines_app/features/runs/actions/retry_wording.dart'; import 'package:pipelines_app/features/runs/ui/run_detail_actions.dart'; import 'run_retry_wiring_support.dart'; void main() { testWidgets('a hidden retry adds no leading gap before Cancel', ( tester, ) async { final gateway = RetryWiringGateway(); addTearDown(gateway.framesController.close); await tester.pumpWidget( MaterialApp( home: Scaffold( body: Padding( padding: const EdgeInsets.all(16), child: RunDetailActions( run: retryCreatedDetail(id: 7), gateway: gateway, onRunChanged: (_) {}, ), ), ), ), ); await tester.pumpAndSettle(); // Retry is not eligible on the running run and must not consume spacing. expect(find.byKey(retryActionKey), findsNothing); // Rename lives in the more menu; Cancel now leads the row. final cancel = tester.getRect(find.byKey(cancelActionKey)); expect(cancel.left, closeTo(16, 0.5)); }); for (final cupertino in [false, true]) { testWidgets('320 px at 2x keeps Retry reachable ($cupertino)', ( tester, ) async { tester.view.physicalSize = const Size(320, 480); tester.view.devicePixelRatio = 1; addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); final gateway = RetryWiringGateway(); addTearDown(gateway.framesController.close); Widget scale(BuildContext context, Widget? app) => MediaQuery( data: MediaQuery.of( context, ).copyWith(textScaler: const TextScaler.linear(2)), child: app!, ); // The action row itself, in the detail's 16 px inset, so the narrow // accessibility state is measured without unrelated header controls. final row = Padding( padding: const EdgeInsets.all(16), child: RunDetailActions( run: retryFailedDetail(), gateway: gateway, onRunChanged: (_) {}, ), ); await tester.pumpWidget( cupertino ? CupertinoApp( builder: scale, home: CupertinoPageScaffold(child: SafeArea(child: row)), ) : MaterialApp( builder: scale, home: Scaffold(body: row), ), ); await tester.pumpAndSettle(); expect(find.byKey(retryActionKey).hitTestable(), findsOneWidget); final rect = tester.getRect(find.byKey(retryActionKey)); expect(rect.left, greaterThanOrEqualTo(0)); expect(rect.right, lessThanOrEqualTo(320)); await tester.tap(find.byKey(retryActionKey)); await tester.pumpAndSettle(); expect(find.text(retryDialogTitle(7)), findsOneWidget); await tester.tap(find.byKey(retryKeepKey)); await tester.pumpAndSettle(); expect(gateway.retryCalls, isEmpty); }); } }