fix: block creation when workspace summaries fail
This commit is contained in:
@@ -379,6 +379,44 @@ test("initial submit waits for delayed workspace summaries before allowing a con
|
||||
}));
|
||||
});
|
||||
|
||||
test("failed workspace summaries block creation and report a safe error", async () => {
|
||||
let body: unknown;
|
||||
let failure: string | undefined;
|
||||
let summaryRequestFailed = false;
|
||||
localStorage.setItem("thothii.workspace-registry.v1.preferences", JSON.stringify({
|
||||
workspaceId: "psd-clinical", provider: "zai", model: "glm-5.2", thinking: "medium",
|
||||
}));
|
||||
server.use(
|
||||
http.get("http://localhost:8787/settings", () => HttpResponse.json({ workspace: "psd-clinical" })),
|
||||
http.get("http://localhost:8787/workspaces", () => {
|
||||
summaryRequestFailed = true;
|
||||
return new HttpResponse(null, { status: 503 });
|
||||
}),
|
||||
http.get("http://localhost:8787/models", () => HttpResponse.json({ models: [
|
||||
{ provider: "zai", id: "glm-5.2", name: "GLM-5.2", reasoning: true },
|
||||
] })),
|
||||
http.post("http://localhost:8787/sessions", async ({ request }) => {
|
||||
body = await request.json();
|
||||
return HttpResponse.json({ id: "s1" });
|
||||
}),
|
||||
);
|
||||
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
||||
render(
|
||||
<QueryClientProvider client={client}>
|
||||
<ComposerFooter />
|
||||
<SteerInput sessionId={null} onSessionCreateFailed={(message) => { failure = message; }} />
|
||||
</QueryClientProvider>,
|
||||
);
|
||||
|
||||
await waitFor(() => expect(summaryRequestFailed).toBe(true));
|
||||
await waitFor(() => expect(client.getQueryState(["workspaces"])?.status).toBe("error"));
|
||||
await userEvent.type(screen.getByRole("textbox", { name: /new question/i }), "q");
|
||||
await userEvent.click(screen.getByRole("button", { name: /send/i }));
|
||||
|
||||
await waitFor(() => expect(failure).toBe("Could not load workspace registry. Please retry."));
|
||||
expect(body).toBeUndefined();
|
||||
});
|
||||
|
||||
test("submit follows a rapid workspace switch instead of waiting for an abandoned policy", async () => {
|
||||
let body: unknown;
|
||||
let releaseC!: () => void;
|
||||
|
||||
Reference in New Issue
Block a user