Secure Sakani portal and show full album titles

This commit is contained in:
Leon Tonhäuser committed 2026-11-30 19:14:57 +01:00
1 parent c40ccf77cf
commit 69264ce165
49 files changed
+1362 -601

No files matched your search

+20
View File
@@ -12,6 +12,7 @@ vi.mock("next/navigation", () => ({
vi.mock("next-themes", () => ({ useTheme: () => ({ resolvedTheme: "light", setTheme: vi.fn() }) }));
vi.mock("@/modules/auth/client", () => ({ authClient: { signOut: vi.fn() } }));
import { authClient } from "@/modules/auth/client";
import { AppShell } from "./app-shell";
import { RELEASE } from "./release-notes";
@@ -74,3 +75,22 @@ test("release notes pop up once per version and reopen from the sidebar", async
fireEvent.click(screen.getByRole("button", { name: new RegExp(`Was ist neu · v${RELEASE.version}`) }));
expect(await screen.findByRole("dialog", { name: "Was ist neu?" })).toBeTruthy();
});
test.each(["rejected", "error response"])("failed sign-out (%s) stays on the page and can be retried", async (kind) => {
const signOut = vi.mocked(authClient.signOut);
const error = { error: { status: 503, statusText: "Unavailable" }, data: null };
signOut.mockReset();
if (kind === "rejected") signOut.mockRejectedValueOnce(new Error("network failure"));
else signOut.mockResolvedValueOnce(error);
signOut.mockResolvedValueOnce(error);
render(<AppShell area="redaktion" legal={legal}>Inhalt</AppShell>);
fireEvent.click(screen.getByRole("button", { name: "Abmelden" }));
expect((await screen.findByRole("alert")).textContent).toMatch(/fehlgeschlagen/i);
expect(screen.getByText("Inhalt")).toBeTruthy();
const retry = screen.getByRole("button", { name: "Abmelden" });
expect((retry as HTMLButtonElement).disabled).toBe(false);
fireEvent.click(retry);
expect(signOut).toHaveBeenCalledTimes(2);
await screen.findByRole("alert");
});
+16 -3
View File
@@ -63,6 +63,7 @@ export function AppShell({
const { resolvedTheme, setTheme } = useTheme();
const [menuOpen, setMenuOpen] = useState(false);
const [signingOut, setSigningOut] = useState(false);
const [signOutFailed, setSignOutFailed] = useState(false);
const [notesOpen, setNotesOpen] = useState(false);
const active = NAV.filter(({ href }) => pathname === href || pathname.startsWith(`${href}/`))
@@ -91,11 +92,18 @@ export function AppShell({
async function signOut() {
setSigningOut(true);
setSignOutFailed(false);
try {
await authClient.signOut();
} finally {
window.location.replace("/anmelden");
const result = await authClient.signOut();
if (result.data?.success === true && !result.error) {
window.location.replace("/anmelden");
return;
}
} catch {
// A failed request leaves the session status unconfirmed.
}
setSignOutFailed(true);
setSigningOut(false);
}
return (
@@ -146,6 +154,11 @@ export function AppShell({
<Button variant="ghost" size="sm" leftIcon={<IconLogout size={16} />} loading={signingOut} onClick={signOut}>
Abmelden
</Button>
{signOutFailed && (
<p className="px-3 text-sm text-[var(--color-danger-fg)]" role="alert">
Abmeldung fehlgeschlagen. Bitte versuchen Sie es erneut.
</p>
)}
</div>
</Sidebar>
</div>