Aggiunge copertura test e documentazione per Notifiche attive in admin

Estrae la deduplica degli id giocatore in idsConNotificheAttive
(src/lib/notifiche-attive.server.ts), testata a livello unit. Aggiunge
un test di integrazione sui permessi della route (401/403/200), sullo
stesso schema di permessi-route.test.ts. Documenta il nuovo endpoint
in notifiche.md e la dashboard admin a tab in profilo-giocatore.md.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-10 14:32:11 +02:00
co-authored by Claude Sonnet 5
parent d8fc6ef04f
commit 457a0fe23d
6 changed files with 154 additions and 8 deletions
+4
View File
@@ -0,0 +1,4 @@
/** Id giocatore distinti tra le righe di `push_subscriptions` (una riga per dispositivo). */
export function idsConNotificheAttive(righe: Array<{ giocatore_id: string }>): string[] {
return [...new Set(righe.map((r) => r.giocatore_id))];
}
+2 -2
View File
@@ -1,5 +1,6 @@
import { createFileRoute } from "@tanstack/react-router";
import { richiediAdmin } from "@/lib/auth-route.server";
import { idsConNotificheAttive } from "@/lib/notifiche-attive.server";
export const Route = createFileRoute("/api/public/notifiche-attive")({
server: {
@@ -17,8 +18,7 @@ export const Route = createFileRoute("/api/public/notifiche-attive")({
return new Response("Errore lettura", { status: 500 });
}
const giocatoreIds = [...new Set((data ?? []).map((r) => r.giocatore_id))];
return Response.json({ giocatoreIds });
return Response.json({ giocatoreIds: idsConNotificheAttive(data ?? []) });
},
},
},