Add a "Send test notification" button to verify push delivery

Adds POST /api/notifications/test, which delivers a canned test push to every
registered device through the existing relay path (not persisted to the
notifications list), wired into the router and OpenAPI. In Settings, a "Send test
notification" button appears under the push toggle, only when push is enabled on
this device, so the full backend -> relay -> FCM -> APNs -> device path can be
verified on demand without waiting for a real device event.

Backend, API and widget tests added; clippy and dart analyze clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
rzuasti
2026-06-09 12:42:20 -04:00
co-authored by Claude Opus 4.8
parent c7c5b45ae8
commit 817ec5872c
7 changed files with 147 additions and 1 deletions
@@ -161,4 +161,32 @@ void main() {
expect(service.disableCalls, 1);
expect(PrefUtil.getValue('push_enabled', false), isFalse);
});
testWidgets('hides the test button when push is off on this device', (
tester,
) async {
stubNotificationMethod('push');
await PrefUtil.setValue('push_enabled', false);
await pumpScreen(tester, Settings(pushService: _FakePushService()));
await pumpUntilFound(tester, find.byType(SwitchListTile));
expect(find.text('Send test notification'), findsNothing);
});
testWidgets('sends a test notification when push is on', (tester) async {
stubNotificationMethod('push');
adapter.onPost(
'/notifications/test',
(server) => server.reply(200, null),
);
await PrefUtil.setValue('push_enabled', true);
await pumpScreen(tester, Settings(pushService: _FakePushService()));
await pumpUntilFound(tester, find.text('Send test notification'));
await tester.tap(find.text('Send test notification'));
await pumpUntilFound(
tester,
find.text('Test notification sent. It should arrive shortly.'),
);
});
}