feat: complete catalog-driven preprocessing
Publish documentation / publish (push) Successful in 2m12s
Publish documentation / publish (push) Successful in 2m12s
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { http, HttpResponse } from "msw";
|
||||
import { server } from "./test/msw";
|
||||
import { App } from "./App";
|
||||
@@ -50,3 +51,54 @@ test("trusted upstream authentication keeps identity but omits ThothII logout",
|
||||
expect(await screen.findByText("Portal user")).toBeInTheDocument();
|
||||
expect(screen.queryByRole("button", { name: "Log out" })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
test("a local login always enters the core activity", async () => {
|
||||
let signedIn = false;
|
||||
localStorage.setItem("thothii:app-navigation", JSON.stringify({
|
||||
surface: "database-management",
|
||||
panel: null,
|
||||
}));
|
||||
server.use(
|
||||
http.get("/api/auth/config", () => HttpResponse.json({
|
||||
mode: "local",
|
||||
localLogin: true,
|
||||
oidcLogin: false,
|
||||
})),
|
||||
http.get("/api/me", () => signedIn
|
||||
? HttpResponse.json({
|
||||
issuer: "local",
|
||||
subject: "admin-user",
|
||||
displayName: "Admin user",
|
||||
roles: ["admin"],
|
||||
permissions: ["session.use", "database.manage"],
|
||||
isAdmin: true,
|
||||
csrfToken: "c".repeat(43),
|
||||
session: null,
|
||||
})
|
||||
: new HttpResponse(null, { status: 401 })),
|
||||
http.post("/api/auth/local/login", () => {
|
||||
signedIn = true;
|
||||
return HttpResponse.json({});
|
||||
}),
|
||||
http.get("/api/settings", () => HttpResponse.json({
|
||||
workspace: "psd", provider: "zai", model: "glm-5.2", thinking: "medium",
|
||||
})),
|
||||
http.get("/api/workspaces", () => HttpResponse.json([])),
|
||||
http.get("/api/models", () => HttpResponse.json({ models: [] })),
|
||||
http.get("/api/sessions", () => HttpResponse.json([])),
|
||||
http.get("/api/workspace-registry/status", () => HttpResponse.json({
|
||||
branch: "main", ahead: 0, behind: 0, degraded: false,
|
||||
})),
|
||||
);
|
||||
|
||||
render(<App />);
|
||||
|
||||
await screen.findByRole("heading", { name: /sign in to thothii/i });
|
||||
await userEvent.type(screen.getByLabelText(/username/i), "admin");
|
||||
await userEvent.type(screen.getByLabelText(/^password$/i), "correct-password");
|
||||
await userEvent.click(screen.getByRole("button", { name: /sign in/i }));
|
||||
|
||||
expect(await screen.findByRole("button", { name: "New session" }))
|
||||
.toHaveAttribute("aria-current", "page");
|
||||
expect(screen.queryByRole("main", { name: "Database management" })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user