Files
ThothII/frontend/src/shell/AppShell.notifications.test.tsx
T

30 lines
1.2 KiB
TypeScript

import { act, render, screen } from "@testing-library/react";
import { http, HttpResponse } from "msw";
import { App } from "../App";
import { queryClient } from "../app/queryClient";
import { useSessionStore } from "../store/sessionStore";
import { server } from "../test/msw";
beforeEach(() => {
queryClient.clear();
useSessionStore.getState().resetSession();
server.use(
http.get("/api/me", () => HttpResponse.json({ issuer: "local", subject: "dev", isAdmin: true })),
http.get("/api/sessions", () => HttpResponse.json([])),
http.get("/api/settings", () => HttpResponse.json({ workspace: "psd-clinical" })),
http.get("/api/workspaces", () => HttpResponse.json([])),
http.get("/api/models", () => HttpResponse.json({ models: [] })),
);
});
test("session errors queued in the store become visible notifications", async () => {
render(<App />);
await screen.findByTestId("app-shell");
act(() => useSessionStore.getState().pushToast({
level: "error",
text: "The selected model is unavailable for this subscription.",
}));
expect(await screen.findByText("The selected model is unavailable for this subscription.")).toBeInTheDocument();
});