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.
97 lines
3.5 KiB
Dart
97 lines
3.5 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/core/api_gateway.dart';
|
|
import 'package:pipelines_app/features/attention/notify/notification_controller.dart';
|
|
import 'package:pipelines_app/features/attention/notify/notification_models.dart';
|
|
import 'package:pipelines_app/features/attention/notify/notification_store.dart';
|
|
import 'package:pipelines_app/features/attention/ui/needs_you_runs_heading.dart';
|
|
import 'package:pipelines_app/features/attention/ui/notification_permission_tile.dart';
|
|
import 'package:pipelines_app/features/settings/settings_notifications_section.dart';
|
|
|
|
import 'notification_test_support.dart';
|
|
|
|
/// The manager-owned wiring: the bell surface publishes live transitions and
|
|
/// Settings renders the same controller's permission.
|
|
void main() {
|
|
testWidgets('a seed never notifies and one live transition notifies once', (
|
|
tester,
|
|
) async {
|
|
final bridge = FakeNotificationBridge(permission: 'granted');
|
|
final notify = NotificationController(
|
|
store: MemoryNotificationStore(),
|
|
bridge: bridge,
|
|
);
|
|
final frames = StreamController<JsonMap>.broadcast();
|
|
addTearDown(frames.close);
|
|
addTearDown(notify.dispose);
|
|
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: NeedsYouRunsHeading(
|
|
rows: <JsonMap>[runSummary(1, 'failed'), runSummary(2, 'running')],
|
|
frames: frames.stream,
|
|
onOpen: (_) {},
|
|
now: () => attentionNow,
|
|
notifications: notify,
|
|
),
|
|
),
|
|
);
|
|
// Let the persisted ledger read and the seed publish settle. A plain
|
|
// `Future.delayed` would deadlock inside the widget test's fake clock.
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 20));
|
|
expect(bridge.shown, isEmpty, reason: 'the initial list is a seed');
|
|
expect(notify.permission.name, 'granted');
|
|
|
|
frames.add(runFrame(2, 'failed'));
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 20));
|
|
expect(bridge.shown, hasLength(1));
|
|
expect(bridge.shown.single.runId, 2);
|
|
|
|
// The same transition instance again (a reconnect reseed of that frame)
|
|
// must not announce twice.
|
|
frames.add(runFrame(2, 'failed'));
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 20));
|
|
expect(bridge.shown, hasLength(1));
|
|
});
|
|
|
|
testWidgets('Settings renders the platform permission from the controller', (
|
|
tester,
|
|
) async {
|
|
final notify = NotificationController(
|
|
store: MemoryNotificationStore(),
|
|
bridge: FakeNotificationBridge(permission: 'granted'),
|
|
);
|
|
addTearDown(notify.dispose);
|
|
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: Scaffold(body: SettingsNotificationsSection(controller: notify)),
|
|
),
|
|
);
|
|
await tester.pump();
|
|
// One compact row: the short state, not the long rationale paragraph.
|
|
expect(find.byKey(notificationStateKey), findsOneWidget);
|
|
expect(find.text(notificationRationale), findsNothing);
|
|
|
|
// A denied platform answer shows its own words and no Enable action.
|
|
final denied = NotificationController(
|
|
store: MemoryNotificationStore(),
|
|
bridge: FakeNotificationBridge(permission: 'denied'),
|
|
);
|
|
addTearDown(denied.dispose);
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: Scaffold(body: SettingsNotificationsSection(controller: denied)),
|
|
),
|
|
);
|
|
await tester.pump();
|
|
expect(find.byKey(notificationStateKey), findsOneWidget);
|
|
expect(find.text(notificationRationale), findsNothing);
|
|
});
|
|
}
|