diff --git a/app/lib/application/pipelines_app.dart b/app/lib/application/pipelines_app.dart index afc06bfd..de92448a 100644 --- a/app/lib/application/pipelines_app.dart +++ b/app/lib/application/pipelines_app.dart @@ -3,6 +3,7 @@ import '../core/servers/server_context.dart'; import '../core/servers/elevation/elevation_dialog.dart'; import '../core/servers/elevation/machine_elevation.dart'; import 'dart:async'; +import '../features/runs/domain/run_tab_counts.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/scheduler.dart'; @@ -70,6 +71,8 @@ bool shouldReconnectOnForeground(ConnectionKind kind) => /// /// Tests may inject the client and route-information provider; the session /// owns the socket either way, so there is never a second app-level connection. +typedef _RunIndicators = ({int attention, int running, int failed}); + class PipelinesApp extends StatefulWidget { const PipelinesApp({ super.key, @@ -203,7 +206,11 @@ class _PipelinesAppState extends State int _attentionEpoch = 0; /// The count the shell's Runs tab shows; only a changed count rebuilds it. - final ValueNotifier _attentionCount = ValueNotifier(0); + final _attentionCount = ValueNotifier<_RunIndicators>(( + attention: 0, + running: 0, + failed: 0, + )); /// Android background delivery (no service elsewhere). final NotificationServiceBridge _deliveryService = @@ -552,13 +559,18 @@ class _PipelinesAppState extends State if (_session.connected) unawaited(_ackSync.connected()); } - /// Mirrors the controller's entry count for the shell. The Runs list seeds + /// Mirrors attention and independent status counts for the shell. The Runs list seeds /// the rows from inside its own build, and the shell sits above that layout /// scope, so a count that changes mid-build lands after the frame; a pushed /// frame arrives outside any build and applies at once. void _attentionChanged() { if (!mounted) return; - final count = _attention.entries.length; + final statuses = runTabCounts(_attention.rows); + final count = ( + attention: _attention.entries.length, + running: statuses.running, + failed: statuses.failed, + ); if (count == _attentionCount.value) return; if (SchedulerBinding.instance.schedulerPhase == SchedulerPhase.persistentCallbacks) { @@ -777,10 +789,10 @@ class _PipelinesAppState extends State void _chatSyncChanged() => _chatRuntime.syncToken.value = widget.chatPool?.revision ?? _session.connectionEpoch; - /// The shell rebuilds its Runs tab badge from the attention count alone; the + /// The shell rebuilds its Runs tab badges from the shared status counts; the /// destination bodies keep their state through it. Widget _buildShell(BuildContext context, AppRoute route) => - ValueListenableBuilder( + ValueListenableBuilder<_RunIndicators>( valueListenable: _attentionCount, builder: (context, count, _) => _terminals.surround( _shellFor(route, count), @@ -789,7 +801,7 @@ class _PipelinesAppState extends State ), ); - Widget _shellFor(AppRoute route, int attentionCount) { + Widget _shellFor(AppRoute route, _RunIndicators counts) { // Each tab is built from the route it last showed, so switching tabs keeps // an open run, pipeline or chat instead of resetting it. AppRoute tab(AppDestination destination) { @@ -812,7 +824,9 @@ class _PipelinesAppState extends State if (_destinationOf(route.kind) == AppDestination.chat) _terminals.toggle(), ], - attentionCount: attentionCount, + attentionCount: counts.attention, + runningRunCount: counts.running, + failedRunCount: counts.failed, destination: _destinationOf(route.kind), onDestinationSelected: _selectDestination, onClosePage: () => _delegate.goTo( diff --git a/app/lib/features/runs/domain/run_tab_counts.dart b/app/lib/features/runs/domain/run_tab_counts.dart new file mode 100644 index 00000000..90c763fd --- /dev/null +++ b/app/lib/features/runs/domain/run_tab_counts.dart @@ -0,0 +1,27 @@ +import '../../../core/api_gateway.dart'; + +typedef RunTabCounts = ({int running, int failed}); + +/// Independent status counts from known, unfiltered server summaries. +/// Dismissing a notification does not change a run's failed status. +RunTabCounts runTabCounts(Iterable runs) { + var running = 0; + var failed = 0; + for (final run in runs) { + if (run['status'] == 'failed') failed++; + if (const { + 'succeeded', + 'failed', + 'canceled', + 'interrupted', + }.contains(run['status'])) { + continue; + } + // Older summaries omit the execution flag but still name the live state. + if (run['executing'] == true || + (!run.containsKey('executing') && run['status'] == 'running')) { + running++; + } + } + return (running: running, failed: failed); +} diff --git a/app/lib/features/runs/ui/runs_list.dart b/app/lib/features/runs/ui/runs_list.dart index 702dbd7a..8ba56b64 100644 --- a/app/lib/features/runs/ui/runs_list.dart +++ b/app/lib/features/runs/ui/runs_list.dart @@ -9,6 +9,7 @@ import '../../attention/runtime/attention_controller.dart'; import '../../attention/runtime/attention_store.dart'; import '../../attention/ui/needs_you_runs_heading.dart'; import '../domain/run_models.dart'; +import '../domain/run_tab_counts.dart'; import '../../../shell/shell_bar.dart'; import '../../../shell/shell_list_shortcuts.dart'; import 'run_list_row.dart'; @@ -102,14 +103,19 @@ class RunsList extends StatelessWidget { if (!ShellBar.available(context)) { return _ownBar(context, [const Spacer(), ...actions]); } + final counts = runTabCounts(controller.runs); return ShellBar( active: active, actions: actions, // The Runs tab counts runs still executing. child: ShellBadge( kind: ShellBadgeKind.running, - count: controller.runs.where((run) => run['executing'] == true).length, - child: _shortcutList(context), + count: counts.running, + child: ShellBadge( + kind: ShellBadgeKind.failed, + count: counts.failed, + child: _shortcutList(context), + ), ), ); } diff --git a/app/lib/shell/adaptive_shell.dart b/app/lib/shell/adaptive_shell.dart index 53ec95f7..83a1c811 100644 --- a/app/lib/shell/adaptive_shell.dart +++ b/app/lib/shell/adaptive_shell.dart @@ -23,6 +23,8 @@ class AdaptiveShell extends StatefulWidget { this.onClosePage, this.onSearch, this.attentionCount = 0, + this.runningRunCount, + this.failedRunCount, this.listPaneWidthStore = const SharedPreferencesListPaneWidthStore(), this.barActions = const [], }); @@ -46,10 +48,13 @@ class AdaptiveShell extends StatefulWidget { /// shell tests and compositions without routing keep their tab set only. final VoidCallback? onSearch; - /// Runs needing the operator today, mirrored on the Runs tab in every mount - /// so it stays visible from any destination. Zero shows no badge. + /// Runs needing the operator today, retained in the tab's accessible label. final int attentionCount; + /// App-wide counts when available; standalone screens publish their own. + final int? runningRunCount; + final int? failedRunCount; + @override State createState() => _AdaptiveShellState(); } @@ -109,7 +114,7 @@ class _AdaptiveShellState extends State { }); } - /// The destination's icon; only Runs carries the attention count. + /// Runs has independent status counts; Chat has its unread count. Widget _icon(AppDestination destination, IconData data) { Widget icon = Icon(data); if (destination == AppDestination.chat) { @@ -121,17 +126,15 @@ class _AdaptiveShellState extends State { ); } if (destination != AppDestination.runs) return icon; - // One indicator: runs that need you outrank runs in progress, so the - // tab never wears two counts at once. - final attention = widget.attentionCount > 0; - return AttentionDestinationIcon( - count: widget.attentionCount, - child: ActivityBadge( - key: const ValueKey('shell.badge.runs.running'), - count: attention ? 0 : _bar.badge(destination, ShellBadgeKind.running), - label: 'runs in progress', - child: icon, - ), + return RunsDestinationIcon( + running: + widget.runningRunCount ?? + _bar.badge(destination, ShellBadgeKind.running), + failed: + widget.failedRunCount ?? + _bar.badge(destination, ShellBadgeKind.failed), + attention: widget.attentionCount, + child: icon, ); } diff --git a/app/lib/shell/attention_badge.dart b/app/lib/shell/attention_badge.dart index 68f5369e..234df09a 100644 --- a/app/lib/shell/attention_badge.dart +++ b/app/lib/shell/attention_badge.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import '../features/attention/domain/attention_models.dart'; import '../ui/motion/motion.dart'; -/// Mirrors the Runs-heading bell count onto the Runs destination icon. +/// A generic attention count, separate from the Runs tab's status counts. /// /// The bell itself lives in the Runs heading, so without this the count would /// be visible only on that destination; the web mirrors it on the rail and @@ -44,7 +44,57 @@ class AttentionDestinationIcon extends StatelessWidget { } } -/// A small count on a tab icon: blue for activity (runs in progress, unread +/// Both status counts remain visible: failures never hide executing work. +class RunsDestinationIcon extends StatelessWidget { + const RunsDestinationIcon({ + super.key, + required this.running, + required this.failed, + required this.child, + this.attention = 0, + }); + + final int running; + final int failed; + final int attention; + final Widget child; + + @override + Widget build(BuildContext context) { + final colors = Theme.of(context).colorScheme; + final labels = [ + if (running > 0) '$running runs in progress', + if (failed > 0) '$failed failed runs', + if (attention > 0) attentionBadgeLabel(attention), + ]; + return Semantics( + label: labels.join(', '), + child: ExcludeSemantics( + child: Tooltip( + message: labels.isEmpty ? 'Runs' : 'Runs: ${labels.join(', ')}', + excludeFromSemantics: true, + child: Badge.count( + key: const ValueKey('shell.badge.runs.failed'), + count: failed, + maxCount: 99, + isLabelVisible: failed > 0, + backgroundColor: colors.error, + textColor: colors.onError, + child: ActivityBadge( + key: const ValueKey('shell.badge.runs.running'), + count: running, + label: 'runs in progress', + bottom: true, + child: child, + ), + ), + ), + ), + ); + } +} + +/// A small primary-theme count on a tab icon for activity (runs in progress, unread /// chats), so it reads apart from the red needs-you count. class ActivityBadge extends StatelessWidget { const ActivityBadge({ diff --git a/app/lib/shell/shell_bar.dart b/app/lib/shell/shell_bar.dart index f457f235..d9e3718d 100644 --- a/app/lib/shell/shell_bar.dart +++ b/app/lib/shell/shell_bar.dart @@ -357,6 +357,9 @@ enum ShellBadgeKind { /// Runs still executing. running, + /// Runs whose server status is failed, independent of attention dismissal. + failed, + /// Chats with messages not yet seen. unread, } diff --git a/app/notes/runs-tab-status-indicators.md b/app/notes/runs-tab-status-indicators.md new file mode 100644 index 00000000..a62cfebd --- /dev/null +++ b/app/notes/runs-tab-status-indicators.md @@ -0,0 +1,22 @@ +# Independent Runs tab indicators + +The Runs tab now shows the executing count at the lower edge in the primary +theme colour and the failed count at the upper edge in the error colour. +Neither suppresses the other. Zero hides its indicator; the failed label caps +at 99+ while the tooltip and accessible label retain the actual count. + +Counts use known, unfiltered server summaries and update from existing pushed +frames without extra polling. Failed status is independent of notification +dismissals and the daily attention window. Terminal statuses override a stale +execution flag. Older summaries without that flag can still name running work. +Waiting decisions remain announced by the attention label and available in the +Needs you bell; they are not mislabelled as failed runs. + +The app-level observer now republishes status changes even when total +attention is unchanged (for example a waiting run becoming failed). Standalone +Runs lists also publish both counts through the existing shell registry. + +Focused validation: 24 tests passed, covering both colours/positions in light +and dark at narrow/wide widths, zero states, live updates from another tab, +unchanged-attention transitions, and terminal/older status summaries. Analysis +was clean. Full-suite and rendered checks follow this focused pass. diff --git a/app/test/application/attention_badge_wiring_test.dart b/app/test/application/attention_badge_wiring_test.dart index 2ee9e9d4..4d77c86f 100644 --- a/app/test/application/attention_badge_wiring_test.dart +++ b/app/test/application/attention_badge_wiring_test.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/core/transport/pipelines_client.dart'; +import 'package:pipelines_app/shell/attention_badge.dart'; import '../core/transport/pipelines_client_test.dart' show FakeChannel; import 'pipelines_app_test.dart' show pumpApp, replyList; @@ -17,77 +18,74 @@ void main() { Finder badgeCount(String count) => find.descendant(of: find.byType(Badge), matching: find.text(count)); - testWidgets( - 'a run_event folded to waiting raises the Runs tab badge from Pipelines', - (tester) async { - final semantics = tester.ensureSemantics(); - final channel = FakeChannel()..readyCompleter.complete(); - final client = PipelinesClient(channelFactory: (_) => channel); - final provider = PlatformRouteInformationProvider( - initialRouteInformation: RouteInformation(uri: Uri.parse('/runs')), - ); - addTearDown(provider.dispose); + testWidgets('waiting is announced without being labelled as a failed run', ( + tester, + ) async { + final semantics = tester.ensureSemantics(); + final channel = FakeChannel()..readyCompleter.complete(); + final client = PipelinesClient(channelFactory: (_) => channel); + final provider = PlatformRouteInformationProvider( + initialRouteInformation: RouteInformation(uri: Uri.parse('/runs')), + ); + addTearDown(provider.dispose); - await pumpApp( - tester, - channel: channel, - client: client, - provider: provider, - ); - await replyList( - tester, - channel, - runs: [ - { - 'id': 1, - 'pipeline_id': 4, - 'name': 'nightly', - 'title': 'Nightly build', - 'status': 'running', - 'created_at': DateTime.now().toIso8601String(), - }, - ], - ); - expect(find.text('Nightly build'), findsWidgets); - expect(tester.widget(find.byType(Badge)).isLabelVisible, isFalse); - expect(find.bySemanticsLabel(needingAttention), findsNothing); + await pumpApp(tester, channel: channel, client: client, provider: provider); + await replyList( + tester, + channel, + runs: [ + { + 'id': 1, + 'pipeline_id': 4, + 'name': 'nightly', + 'title': 'Nightly build', + 'status': 'running', + 'created_at': DateTime.now().toIso8601String(), + }, + ], + ); + expect(find.text('Nightly build'), findsWidgets); + expect(tester.widget(find.byType(Badge)).isLabelVisible, isFalse); + expect(find.bySemanticsLabel(needingAttention), findsNothing); - await tester.tap( - find.byKey(const ValueKey('shell.destination.pipelines')), - ); - await tester.pump(); - expect(provider.value.uri.path, '/pipelines'); - await waitForRequest(tester, channel, 'list_pipelines'); - // The Runs page may still be fading out, but it is no longer the - // active page: nothing on it takes a tap. - expect(find.text('Nightly build').hitTestable(), findsNothing); + await tester.tap(find.byKey(const ValueKey('shell.destination.pipelines'))); + await tester.pump(); + expect(provider.value.uri.path, '/pipelines'); + await waitForRequest(tester, channel, 'list_pipelines'); + // The Runs page may still be fading out, but it is no longer the + // active page: nothing on it takes a tap. + expect(find.text('Nightly build').hitTestable(), findsNothing); - channel.incoming.add( - jsonEncode({'type': 'run_event', 'run_id': 1, 'status': 'waiting'}), - ); - await tester.pump(); - await tester.pump(); + channel.incoming.add( + jsonEncode({'type': 'run_event', 'run_id': 1, 'status': 'waiting'}), + ); + await tester.pump(); + await tester.pump(); - expect(provider.value.uri.path, '/pipelines'); - expect(tester.widget(find.byType(Badge)).isLabelVisible, isTrue); - expect(badgeCount('1'), findsOneWidget); - expect( - find.bySemanticsLabel(RegExp('Notifications, 1 needing attention')), - findsOneWidget, - ); + expect(provider.value.uri.path, '/pipelines'); + expect(tester.widget(find.byType(Badge)).isLabelVisible, isFalse); + expect( + tester + .widget(find.byType(RunsDestinationIcon)) + .failed, + 0, + ); + expect( + find.bySemanticsLabel(RegExp('Notifications, 1 needing attention')), + findsOneWidget, + ); - // The decision taken elsewhere clears the badge the same way. - channel.incoming.add( - jsonEncode({'type': 'run_event', 'run_id': 1, 'status': 'succeeded'}), - ); - await tester.pump(); - await tester.pump(); - expect(tester.widget(find.byType(Badge)).isLabelVisible, isFalse); - expect(badgeCount('1'), findsNothing); - expect(find.bySemanticsLabel(needingAttention), findsNothing); - semantics.dispose(); - }, - ); + // The decision taken elsewhere clears the badge the same way. + channel.incoming.add( + jsonEncode({'type': 'run_event', 'run_id': 1, 'status': 'succeeded'}), + ); + await tester.pump(); + await tester.pump(); + expect(tester.widget(find.byType(Badge)).isLabelVisible, isFalse); + expect(badgeCount('1'), findsNothing); + expect(find.bySemanticsLabel(needingAttention), findsNothing); + semantics.dispose(); + }); testWidgets('a new waiting run pushed before any list read is counted', ( tester, @@ -117,6 +115,12 @@ void main() { await tester.pump(); expect(provider.value.uri.path, '/settings'); - expect(badgeCount('1'), findsOneWidget); + expect(badgeCount('1'), findsNothing); + expect( + tester + .widget(find.byType(RunsDestinationIcon)) + .failed, + 0, + ); }); } diff --git a/app/test/application/run_tab_indicators_test.dart b/app/test/application/run_tab_indicators_test.dart new file mode 100644 index 00000000..f14e5041 --- /dev/null +++ b/app/test/application/run_tab_indicators_test.dart @@ -0,0 +1,95 @@ +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/core/transport/pipelines_client.dart'; +import 'package:pipelines_app/shell/attention_badge.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +import '../core/transport/pipelines_client_test.dart' show FakeChannel; +import 'pipelines_app_test.dart' show pumpApp, replyList; + +void main() { + testWidgets('both run counts update while another destination is visible', ( + tester, + ) async { + SharedPreferences.setMockInitialValues({}); + final channel = FakeChannel()..readyCompleter.complete(); + final client = PipelinesClient(channelFactory: (_) => channel); + final provider = PlatformRouteInformationProvider( + initialRouteInformation: RouteInformation(uri: Uri.parse('/runs')), + ); + addTearDown(provider.dispose); + await pumpApp(tester, channel: channel, client: client, provider: provider); + final now = DateTime.now().toIso8601String(); + await replyList( + tester, + channel, + runs: [ + { + 'id': 1, + 'pipeline_id': 1, + 'name': 'fixture', + 'title': 'Running job', + 'status': 'running', + 'executing': true, + 'created_at': now, + }, + { + 'id': 2, + 'pipeline_id': 1, + 'name': 'fixture', + 'title': 'Failed job', + 'status': 'failed', + 'executing': false, + 'created_at': now, + }, + { + 'id': 3, + 'pipeline_id': 1, + 'name': 'fixture', + 'title': 'Decision job', + 'status': 'waiting', + 'executing': false, + 'created_at': now, + }, + ], + ); + await tester.pumpAndSettle(); + RunsDestinationIcon counts() => + tester.widget(find.byType(RunsDestinationIcon)); + expect(counts().running, 1); + expect(counts().failed, 1); + expect(counts().attention, 2); + + await tester.tap(find.byKey(const ValueKey('shell.destination.pipelines'))); + await tester.pumpAndSettle(); + channel.incoming.add( + jsonEncode({ + 'type': 'run_event', + 'run_id': 3, + 'status': 'failed', + 'executing': false, + }), + ); + await tester.pumpAndSettle(); + expect(provider.value.uri.path, '/pipelines'); + expect(counts().running, 1); + expect(counts().failed, 2); + // Waiting -> failed must repaint even though total attention is unchanged. + expect(counts().attention, 2); + + channel.incoming.add( + jsonEncode({ + 'type': 'run_event', + 'run_id': 1, + 'status': 'succeeded', + 'executing': false, + }), + ); + await tester.pumpAndSettle(); + expect(counts().running, 0); + expect(counts().failed, 2); + expect(tester.takeException(), isNull); + }); +} diff --git a/app/test/features/runs/domain/run_tab_counts_test.dart b/app/test/features/runs/domain/run_tab_counts_test.dart new file mode 100644 index 00000000..b52eb247 --- /dev/null +++ b/app/test/features/runs/domain/run_tab_counts_test.dart @@ -0,0 +1,41 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/features/runs/domain/run_tab_counts.dart'; + +void main() { + test('running and failed statuses are counted independently', () { + expect( + runTabCounts([ + {'status': 'running', 'executing': true}, + {'status': 'queued', 'executing': true}, + {'status': 'failed', 'executing': false}, + {'status': 'waiting', 'executing': false}, + {'status': 'canceled'}, + {'status': 'interrupted'}, + ]), + (running: 2, failed: 1), + ); + }); + + test('terminal statuses override stale execution flags', () { + expect( + runTabCounts([ + {'status': 'failed', 'executing': true}, + {'status': 'succeeded', 'executing': true}, + ]), + (running: 0, failed: 1), + ); + }); + + test('older running summaries work without inventing other live states', () { + expect( + runTabCounts([ + {'status': 'running'}, + {'status': 'running', 'executing': false}, + {'status': 'queued'}, + {'status': 'waiting'}, + ]), + (running: 1, failed: 0), + ); + expect(runTabCounts([]), (running: 0, failed: 0)); + }); +} diff --git a/app/test/shell/attention_badge_test.dart b/app/test/shell/attention_badge_test.dart index a02d7907..6b8f720e 100644 --- a/app/test/shell/attention_badge_test.dart +++ b/app/test/shell/attention_badge_test.dart @@ -7,8 +7,8 @@ import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart'; /// bar at full width on a phone and right-aligned on a wide window. Zero draws /// the bare icon with no count and no attention semantics. void main() { - final needingAttention = RegExp('Notifications, 3 needing attention'); - final anyAttention = RegExp('needing attention'); + final needingAttention = RegExp('3 failed runs'); + final anyAttention = RegExp('failed runs'); Future pumpShell( WidgetTester tester, { @@ -19,7 +19,7 @@ void main() { tester.view.devicePixelRatio = 1; addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); - final shell = AdaptiveShell(attentionCount: count); + final shell = AdaptiveShell(failedRunCount: count); await tester.pumpWidget(MaterialApp(home: shell)); } diff --git a/app/test/shell/pane_bar_row_test.dart b/app/test/shell/pane_bar_row_test.dart index 2907ec60..0f5bae59 100644 --- a/app/test/shell/pane_bar_row_test.dart +++ b/app/test/shell/pane_bar_row_test.dart @@ -66,9 +66,10 @@ void main() { ), ); - Widget shell({int attention = 0}) { + Widget shell({int attention = 0, int failed = 0}) { final app = AdaptiveShell( attentionCount: attention, + failedRunCount: failed, destinationBodies: { AppDestination.runs: (_) => ShellBadge( kind: ShellBadgeKind.running, @@ -218,15 +219,15 @@ void main() { ); }); - testWidgets('the Runs tab shows one indicator: attention outranks running', ( + testWidgets('the Runs tab shows running and failed indicators together', ( tester, ) async { await setSize(tester, const Size(1200, 800)); - await tester.pumpWidget(shell(attention: 2)); + await tester.pumpWidget(shell(attention: 2, failed: 2)); await tester.pump(); await tester.pump(); expect(find.text('2'), findsOneWidget); - expect(find.text('4'), findsNothing); + expect(find.text('4'), findsOneWidget); await tester.pumpWidget(shell()); await tester.pump(); diff --git a/app/test/shell/run_status_indicators_test.dart b/app/test/shell/run_status_indicators_test.dart new file mode 100644 index 00000000..8e7d7219 --- /dev/null +++ b/app/test/shell/run_status_indicators_test.dart @@ -0,0 +1,50 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/shell/adaptive_shell.dart'; + +void main() { + for (final width in [390.0, 1000.0]) { + for (final brightness in Brightness.values) { + testWidgets('running and failed are distinct at $width $brightness', ( + tester, + ) async { + tester.view.physicalSize = Size(width, 900); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + final semantics = tester.ensureSemantics(); + final theme = ThemeData(brightness: brightness); + await tester.pumpWidget( + MaterialApp( + theme: theme, + home: const AdaptiveShell(runningRunCount: 2, failedRunCount: 3), + ), + ); + await tester.pumpAndSettle(); + final failed = find.byKey(const ValueKey('shell.badge.runs.failed')); + final running = find.byKey(const ValueKey('shell.badge.runs.running')); + expect( + find.descendant(of: failed, matching: find.text('3')), + findsOneWidget, + ); + expect( + find.descendant(of: running, matching: find.text('2')), + findsOneWidget, + ); + expect( + tester.widget(failed).backgroundColor, + theme.colorScheme.error, + ); + expect( + tester.getRect(find.text('3')).bottom, + lessThan(tester.getRect(find.text('2')).top), + ); + expect( + find.bySemanticsLabel(RegExp('2 runs in progress, 3 failed runs')), + findsOneWidget, + ); + expect(tester.takeException(), isNull); + semantics.dispose(); + }); + } + } +}