Files
pipelines/app/test/shell/attention_badge_test.dart
T
alan efca56e4e4 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.
2026-11-11 22:10:37 +00:00

76 lines
2.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
/// The Runs tab mirrors the attention count in every mount: the floating tab
/// 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('3 failed runs');
final anyAttention = RegExp('failed runs');
Future<void> pumpShell(
WidgetTester tester, {
required double width,
required int count,
}) async {
tester.view.physicalSize = Size(width, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final shell = AdaptiveShell(failedRunCount: count);
await tester.pumpWidget(MaterialApp(home: shell));
}
for (final width in [390.0, 1000.0]) {
final mount = width < 600 ? 'bottom bar' : 'wide bar';
testWidgets('$mount shows the count on the Runs tab', (tester) async {
final semantics = tester.ensureSemantics();
await pumpShell(tester, width: width, count: 3);
expect(find.byType(FloatingDestinationBar), findsOneWidget);
expect(find.byType(NavigationRail), findsNothing);
final badge = find.byType(Badge);
expect(badge, findsOneWidget);
expect(tester.widget<Badge>(badge).isLabelVisible, isTrue);
expect(
find.descendant(of: badge, matching: find.text('3')),
findsOneWidget,
);
expect(find.bySemanticsLabel(needingAttention), findsOneWidget);
semantics.dispose();
});
testWidgets('$mount hides the badge at zero', (tester) async {
final semantics = tester.ensureSemantics();
await pumpShell(tester, width: width, count: 0);
final badge = find.byType(Badge);
expect(badge, findsOneWidget);
expect(tester.widget<Badge>(badge).isLabelVisible, isFalse);
expect(
find.descendant(
of: badge,
matching: find.textContaining(RegExp(r'\d')),
),
findsNothing,
);
expect(find.bySemanticsLabel(anyAttention), findsNothing);
semantics.dispose();
});
}
testWidgets('the badge stays visible from every destination', (tester) async {
await pumpShell(tester, width: 1000, count: 2);
for (final name in ['runs', 'chat', 'search']) {
await tester.tap(find.byKey(ValueKey('shell.destination.$name')));
await tester.pumpAndSettle();
expect(
find.descendant(of: find.byType(Badge), matching: find.text('2')),
findsOneWidget,
reason: 'badge missing on $name',
);
}
});
}