feat(auth): add remembered local login to the frontend

This commit is contained in:
2026-08-17 04:52:39 +02:00
parent 8c67cb75dc
commit 202822f3ba
36 changed files with 2649 additions and 163 deletions
+7 -6
View File
@@ -1,4 +1,4 @@
import { render, screen } from "@testing-library/react";
import { act, cleanup, render, screen } from "@testing-library/react";
import { WidgetHost } from "./WidgetHost";
import { useSessionStore } from "../store/sessionStore";
import type { WidgetDescriptor } from "../api/types";
@@ -17,18 +17,19 @@ beforeEach(() => {
useSessionStore.getState().resetSession();
});
afterEach(() => {
cleanup();
errorSpy.mockRestore();
useSessionStore.getState().resetSession();
act(() => useSessionStore.getState().resetSession());
});
const gate: WidgetDescriptor = { id: "g1", widget: "select", title: "Choose" };
test("a crashing widget shows a fallback instead of unmounting the app", () => {
test("a crashing widget shows a fallback instead of unmounting the app", async () => {
useSessionStore.setState({ pendingWidget: gate });
render(<WidgetHost sessionId="s1" />);
await act(async () => { render(<WidgetHost sessionId="s1" />); });
// No throw escaped: the fallback rendered.
expect(screen.getByRole("alert")).toBeInTheDocument();
expect(screen.getByText(/couldn't be displayed/i)).toBeInTheDocument();
expect(await screen.findByRole("alert")).toBeInTheDocument();
expect(await screen.findByText(/couldn't be displayed/i)).toBeInTheDocument();
// The store (and thus the surrounding app) is still alive and interactive.
expect(useSessionStore.getState().pendingWidget).toEqual(gate);
});