Files
pipelines/app/test/features/attention/ui/needs_you_bell_test.dart
T
alan 968e3e908a Remove Cupertino attention branches
Keep the reviewed attention surfaces on their Material implementations while preserving public cupertino parameters for remaining callers. Remove the unreachable Cupertino sheet and narrow tests to the Material path.
2026-11-11 01:31:14 +00:00

138 lines
4.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/attention/ui/needs_you_bell.dart';
import 'package:pipelines_app/features/attention/ui/needs_you_keys.dart';
import 'needs_you_test_support.dart';
void main() {
testWidgets('Material bell is plain and announced when nothing needs you', (
tester,
) async {
final semantics = tester.ensureSemantics();
await tester.pumpWidget(attentionApp(NeedsYouPage(entries: const [])));
expect(find.bySemanticsLabel('Notifications'), findsOneWidget);
expect(find.byKey(attentionBadgeKey), findsNothing);
expect(find.text('0'), findsNothing);
semantics.dispose();
});
testWidgets('Material bell announces the count and shows one badge', (
tester,
) async {
final semantics = tester.ensureSemantics();
final entries = [
attentionFixture(id: 1),
attentionFixture(id: 2, status: 'waiting', title: 'Approve release'),
attentionFixture(id: 3, diagnostic: 'Stage 2 failed'),
];
await tester.pumpWidget(attentionApp(NeedsYouPage(entries: entries)));
expect(
find.bySemanticsLabel('Notifications, 3 needing attention'),
findsOneWidget,
);
expect(find.byKey(attentionBadgeKey), findsOneWidget);
expect(find.text('3'), findsOneWidget);
semantics.dispose();
});
testWidgets('Material bell opens the honest empty sheet and back closes it', (
tester,
) async {
await tester.pumpWidget(attentionApp(NeedsYouPage(entries: const [])));
await tester.tap(find.byKey(attentionBellKey));
await tester.pumpAndSettle();
expect(find.byKey(attentionSheetKey), findsOneWidget);
expect(find.text('Needs you'), findsOneWidget);
expect(find.text('Nothing needs you right now.'), findsOneWidget);
expect(find.byKey(attentionEmptyKey), findsOneWidget);
expect(find.byKey(attentionClearAllKey), findsNothing);
expect(find.text('Dismiss'), findsNothing);
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
expect(find.byKey(attentionSheetKey), findsNothing);
});
testWidgets('Material sheet is a named heading and Escape closes it', (
tester,
) async {
final semantics = tester.ensureSemantics();
await tester.pumpWidget(attentionApp(NeedsYouPage(entries: const [])));
await tester.tap(find.byKey(attentionBellKey));
await tester.pumpAndSettle();
final title = tester.getSemantics(find.text('Needs you'));
expect(
title.getSemanticsData().flagsCollection.isHeader,
isTrue,
reason: 'the sheet title must reach assistive tech as a heading',
);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
expect(find.byKey(attentionSheetKey), findsNothing);
semantics.dispose();
});
testWidgets('Material sheet closes on a barrier tap', (tester) async {
await tester.pumpWidget(attentionApp(NeedsYouPage(entries: const [])));
await tester.tap(find.byKey(attentionBellKey));
await tester.pumpAndSettle();
expect(find.byKey(attentionSheetKey), findsOneWidget);
// Above the sheet body: only the native modal barrier is there.
await tester.tapAt(const Offset(20, 20));
await tester.pumpAndSettle();
expect(find.byKey(attentionSheetKey), findsNothing);
});
testWidgets('Material closing the sheet returns focus to the bell', (
tester,
) async {
await tester.pumpWidget(attentionApp(NeedsYouPage(entries: const [])));
await tester.tap(find.byKey(attentionBellKey));
await tester.pumpAndSettle();
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
expect(find.byKey(attentionSheetKey), findsNothing);
expect(bellHasFocus(tester), isTrue);
});
testWidgets('a stale cupertino flag still draws the Material bell and sheet', (
tester,
) async {
await tester.pumpWidget(
attentionApp(
Scaffold(
body: Center(
child: NeedsYouBell(
entries: [attentionFixture()],
cupertino: true,
onOpen: (_) {},
onDismiss: (_) {},
onClearAll: (_) {},
),
),
),
),
);
expect(tester.widget(find.byKey(attentionBellKey)), isA<IconButton>());
expect(find.byIcon(Icons.notifications_outlined), findsOneWidget);
await tester.tap(find.byKey(attentionBellKey));
await tester.pumpAndSettle();
expect(find.byType(BottomSheet), findsOneWidget);
expect(find.byKey(attentionSheetKey), findsOneWidget);
});
}