fix: harden Pi management readiness

This commit is contained in:
2026-08-05 06:20:25 +02:00
parent 7a8bcacbfe
commit 7df21b5f21
24 changed files with 577 additions and 274 deletions
@@ -18,19 +18,19 @@ beforeEach(() => {
(globalThis as any).EventSource = FakeEventSource;
useSessionStore.getState().resetSession();
server.use(
http.get("http://localhost:8787/me", () => HttpResponse.json({ issuer: "test", subject: "test", displayName: "Test", isAdmin: false })),
http.get("http://localhost:8787/sessions", () => HttpResponse.json([])),
http.get("http://localhost:8787/settings", () =>
http.get("/api/me", () => HttpResponse.json({ issuer: "test", subject: "test", displayName: "Test", isAdmin: false })),
http.get("/api/sessions", () => HttpResponse.json([])),
http.get("/api/settings", () =>
HttpResponse.json({ workspace: "default", provider: "test", model: "test", thinking: "low" })),
http.get("http://localhost:8787/workspaces", () => HttpResponse.json([])),
http.get("http://localhost:8787/models", () => HttpResponse.json({ models: [] })),
http.get("/api/workspaces", () => HttpResponse.json([])),
http.get("/api/models", () => HttpResponse.json({ models: [] })),
);
});
test("New session starts prewarm without delaying composer focus", async () => {
let prewarmStarted = false;
server.use(
http.post("http://localhost:8787/runtime/prewarm", async () => {
http.post("/api/runtime/prewarm", async () => {
prewarmStarted = true;
await delay(100);
return new HttpResponse(null, { status: 202 });
@@ -51,7 +51,7 @@ test("records the prompt without central duplication, then opens the live log",
let releaseCreate!: () => void;
const createMayFinish = new Promise<void>((resolve) => { releaseCreate = resolve; });
server.use(
http.post("http://localhost:8787/sessions", async () => {
http.post("/api/sessions", async () => {
await createMayFinish;
return HttpResponse.json({ id: "s-new" });
}),
@@ -81,7 +81,7 @@ test("records the prompt without central duplication, then opens the live log",
test("a failed create restores the landing view and preserves the question for retry", async () => {
server.use(
http.post("http://localhost:8787/sessions", () =>
http.post("/api/sessions", () =>
new HttpResponse("unavailable", { status: 503 })),
);
renderShell();
@@ -99,7 +99,7 @@ test("a failed create restores the landing view and preserves the question for r
test("a DWH-unreachable precheck shows a specific alert and preserves the question", async () => {
server.use(
http.post("http://localhost:8787/sessions", () =>
http.post("/api/sessions", () =>
HttpResponse.json(
{
error: "Cannot start a session: the database is unreachable. Check the VPN connection and try again.",
@@ -125,10 +125,10 @@ test("a DWH-unreachable precheck shows a specific alert and preserves the questi
test("model selector shows the three Pi-enabled models and stores the selected provider locally", async () => {
server.use(
http.get("http://localhost:8787/settings", () => HttpResponse.json({
http.get("/api/settings", () => HttpResponse.json({
workspace: "default", provider: "zai", model: "glm-5.2", thinking: "low",
})),
http.get("http://localhost:8787/models", () => HttpResponse.json({ models: [
http.get("/api/models", () => HttpResponse.json({ models: [
{ provider: "zai", id: "glm-5.2", name: "GLM-5.2", reasoning: true },
{ provider: "deepseek", id: "deepseek-v4-flash", name: "DeepSeek V4 Flash", reasoning: true },
{ provider: "local-qwen", id: "qwen3.6-35b-a3b", name: "Qwen3.6 35B A3B Local", reasoning: false },
@@ -151,7 +151,7 @@ test("model selector shows the three Pi-enabled models and stores the selected p
test("opens Workspace management from the right sidebar without interrupting the shell", async () => {
server.use(
http.get("http://localhost:8787/workspace-registry/status", () =>
http.get("/api/workspace-registry/status", () =>
HttpResponse.json({ branch: "main", ahead: 0, behind: 0, degraded: false })),
);
renderShell();