import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/features/attention/runtime/attention_store.dart'; import 'package:pipelines_app/features/attention/ui/needs_you_keys.dart'; import 'attention_runs_test_support.dart'; /// The hardest real-app case: a narrow phone at a doubled text scale. Both the /// Runs list chrome and the native sheet must keep the bell and every action /// inside the viewport. void main() { testWidgets('both hosts fit the bell and sheet at 320 logical px and 2x', ( tester, ) async { tester.view.devicePixelRatio = 2; tester.view.physicalSize = const Size(640, 1280); addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); final gateway = AttentionRunsGateway(); addTearDown(gateway.framesController.close); for (final native in [false, true]) { await mountAttentionRuns( tester, gateway, cupertino: native, store: MemoryAttentionStore(), runs: [ attentionRun( 1, 'waiting', title: 'Approve a release candidate at 320 px', ), attentionRun( 2, 'failed', title: 'A failed run with a label long enough to wrap', diagnostic: 'Stage 3 stopped because the credential is missing.', ), ], request: native ? 1 : 0, textScale: 2, key: ValueKey(native), ); expect(find.byKey(attentionBellKey), findsOneWidget); final listError = tester.takeException(); expect( listError, isNull, reason: listError is FlutterError ? '${native ? 'Cupertino' : 'Material'} list: ${listError.toStringDeep()}' : '${native ? 'Cupertino' : 'Material'} list: $listError', ); await openAttentionSheet(tester); final sheetError = tester.takeException(); expect( sheetError, isNull, reason: sheetError is FlutterError ? '${native ? 'Cupertino' : 'Material'} sheet: ${sheetError.toStringDeep()}' : '${native ? 'Cupertino' : 'Material'} sheet: $sheetError', ); final sheet = tester.getRect(find.byKey(attentionSheetKey)); expect(sheet.left, greaterThanOrEqualTo(0)); expect(sheet.right, lessThanOrEqualTo(320)); expect(sheet.top, greaterThanOrEqualTo(0)); expect(sheet.bottom, lessThanOrEqualTo(640)); await tester.binding.handlePopRoute(); await tester.pumpAndSettle(); } }); }