Report delivered device count from the test-notification endpoint

POST /api/notifications/test previously returned a blanket 200 even when there
were no registered devices, so a test that reached nobody looked like a success.
push::send now returns the number of devices the relay confirmed delivery to, and
the endpoint returns it as {"delivered": N}. Settings shows "sent to N device(s)"
on success and an explicit "No devices are registered..." warning when N is 0,
which is the case that previously masqueraded as success.

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

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
rzuasti
2026-06-09 14:06:56 -04:00
co-authored by Claude Opus 4.8
parent 0075072196
commit 475edcb2cf
8 changed files with 82 additions and 33 deletions
@@ -36,13 +36,13 @@ void main() {
await BackendAPI.instance.markAllNotificationsAsRead();
});
test('sendTestNotification POSTs to /notifications/test', () async {
test('sendTestNotification POSTs and returns the delivered count', () async {
adapter.onPost(
'/notifications/test',
(server) => server.reply(200, null),
(server) => server.reply(200, {'delivered': 2}),
);
await BackendAPI.instance.sendTestNotification();
expect(await BackendAPI.instance.sendTestNotification(), 2);
});
test(