Show running and failed run counts independently

Give the Runs tab separate activity and failure indicators so neither suppresses the other. Reuse known summaries and pushed updates, keep failed states separate from decisions and dismissal counts, and update across tabs even when total attention is unchanged.
This commit is contained in:
2026-11-11 22:10:37 +00:00
parent 9551eceaed
commit efca56e4e4
13 changed files with 415 additions and 99 deletions
+21 -7
View File
@@ -3,6 +3,7 @@ import '../core/servers/server_context.dart';
import '../core/servers/elevation/elevation_dialog.dart'; import '../core/servers/elevation/elevation_dialog.dart';
import '../core/servers/elevation/machine_elevation.dart'; import '../core/servers/elevation/machine_elevation.dart';
import 'dart:async'; import 'dart:async';
import '../features/runs/domain/run_tab_counts.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/scheduler.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 /// 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. /// 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 { class PipelinesApp extends StatefulWidget {
const PipelinesApp({ const PipelinesApp({
super.key, super.key,
@@ -203,7 +206,11 @@ class _PipelinesAppState extends State<PipelinesApp>
int _attentionEpoch = 0; int _attentionEpoch = 0;
/// The count the shell's Runs tab shows; only a changed count rebuilds it. /// The count the shell's Runs tab shows; only a changed count rebuilds it.
final ValueNotifier<int> _attentionCount = ValueNotifier<int>(0); final _attentionCount = ValueNotifier<_RunIndicators>((
attention: 0,
running: 0,
failed: 0,
));
/// Android background delivery (no service elsewhere). /// Android background delivery (no service elsewhere).
final NotificationServiceBridge _deliveryService = final NotificationServiceBridge _deliveryService =
@@ -552,13 +559,18 @@ class _PipelinesAppState extends State<PipelinesApp>
if (_session.connected) unawaited(_ackSync.connected()); 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 /// 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 /// scope, so a count that changes mid-build lands after the frame; a pushed
/// frame arrives outside any build and applies at once. /// frame arrives outside any build and applies at once.
void _attentionChanged() { void _attentionChanged() {
if (!mounted) return; 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 (count == _attentionCount.value) return;
if (SchedulerBinding.instance.schedulerPhase == if (SchedulerBinding.instance.schedulerPhase ==
SchedulerPhase.persistentCallbacks) { SchedulerPhase.persistentCallbacks) {
@@ -777,10 +789,10 @@ class _PipelinesAppState extends State<PipelinesApp>
void _chatSyncChanged() => _chatRuntime.syncToken.value = void _chatSyncChanged() => _chatRuntime.syncToken.value =
widget.chatPool?.revision ?? _session.connectionEpoch; 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. /// destination bodies keep their state through it.
Widget _buildShell(BuildContext context, AppRoute route) => Widget _buildShell(BuildContext context, AppRoute route) =>
ValueListenableBuilder<int>( ValueListenableBuilder<_RunIndicators>(
valueListenable: _attentionCount, valueListenable: _attentionCount,
builder: (context, count, _) => _terminals.surround( builder: (context, count, _) => _terminals.surround(
_shellFor(route, count), _shellFor(route, count),
@@ -789,7 +801,7 @@ class _PipelinesAppState extends State<PipelinesApp>
), ),
); );
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 // Each tab is built from the route it last showed, so switching tabs keeps
// an open run, pipeline or chat instead of resetting it. // an open run, pipeline or chat instead of resetting it.
AppRoute tab(AppDestination destination) { AppRoute tab(AppDestination destination) {
@@ -812,7 +824,9 @@ class _PipelinesAppState extends State<PipelinesApp>
if (_destinationOf(route.kind) == AppDestination.chat) if (_destinationOf(route.kind) == AppDestination.chat)
_terminals.toggle(), _terminals.toggle(),
], ],
attentionCount: attentionCount, attentionCount: counts.attention,
runningRunCount: counts.running,
failedRunCount: counts.failed,
destination: _destinationOf(route.kind), destination: _destinationOf(route.kind),
onDestinationSelected: _selectDestination, onDestinationSelected: _selectDestination,
onClosePage: () => _delegate.goTo( onClosePage: () => _delegate.goTo(
@@ -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<JsonMap> 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);
}
+8 -2
View File
@@ -9,6 +9,7 @@ import '../../attention/runtime/attention_controller.dart';
import '../../attention/runtime/attention_store.dart'; import '../../attention/runtime/attention_store.dart';
import '../../attention/ui/needs_you_runs_heading.dart'; import '../../attention/ui/needs_you_runs_heading.dart';
import '../domain/run_models.dart'; import '../domain/run_models.dart';
import '../domain/run_tab_counts.dart';
import '../../../shell/shell_bar.dart'; import '../../../shell/shell_bar.dart';
import '../../../shell/shell_list_shortcuts.dart'; import '../../../shell/shell_list_shortcuts.dart';
import 'run_list_row.dart'; import 'run_list_row.dart';
@@ -102,14 +103,19 @@ class RunsList extends StatelessWidget {
if (!ShellBar.available(context)) { if (!ShellBar.available(context)) {
return _ownBar(context, [const Spacer(), ...actions]); return _ownBar(context, [const Spacer(), ...actions]);
} }
final counts = runTabCounts(controller.runs);
return ShellBar( return ShellBar(
active: active, active: active,
actions: actions, actions: actions,
// The Runs tab counts runs still executing. // The Runs tab counts runs still executing.
child: ShellBadge( child: ShellBadge(
kind: ShellBadgeKind.running, kind: ShellBadgeKind.running,
count: controller.runs.where((run) => run['executing'] == true).length, count: counts.running,
child: _shortcutList(context), child: ShellBadge(
kind: ShellBadgeKind.failed,
count: counts.failed,
child: _shortcutList(context),
),
), ),
); );
} }
+17 -14
View File
@@ -23,6 +23,8 @@ class AdaptiveShell extends StatefulWidget {
this.onClosePage, this.onClosePage,
this.onSearch, this.onSearch,
this.attentionCount = 0, this.attentionCount = 0,
this.runningRunCount,
this.failedRunCount,
this.listPaneWidthStore = const SharedPreferencesListPaneWidthStore(), this.listPaneWidthStore = const SharedPreferencesListPaneWidthStore(),
this.barActions = const [], this.barActions = const [],
}); });
@@ -46,10 +48,13 @@ class AdaptiveShell extends StatefulWidget {
/// shell tests and compositions without routing keep their tab set only. /// shell tests and compositions without routing keep their tab set only.
final VoidCallback? onSearch; final VoidCallback? onSearch;
/// Runs needing the operator today, mirrored on the Runs tab in every mount /// Runs needing the operator today, retained in the tab's accessible label.
/// so it stays visible from any destination. Zero shows no badge.
final int attentionCount; final int attentionCount;
/// App-wide counts when available; standalone screens publish their own.
final int? runningRunCount;
final int? failedRunCount;
@override @override
State<AdaptiveShell> createState() => _AdaptiveShellState(); State<AdaptiveShell> createState() => _AdaptiveShellState();
} }
@@ -109,7 +114,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
}); });
} }
/// 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(AppDestination destination, IconData data) {
Widget icon = Icon(data); Widget icon = Icon(data);
if (destination == AppDestination.chat) { if (destination == AppDestination.chat) {
@@ -121,17 +126,15 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
); );
} }
if (destination != AppDestination.runs) return icon; if (destination != AppDestination.runs) return icon;
// One indicator: runs that need you outrank runs in progress, so the return RunsDestinationIcon(
// tab never wears two counts at once. running:
final attention = widget.attentionCount > 0; widget.runningRunCount ??
return AttentionDestinationIcon( _bar.badge(destination, ShellBadgeKind.running),
count: widget.attentionCount, failed:
child: ActivityBadge( widget.failedRunCount ??
key: const ValueKey('shell.badge.runs.running'), _bar.badge(destination, ShellBadgeKind.failed),
count: attention ? 0 : _bar.badge(destination, ShellBadgeKind.running), attention: widget.attentionCount,
label: 'runs in progress', child: icon,
child: icon,
),
); );
} }
+52 -2
View File
@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import '../features/attention/domain/attention_models.dart'; import '../features/attention/domain/attention_models.dart';
import '../ui/motion/motion.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 /// 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 /// 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. /// chats), so it reads apart from the red needs-you count.
class ActivityBadge extends StatelessWidget { class ActivityBadge extends StatelessWidget {
const ActivityBadge({ const ActivityBadge({
+3
View File
@@ -357,6 +357,9 @@ enum ShellBadgeKind {
/// Runs still executing. /// Runs still executing.
running, running,
/// Runs whose server status is failed, independent of attention dismissal.
failed,
/// Chats with messages not yet seen. /// Chats with messages not yet seen.
unread, unread,
} }
+22
View File
@@ -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.
@@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/transport/pipelines_client.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 '../core/transport/pipelines_client_test.dart' show FakeChannel;
import 'pipelines_app_test.dart' show pumpApp, replyList; import 'pipelines_app_test.dart' show pumpApp, replyList;
@@ -17,77 +18,74 @@ void main() {
Finder badgeCount(String count) => Finder badgeCount(String count) =>
find.descendant(of: find.byType(Badge), matching: find.text(count)); find.descendant(of: find.byType(Badge), matching: find.text(count));
testWidgets( testWidgets('waiting is announced without being labelled as a failed run', (
'a run_event folded to waiting raises the Runs tab badge from Pipelines', tester,
(tester) async { ) async {
final semantics = tester.ensureSemantics(); final semantics = tester.ensureSemantics();
final channel = FakeChannel()..readyCompleter.complete(); final channel = FakeChannel()..readyCompleter.complete();
final client = PipelinesClient(channelFactory: (_) => channel); final client = PipelinesClient(channelFactory: (_) => channel);
final provider = PlatformRouteInformationProvider( final provider = PlatformRouteInformationProvider(
initialRouteInformation: RouteInformation(uri: Uri.parse('/runs')), initialRouteInformation: RouteInformation(uri: Uri.parse('/runs')),
); );
addTearDown(provider.dispose); addTearDown(provider.dispose);
await pumpApp( await pumpApp(tester, channel: channel, client: client, provider: provider);
tester, await replyList(
channel: channel, tester,
client: client, channel,
provider: provider, runs: [
); {
await replyList( 'id': 1,
tester, 'pipeline_id': 4,
channel, 'name': 'nightly',
runs: [ 'title': 'Nightly build',
{ 'status': 'running',
'id': 1, 'created_at': DateTime.now().toIso8601String(),
'pipeline_id': 4, },
'name': 'nightly', ],
'title': 'Nightly build', );
'status': 'running', expect(find.text('Nightly build'), findsWidgets);
'created_at': DateTime.now().toIso8601String(), expect(tester.widget<Badge>(find.byType(Badge)).isLabelVisible, isFalse);
}, expect(find.bySemanticsLabel(needingAttention), findsNothing);
],
);
expect(find.text('Nightly build'), findsWidgets);
expect(tester.widget<Badge>(find.byType(Badge)).isLabelVisible, isFalse);
expect(find.bySemanticsLabel(needingAttention), findsNothing);
await tester.tap( await tester.tap(find.byKey(const ValueKey('shell.destination.pipelines')));
find.byKey(const ValueKey('shell.destination.pipelines')), await tester.pump();
); expect(provider.value.uri.path, '/pipelines');
await tester.pump(); await waitForRequest(tester, channel, 'list_pipelines');
expect(provider.value.uri.path, '/pipelines'); // The Runs page may still be fading out, but it is no longer the
await waitForRequest(tester, channel, 'list_pipelines'); // active page: nothing on it takes a tap.
// The Runs page may still be fading out, but it is no longer the expect(find.text('Nightly build').hitTestable(), findsNothing);
// active page: nothing on it takes a tap.
expect(find.text('Nightly build').hitTestable(), findsNothing);
channel.incoming.add( channel.incoming.add(
jsonEncode({'type': 'run_event', 'run_id': 1, 'status': 'waiting'}), jsonEncode({'type': 'run_event', 'run_id': 1, 'status': 'waiting'}),
); );
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
expect(provider.value.uri.path, '/pipelines'); expect(provider.value.uri.path, '/pipelines');
expect(tester.widget<Badge>(find.byType(Badge)).isLabelVisible, isTrue); expect(tester.widget<Badge>(find.byType(Badge)).isLabelVisible, isFalse);
expect(badgeCount('1'), findsOneWidget); expect(
expect( tester
find.bySemanticsLabel(RegExp('Notifications, 1 needing attention')), .widget<RunsDestinationIcon>(find.byType(RunsDestinationIcon))
findsOneWidget, .failed,
); 0,
);
expect(
find.bySemanticsLabel(RegExp('Notifications, 1 needing attention')),
findsOneWidget,
);
// The decision taken elsewhere clears the badge the same way. // The decision taken elsewhere clears the badge the same way.
channel.incoming.add( channel.incoming.add(
jsonEncode({'type': 'run_event', 'run_id': 1, 'status': 'succeeded'}), jsonEncode({'type': 'run_event', 'run_id': 1, 'status': 'succeeded'}),
); );
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
expect(tester.widget<Badge>(find.byType(Badge)).isLabelVisible, isFalse); expect(tester.widget<Badge>(find.byType(Badge)).isLabelVisible, isFalse);
expect(badgeCount('1'), findsNothing); expect(badgeCount('1'), findsNothing);
expect(find.bySemanticsLabel(needingAttention), findsNothing); expect(find.bySemanticsLabel(needingAttention), findsNothing);
semantics.dispose(); semantics.dispose();
}, });
);
testWidgets('a new waiting run pushed before any list read is counted', ( testWidgets('a new waiting run pushed before any list read is counted', (
tester, tester,
@@ -117,6 +115,12 @@ void main() {
await tester.pump(); await tester.pump();
expect(provider.value.uri.path, '/settings'); expect(provider.value.uri.path, '/settings');
expect(badgeCount('1'), findsOneWidget); expect(badgeCount('1'), findsNothing);
expect(
tester
.widget<RunsDestinationIcon>(find.byType(RunsDestinationIcon))
.failed,
0,
);
}); });
} }
@@ -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<RunsDestinationIcon>(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);
});
}
@@ -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));
});
}
+3 -3
View File
@@ -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 /// 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. /// the bare icon with no count and no attention semantics.
void main() { void main() {
final needingAttention = RegExp('Notifications, 3 needing attention'); final needingAttention = RegExp('3 failed runs');
final anyAttention = RegExp('needing attention'); final anyAttention = RegExp('failed runs');
Future<void> pumpShell( Future<void> pumpShell(
WidgetTester tester, { WidgetTester tester, {
@@ -19,7 +19,7 @@ void main() {
tester.view.devicePixelRatio = 1; tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio); addTearDown(tester.view.resetDevicePixelRatio);
final shell = AdaptiveShell(attentionCount: count); final shell = AdaptiveShell(failedRunCount: count);
await tester.pumpWidget(MaterialApp(home: shell)); await tester.pumpWidget(MaterialApp(home: shell));
} }
+5 -4
View File
@@ -66,9 +66,10 @@ void main() {
), ),
); );
Widget shell({int attention = 0}) { Widget shell({int attention = 0, int failed = 0}) {
final app = AdaptiveShell( final app = AdaptiveShell(
attentionCount: attention, attentionCount: attention,
failedRunCount: failed,
destinationBodies: { destinationBodies: {
AppDestination.runs: (_) => ShellBadge( AppDestination.runs: (_) => ShellBadge(
kind: ShellBadgeKind.running, 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, tester,
) async { ) async {
await setSize(tester, const Size(1200, 800)); 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();
await tester.pump(); await tester.pump();
expect(find.text('2'), findsOneWidget); expect(find.text('2'), findsOneWidget);
expect(find.text('4'), findsNothing); expect(find.text('4'), findsOneWidget);
await tester.pumpWidget(shell()); await tester.pumpWidget(shell());
await tester.pump(); await tester.pump();
@@ -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<Badge>(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();
});
}
}
}