ba198d144a
Keep the audited runs filter, chat colour picker, and Needs you flows as Material bottom sheets on narrow or touch layouts while presenting bounded desktop dialogs on wide layouts. Remove obsolete Cupertino flags and add focused route regressions and notes.
108 lines
3.6 KiB
Dart
108 lines
3.6 KiB
Dart
import 'package:flutter/services.dart';
|
|
import 'package:flutter_test/flutter_test.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);
|
|
});
|
|
}
|