Files
pipelines/app/test/features/attention/runtime/attention_runs_wiring_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

186 lines
5.9 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/attention/domain/attention_models.dart';
import 'package:pipelines_app/features/attention/runtime/attention_store.dart';
import 'package:pipelines_app/features/attention/ui/needs_you_keys.dart';
import 'attention_runs_test_support.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
late AttentionRunsGateway gateway;
setUp(() => gateway = AttentionRunsGateway());
tearDown(() => gateway.framesController.close());
testWidgets('Material Runs list bell opens the sheet and dismisses one', (
tester,
) async {
final semantics = tester.ensureSemantics();
final store = MemoryAttentionStore();
await mountAttentionRuns(
tester,
gateway,
store: store,
runs: [
attentionRun(1, 'waiting', title: 'Approve the release'),
attentionRun(
2,
'failed',
title: 'Ship the release',
diagnostic: 'Stage 2',
),
attentionRun(3, 'waiting', title: 'Machine export')
..['export_pending_sequence'] = 2,
attentionRun(4, 'running', title: 'Still running'),
],
);
expect(
find.bySemanticsLabel('Notifications, 2 needing attention'),
findsOneWidget,
);
await openAttentionSheet(tester);
expect(find.byKey(attentionSheetKey), findsOneWidget);
expect(find.byKey(attentionRowKey('3:Decision')), findsNothing);
expect(find.byKey(attentionRowKey('4:Failed')), findsNothing);
expect(find.byKey(attentionRowKey('2:Failed')), findsOneWidget);
await tester.tap(find.byKey(attentionDismissKey('2:Failed')));
await tester.pumpAndSettle();
expect(find.byKey(attentionSheetKey), findsOneWidget);
expect(find.byKey(attentionRowKey('2:Failed')), findsNothing);
expect(store.stored, encodeAttentionDismissals({'2:Failed'}));
// Closing and rebuilding from the same store keeps the dismissal.
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
await tester.pumpWidget(const SizedBox());
await mountAttentionRuns(
tester,
gateway,
store: store,
runs: [
attentionRun(1, 'waiting', title: 'Approve the release'),
attentionRun(
2,
'failed',
title: 'Ship the release',
diagnostic: 'Stage 2',
),
],
request: 1,
key: const ValueKey('rebuilt'),
);
expect(
find.bySemanticsLabel('Notifications, 1 needing attention'),
findsOneWidget,
);
semantics.dispose();
});
testWidgets('Material rows follow the browser open/dismiss rules', (
tester,
) async {
final store = MemoryAttentionStore();
await mountAttentionRuns(
tester,
gateway,
store: store,
runs: [
attentionRun(1, 'waiting', title: 'Approve the release'),
attentionRun(2, 'failed', title: 'Ship the release'),
],
);
await openAttentionSheet(tester);
await tester.tap(find.byKey(attentionRowKey('1:Decision')));
await tester.pump();
await tester.pump(const Duration(milliseconds: 400));
expect(gateway.detailRequests[1], hasLength(1));
expect(
store.stored,
isNull,
reason: 'a Decision opens without dismissing',
);
gateway.replyDetail(1, {'id': 1, 'title': 'Approve the release'});
await tester.pump();
await tester.pumpAndSettle();
// The wide list and its bell stay available beside the open detail.
expect(find.byKey(const ValueKey('run-row-2')), findsOneWidget);
await openAttentionSheet(tester);
await tester.tap(find.byKey(attentionRowKey('2:Failed')));
await tester.pump();
await tester.pump(const Duration(milliseconds: 400));
expect(gateway.detailRequests[2], hasLength(1));
expect(store.stored, encodeAttentionDismissals({'2:Failed'}));
gateway.replyDetail(2, {'id': 2, 'title': 'Ship the release'});
await tester.pump();
});
testWidgets('Material live frame and Clear-all snapshot reach the bell', (
tester,
) async {
final semantics = tester.ensureSemantics();
final store = MemoryAttentionStore();
await mountAttentionRuns(
tester,
gateway,
store: store,
runs: [attentionRun(1, 'failed', title: 'First failure')],
);
expect(
find.bySemanticsLabel('Notifications, 1 needing attention'),
findsOneWidget,
);
await openAttentionSheet(tester);
gateway.framesController.add({
'type': 'run_event',
'run_id': 9,
'pipeline_id': 4,
'name': 'nightly',
'title': 'Arrived while open',
'status': 'waiting',
'created_at': attentionTestNow
.subtract(const Duration(minutes: 5))
.toIso8601String(),
});
await tester.pump();
await tester.pumpAndSettle();
expect(find.byKey(attentionRowKey('9:Decision')), findsOneWidget);
await tester.tap(find.byKey(attentionClearAllKey));
await tester.pumpAndSettle();
expect(find.byKey(attentionRowKey('1:Failed')), findsNothing);
expect(
find.byKey(attentionRowKey('9:Decision')),
findsOneWidget,
reason: 'Clear all acts on the snapshot it opened with',
);
expect(store.stored, encodeAttentionDismissals({'1:Failed'}));
semantics.dispose();
});
testWidgets('Material empty runs hide the badge but keep the bell', (
tester,
) async {
final semantics = tester.ensureSemantics();
await mountAttentionRuns(
tester,
gateway,
store: MemoryAttentionStore(),
runs: const [],
);
expect(find.byKey(attentionBellKey), findsOneWidget);
expect(find.byKey(attentionBadgeKey), findsNothing);
expect(find.bySemanticsLabel('Notifications'), findsOneWidget);
await openAttentionSheet(tester);
expect(find.text('Nothing needs you right now.'), findsOneWidget);
expect(find.byKey(attentionClearAllKey), findsNothing);
semantics.dispose();
});
}