feat(app): deliver live attention notifications and show permission in Settings
This commit is contained in:
@@ -8,6 +8,8 @@ import '../core/api_gateway.dart';
|
|||||||
import '../core/transport/pipelines_client.dart';
|
import '../core/transport/pipelines_client.dart';
|
||||||
import '../shell/adaptive_shell.dart';
|
import '../shell/adaptive_shell.dart';
|
||||||
import '../shell/destination.dart';
|
import '../shell/destination.dart';
|
||||||
|
import '../features/attention/notify/notification_controller.dart';
|
||||||
|
import '../features/attention/notify/notification_store.dart';
|
||||||
import '../features/settings/settings_screen.dart';
|
import '../features/settings/settings_screen.dart';
|
||||||
import 'app.dart';
|
import 'app.dart';
|
||||||
import 'app_route.dart';
|
import 'app_route.dart';
|
||||||
@@ -61,6 +63,12 @@ class _PipelinesAppState extends State<PipelinesApp> {
|
|||||||
/// list once; the run itself is then opened from its route.
|
/// list once; the run itself is then opened from its route.
|
||||||
int _runsRefresh = 0;
|
int _runsRefresh = 0;
|
||||||
|
|
||||||
|
/// One notification capability for the app: the Runs attention surface
|
||||||
|
/// publishes live transitions and Settings renders the same permission.
|
||||||
|
late final NotificationController _notifications = NotificationController(
|
||||||
|
store: const SharedPreferencesNotificationStore(),
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -81,6 +89,8 @@ class _PipelinesAppState extends State<PipelinesApp> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
_cupertino = widget.cupertino ?? _platformIsCupertino;
|
_cupertino = widget.cupertino ?? _platformIsCupertino;
|
||||||
|
_notifications.onOpenRun = (id) => _delegate.goTo(AppRoute.run(id));
|
||||||
|
unawaited(_notifications.load());
|
||||||
_delegate = AppRouterDelegate(
|
_delegate = AppRouterDelegate(
|
||||||
initial: initial,
|
initial: initial,
|
||||||
cupertino: _cupertino,
|
cupertino: _cupertino,
|
||||||
@@ -100,6 +110,7 @@ class _PipelinesAppState extends State<PipelinesApp> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
_notifications.dispose();
|
||||||
_delegate.dispose();
|
_delegate.dispose();
|
||||||
if (_ownsProvider) {
|
if (_ownsProvider) {
|
||||||
(_provider as PlatformRouteInformationProvider).dispose();
|
(_provider as PlatformRouteInformationProvider).dispose();
|
||||||
@@ -178,6 +189,7 @@ class _PipelinesAppState extends State<PipelinesApp> {
|
|||||||
server: widget.server,
|
server: widget.server,
|
||||||
initialRunId: route.runId,
|
initialRunId: route.runId,
|
||||||
listRefreshToken: _runsRefresh,
|
listRefreshToken: _runsRefresh,
|
||||||
|
notifications: _notifications,
|
||||||
onRunSelected: (id) => _delegate.goTo(AppRoute.run(id)),
|
onRunSelected: (id) => _delegate.goTo(AppRoute.run(id)),
|
||||||
onBack: () => _delegate.goTo(AppRoute.runs),
|
onBack: () => _delegate.goTo(AppRoute.runs),
|
||||||
),
|
),
|
||||||
@@ -193,6 +205,7 @@ class _PipelinesAppState extends State<PipelinesApp> {
|
|||||||
initialEndpoint: _session.endpoint,
|
initialEndpoint: _session.endpoint,
|
||||||
embedded: true,
|
embedded: true,
|
||||||
onOpenTemplates: _delegate.openTemplates,
|
onOpenTemplates: _delegate.openTemplates,
|
||||||
|
notifications: _notifications,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../features/attention/notify/notification_controller.dart';
|
||||||
import '../features/runs/screen.dart';
|
import '../features/runs/screen.dart';
|
||||||
import '../ui/adaptive/host.dart';
|
import '../ui/adaptive/host.dart';
|
||||||
import 'app_session.dart';
|
import 'app_session.dart';
|
||||||
@@ -21,6 +22,7 @@ class RunsDestination extends StatelessWidget {
|
|||||||
this.onRunSelected,
|
this.onRunSelected,
|
||||||
this.onBack,
|
this.onBack,
|
||||||
this.listRefreshToken = 0,
|
this.listRefreshToken = 0,
|
||||||
|
this.notifications,
|
||||||
});
|
});
|
||||||
|
|
||||||
final AppSession session;
|
final AppSession session;
|
||||||
@@ -33,6 +35,9 @@ class RunsDestination extends StatelessWidget {
|
|||||||
/// re-reads its list once; no row is inserted locally.
|
/// re-reads its list once; no row is inserted locally.
|
||||||
final int listRefreshToken;
|
final int listRefreshToken;
|
||||||
|
|
||||||
|
/// The app-level notification capability shared with Settings.
|
||||||
|
final NotificationController? notifications;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => AnimatedBuilder(
|
Widget build(BuildContext context) => AnimatedBuilder(
|
||||||
animation: session,
|
animation: session,
|
||||||
@@ -70,6 +75,7 @@ class RunsDestination extends StatelessWidget {
|
|||||||
initialRunId: initialRunId,
|
initialRunId: initialRunId,
|
||||||
syncToken: session.connectionEpoch,
|
syncToken: session.connectionEpoch,
|
||||||
listRefreshToken: listRefreshToken,
|
listRefreshToken: listRefreshToken,
|
||||||
|
notifications: notifications,
|
||||||
onRunSelected: onRunSelected,
|
onRunSelected: onRunSelected,
|
||||||
onBack: onBack,
|
onBack: onBack,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import 'package:flutter/widgets.dart';
|
|||||||
|
|
||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
import '../domain/attention_models.dart';
|
import '../domain/attention_models.dart';
|
||||||
|
import '../notify/notification_controller.dart';
|
||||||
|
import '../notify/notification_ledger.dart';
|
||||||
import '../runtime/attention_controller.dart';
|
import '../runtime/attention_controller.dart';
|
||||||
import '../runtime/attention_store.dart';
|
import '../runtime/attention_store.dart';
|
||||||
import 'needs_you_bell.dart';
|
import 'needs_you_bell.dart';
|
||||||
@@ -25,6 +27,7 @@ class NeedsYouRunsHeading extends StatefulWidget {
|
|||||||
this.store = const SharedPreferencesAttentionStore(),
|
this.store = const SharedPreferencesAttentionStore(),
|
||||||
this.now,
|
this.now,
|
||||||
this.cupertino,
|
this.cupertino,
|
||||||
|
this.notifications,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// The run summaries the Runs destination already holds.
|
/// The run summaries the Runs destination already holds.
|
||||||
@@ -48,6 +51,10 @@ class NeedsYouRunsHeading extends StatefulWidget {
|
|||||||
/// Forces the native host in tests and fixtures.
|
/// Forces the native host in tests and fixtures.
|
||||||
final bool? cupertino;
|
final bool? cupertino;
|
||||||
|
|
||||||
|
/// The app-level notification capability. Absent in fixtures that only draw
|
||||||
|
/// the bell, so no store or platform bridge is touched there.
|
||||||
|
final NotificationController? notifications;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<NeedsYouRunsHeading> createState() => _NeedsYouRunsHeadingState();
|
State<NeedsYouRunsHeading> createState() => _NeedsYouRunsHeadingState();
|
||||||
}
|
}
|
||||||
@@ -65,12 +72,44 @@ class _NeedsYouRunsHeadingState extends State<NeedsYouRunsHeading> {
|
|||||||
_attention.seedRows(widget.rows);
|
_attention.seedRows(widget.rows);
|
||||||
unawaited(_attention.load());
|
unawaited(_attention.load());
|
||||||
_listen();
|
_listen();
|
||||||
|
final notifications = widget.notifications;
|
||||||
|
if (notifications != null) {
|
||||||
|
notifications.onOpenRun = _openRunById;
|
||||||
|
unawaited(notifications.load().then((_) => _publish()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A notification names only the run id; opening it follows the same route
|
||||||
|
/// rule as a bell row. Dismissal is not implied by a notice tap.
|
||||||
|
void _openRunById(int id) {
|
||||||
|
for (final entry in _attention.entries) {
|
||||||
|
if (entry.runId == id) {
|
||||||
|
widget.onOpen(entry);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Publishes the transitions the model accumulated against the rows and the
|
||||||
|
/// dismissals that are in force right now. Idempotent, so the whole list is
|
||||||
|
/// safe to pass after every read or pushed frame.
|
||||||
|
void _publish() {
|
||||||
|
final notifications = widget.notifications;
|
||||||
|
if (notifications == null) return;
|
||||||
|
notifications.publishTransitions(
|
||||||
|
_attention.transitions,
|
||||||
|
qualifying: notificationQualifyingKeys(_attention.rows),
|
||||||
|
dismissed: _attention.dismissed,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _listen() {
|
void _listen() {
|
||||||
_frames = widget.frames
|
_frames = widget.frames
|
||||||
.where((frame) => frame['type'] == 'run_event')
|
.where((frame) => frame['type'] == 'run_event')
|
||||||
.listen(_attention.observeFrame);
|
.listen((frame) {
|
||||||
|
_attention.observeFrame(frame);
|
||||||
|
_publish();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -84,10 +123,12 @@ class _NeedsYouRunsHeadingState extends State<NeedsYouRunsHeading> {
|
|||||||
if (oldWidget.syncToken != widget.syncToken) {
|
if (oldWidget.syncToken != widget.syncToken) {
|
||||||
_attention.resetForReconnect();
|
_attention.resetForReconnect();
|
||||||
_attention.seedRows(widget.rows, reconnect: true);
|
_attention.seedRows(widget.rows, reconnect: true);
|
||||||
|
_publish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!identical(oldWidget.rows, widget.rows)) {
|
if (!identical(oldWidget.rows, widget.rows)) {
|
||||||
_attention.seedRows(widget.rows);
|
_attention.seedRows(widget.rows);
|
||||||
|
_publish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
import '../../core/api_gateway.dart';
|
import '../../core/api_gateway.dart';
|
||||||
|
import '../attention/notify/notification_controller.dart';
|
||||||
import '../attention/runtime/attention_store.dart';
|
import '../attention/runtime/attention_store.dart';
|
||||||
import 'data/runs_repository.dart';
|
import 'data/runs_repository.dart';
|
||||||
import 'ui/run_detail_view.dart';
|
import 'ui/run_detail_view.dart';
|
||||||
@@ -24,6 +25,7 @@ class RunsScreen extends StatefulWidget {
|
|||||||
this.onBack,
|
this.onBack,
|
||||||
this.attentionStore = const SharedPreferencesAttentionStore(),
|
this.attentionStore = const SharedPreferencesAttentionStore(),
|
||||||
this.attentionNow,
|
this.attentionNow,
|
||||||
|
this.notifications,
|
||||||
});
|
});
|
||||||
|
|
||||||
final ApiGateway gateway;
|
final ApiGateway gateway;
|
||||||
@@ -47,6 +49,9 @@ class RunsScreen extends StatefulWidget {
|
|||||||
final AttentionStore attentionStore;
|
final AttentionStore attentionStore;
|
||||||
final DateTime Function()? attentionNow;
|
final DateTime Function()? attentionNow;
|
||||||
|
|
||||||
|
/// App-level notification delivery for live attention transitions.
|
||||||
|
final NotificationController? notifications;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<RunsScreen> createState() => _RunsScreenState();
|
State<RunsScreen> createState() => _RunsScreenState();
|
||||||
}
|
}
|
||||||
@@ -128,6 +133,7 @@ class _RunsScreenState extends State<RunsScreen> {
|
|||||||
syncToken: widget.syncToken,
|
syncToken: widget.syncToken,
|
||||||
attentionStore: widget.attentionStore,
|
attentionStore: widget.attentionStore,
|
||||||
attentionNow: widget.attentionNow,
|
attentionNow: widget.attentionNow,
|
||||||
|
notifications: widget.notifications,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
import '../../../ui/adaptive/host.dart';
|
import '../../../ui/adaptive/host.dart';
|
||||||
|
import '../../attention/notify/notification_controller.dart';
|
||||||
import '../../attention/runtime/attention_store.dart';
|
import '../../attention/runtime/attention_store.dart';
|
||||||
import '../../attention/ui/needs_you_runs_heading.dart';
|
import '../../attention/ui/needs_you_runs_heading.dart';
|
||||||
import '../domain/run_models.dart';
|
import '../domain/run_models.dart';
|
||||||
@@ -17,6 +18,7 @@ class RunsList extends StatelessWidget {
|
|||||||
this.syncToken = 0,
|
this.syncToken = 0,
|
||||||
this.attentionStore = const SharedPreferencesAttentionStore(),
|
this.attentionStore = const SharedPreferencesAttentionStore(),
|
||||||
this.attentionNow,
|
this.attentionNow,
|
||||||
|
this.notifications,
|
||||||
});
|
});
|
||||||
|
|
||||||
final RunsController controller;
|
final RunsController controller;
|
||||||
@@ -32,6 +34,9 @@ class RunsList extends StatelessWidget {
|
|||||||
/// Deterministic local-day clock for the attention window.
|
/// Deterministic local-day clock for the attention window.
|
||||||
final DateTime Function()? attentionNow;
|
final DateTime Function()? attentionNow;
|
||||||
|
|
||||||
|
/// App-level notification delivery; absent in list-only fixtures.
|
||||||
|
final NotificationController? notifications;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (controller.loading && controller.runs.isEmpty) {
|
if (controller.loading && controller.runs.isEmpty) {
|
||||||
@@ -58,6 +63,7 @@ class RunsList extends StatelessWidget {
|
|||||||
syncToken: syncToken,
|
syncToken: syncToken,
|
||||||
store: attentionStore,
|
store: attentionStore,
|
||||||
now: attentionNow,
|
now: attentionNow,
|
||||||
|
notifications: notifications,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
import '../attention/notify/notification_controller.dart';
|
||||||
|
import '../attention/ui/notification_permission_tile.dart';
|
||||||
|
|
||||||
|
/// The Settings entry for the browser notification permission.
|
||||||
|
///
|
||||||
|
/// It reads the platform's own state from the app-level
|
||||||
|
/// [NotificationController] and asks only when the operator presses the tile's
|
||||||
|
/// Enable action. The controller is shared with the Runs attention surface, so
|
||||||
|
/// the permission shown here is the one that gates the live notices.
|
||||||
|
class SettingsNotificationsSection extends StatelessWidget {
|
||||||
|
const SettingsNotificationsSection({
|
||||||
|
super.key,
|
||||||
|
required this.controller,
|
||||||
|
});
|
||||||
|
|
||||||
|
final NotificationController controller;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => AnimatedBuilder(
|
||||||
|
animation: controller,
|
||||||
|
builder: (context, _) => NotificationPermissionTile(
|
||||||
|
state: controller.permission,
|
||||||
|
asked: controller.asked,
|
||||||
|
onRequest: () {
|
||||||
|
// The platform answer updates the controller; the AnimationBuilder above
|
||||||
|
// redraws the tile with its own words.
|
||||||
|
controller.requestPermission();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -4,10 +4,12 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../core/transport/pipelines_client.dart' as transport;
|
import '../../core/transport/pipelines_client.dart' as transport;
|
||||||
|
import '../attention/notify/notification_controller.dart';
|
||||||
import 'default_endpoint.dart';
|
import 'default_endpoint.dart';
|
||||||
import 'settings_controller.dart';
|
import 'settings_controller.dart';
|
||||||
import 'settings_controls.dart';
|
import 'settings_controls.dart';
|
||||||
import 'settings_layout.dart';
|
import 'settings_layout.dart';
|
||||||
|
import 'settings_notifications_section.dart';
|
||||||
import 'settings_sections.dart';
|
import 'settings_sections.dart';
|
||||||
import 'settings_store.dart';
|
import 'settings_store.dart';
|
||||||
import 'settings_templates_section.dart';
|
import 'settings_templates_section.dart';
|
||||||
@@ -29,6 +31,7 @@ class SettingsScreen extends StatefulWidget {
|
|||||||
this.ping,
|
this.ping,
|
||||||
this.embedded = false,
|
this.embedded = false,
|
||||||
this.onOpenTemplates,
|
this.onOpenTemplates,
|
||||||
|
this.notifications,
|
||||||
});
|
});
|
||||||
|
|
||||||
final transport.PipelinesClient client;
|
final transport.PipelinesClient client;
|
||||||
@@ -50,6 +53,9 @@ class SettingsScreen extends StatefulWidget {
|
|||||||
/// without a dead row that would go nowhere.
|
/// without a dead row that would go nowhere.
|
||||||
final VoidCallback? onOpenTemplates;
|
final VoidCallback? onOpenTemplates;
|
||||||
|
|
||||||
|
/// The app-level notification capability; absent in connection-only fixtures.
|
||||||
|
final NotificationController? notifications;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<SettingsScreen> createState() => _SettingsScreenState();
|
State<SettingsScreen> createState() => _SettingsScreenState();
|
||||||
}
|
}
|
||||||
@@ -127,6 +133,14 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||||||
controller: _controller,
|
controller: _controller,
|
||||||
workspaceField: _workspaceField,
|
workspaceField: _workspaceField,
|
||||||
),
|
),
|
||||||
|
if (widget.notifications != null) ...<Widget>[
|
||||||
|
const SizedBox(height: settingsSectionGap),
|
||||||
|
const _SectionTitle('Notifications'),
|
||||||
|
const SizedBox(height: settingsTitleGap),
|
||||||
|
SettingsNotificationsSection(
|
||||||
|
controller: widget.notifications!,
|
||||||
|
),
|
||||||
|
],
|
||||||
if (widget.onOpenTemplates != null) ...<Widget>[
|
if (widget.onOpenTemplates != null) ...<Widget>[
|
||||||
const SizedBox(height: settingsSectionGap),
|
const SizedBox(height: settingsSectionGap),
|
||||||
const _SectionTitle('Templates'),
|
const _SectionTitle('Templates'),
|
||||||
|
|||||||
@@ -0,0 +1,96 @@
|
|||||||
|
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_store.dart';
|
||||||
|
import 'package:pipelines_app/features/attention/ui/needs_you_runs_heading.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,
|
||||||
|
cupertino: false,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
// 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();
|
||||||
|
expect(find.text('Notifications'), findsWidgets);
|
||||||
|
|
||||||
|
// 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.text('Notifications'), findsWidgets);
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user