refactor: remove legacy workspace UI state
This commit is contained in:
@@ -24,12 +24,12 @@ test("new sessions send the browser-selected workspace, model, provider, and thi
|
||||
}));
|
||||
server.use(
|
||||
http.get("/api/workspaces", () => HttpResponse.json([{
|
||||
id: "psd-clinical", name: "psd-clinical", file: "psd-clinical.yaml", displayName: "PSD Clinical",
|
||||
revision: { id: "psd-clinical", commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: "/snapshot", state: "operational" },
|
||||
id: "psd-clinical", name: "psd-clinical", file: "psd-clinical.yaml", displayName: "PSD Clinical", language: "en",
|
||||
revision: { id: "psd-clinical", commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: "/snapshot" },
|
||||
}])),
|
||||
http.get("/api/workspaces/psd-clinical", () => HttpResponse.json({
|
||||
workspace: canonicalWorkspaceFixture("psd-clinical"),
|
||||
revision: { id: "psd-clinical", commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: "/snapshot", state: "operational" },
|
||||
revision: { id: "psd-clinical", commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: "/snapshot" },
|
||||
})),
|
||||
http.post("/api/sessions", async ({ request }) => {
|
||||
body = await request.json();
|
||||
@@ -135,10 +135,13 @@ test("footer shows cumulative k-token counters after workspace and context gauge
|
||||
http.get("/api/settings", () => HttpResponse.json({
|
||||
workspace: "psd", provider: "zai", model: "glm-5.2", thinking: "medium",
|
||||
})),
|
||||
http.get("/api/workspaces", () => HttpResponse.json([{ name: "psd" }])),
|
||||
http.get("/api/workspaces", () => HttpResponse.json([{
|
||||
id: "psd", name: "psd", file: "psd.yaml", displayName: "PSD", language: "en",
|
||||
revision: { id: "psd", commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: "/snapshot" },
|
||||
}])),
|
||||
http.get("/api/workspaces/psd", () => HttpResponse.json({
|
||||
workspace: canonicalWorkspaceFixture("psd"),
|
||||
revision: { id: "psd", commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: "/snapshot", state: "operational" },
|
||||
revision: { id: "psd", commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: "/snapshot" },
|
||||
})),
|
||||
http.get("/api/models", () => HttpResponse.json({
|
||||
models: [{ provider: "zai", id: "glm-5.2", name: "GLM-5.2", reasoning: true }],
|
||||
@@ -172,12 +175,12 @@ test("footer limits model choices to the selected workspace policy", async () =>
|
||||
workspace: "psd-clinical", provider: "zai", model: "glm-5.2", thinking: "medium",
|
||||
})),
|
||||
http.get("/api/workspaces", () => HttpResponse.json([{
|
||||
id: "psd-clinical", name: "psd-clinical", file: "psd-clinical.yaml", displayName: "PSD Clinical",
|
||||
revision: { id: "psd-clinical", commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: "/snapshot", state: "operational" },
|
||||
id: "psd-clinical", name: "psd-clinical", file: "psd-clinical.yaml", displayName: "PSD Clinical", language: "en",
|
||||
revision: { id: "psd-clinical", commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: "/snapshot" },
|
||||
}])),
|
||||
http.get("/api/workspaces/psd-clinical", () => HttpResponse.json({
|
||||
workspace: canonicalWorkspaceFixture("psd-clinical"),
|
||||
revision: { id: "psd-clinical", commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: "/snapshot", state: "operational" },
|
||||
revision: { id: "psd-clinical", commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: "/snapshot" },
|
||||
})),
|
||||
http.get("/api/models", () => HttpResponse.json({ models: [
|
||||
{ provider: "zai", id: "glm-5.2", name: "GLM-5.2", reasoning: true },
|
||||
@@ -198,15 +201,15 @@ test("switching workspaces replaces an out-of-policy model before session creati
|
||||
workspaceId: "research", provider: "deepseek", model: "deepseek-v4-pro", thinking: "medium",
|
||||
}));
|
||||
const revision = (id: string) => ({
|
||||
id, commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: "/snapshot", state: "operational" as const,
|
||||
id, commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: "/snapshot",
|
||||
});
|
||||
server.use(
|
||||
http.get("/api/settings", () => HttpResponse.json({
|
||||
workspace: "research", provider: "deepseek", model: "deepseek-v4-pro", thinking: "medium",
|
||||
})),
|
||||
http.get("/api/workspaces", () => HttpResponse.json([
|
||||
{ id: "research", name: "research", file: "research.yaml", displayName: "Research", revision: revision("research") },
|
||||
{ id: "psd-clinical", name: "psd-clinical", file: "psd-clinical.yaml", displayName: "PSD Clinical", revision: revision("psd-clinical") },
|
||||
{ id: "research", name: "research", file: "research.yaml", displayName: "Research", language: "en", revision: revision("research") },
|
||||
{ id: "psd-clinical", name: "psd-clinical", file: "psd-clinical.yaml", displayName: "PSD Clinical", language: "en", revision: revision("psd-clinical") },
|
||||
])),
|
||||
http.get("/api/workspaces/research", () => HttpResponse.json({
|
||||
workspace: canonicalWorkspaceFixture("research", ["deepseek/deepseek-v4-pro"]),
|
||||
@@ -251,13 +254,13 @@ test("immediate submit waits for a switched workspace policy before creating a s
|
||||
workspaceId: "research", provider: "deepseek", model: "deepseek-v4-pro", thinking: "medium",
|
||||
}));
|
||||
const revision = (id: string) => ({
|
||||
id, commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: "/snapshot", state: "operational" as const,
|
||||
id, commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: "/snapshot",
|
||||
});
|
||||
server.use(
|
||||
http.get("/api/settings", () => HttpResponse.json({ workspace: "research" })),
|
||||
http.get("/api/workspaces", () => HttpResponse.json([
|
||||
{ id: "research", name: "research", file: "research.yaml", displayName: "Research", revision: revision("research") },
|
||||
{ id: "psd-clinical", name: "psd-clinical", file: "psd-clinical.yaml", displayName: "PSD Clinical", revision: revision("psd-clinical") },
|
||||
{ id: "research", name: "research", file: "research.yaml", displayName: "Research", language: "en", revision: revision("research") },
|
||||
{ id: "psd-clinical", name: "psd-clinical", file: "psd-clinical.yaml", displayName: "PSD Clinical", language: "en", revision: revision("psd-clinical") },
|
||||
])),
|
||||
http.get("/api/workspaces/research", () => HttpResponse.json({
|
||||
workspace: canonicalWorkspaceFixture("research", ["deepseek/deepseek-v4-pro"]), revision: revision("research"),
|
||||
@@ -307,12 +310,12 @@ test("initial restored workspace waits for its delayed policy before creating a
|
||||
workspaceId: "psd-clinical", provider: "deepseek", model: "deepseek-v4-pro", thinking: "medium",
|
||||
}));
|
||||
const revision = (id: string) => ({
|
||||
id, commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: "/snapshot", state: "operational" as const,
|
||||
id, commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: "/snapshot",
|
||||
});
|
||||
server.use(
|
||||
http.get("/api/settings", () => HttpResponse.json({ workspace: "psd-clinical" })),
|
||||
http.get("/api/workspaces", () => HttpResponse.json([
|
||||
{ id: "psd-clinical", name: "psd-clinical", file: "psd-clinical.yaml", displayName: "PSD Clinical", revision: revision("psd-clinical") },
|
||||
{ id: "psd-clinical", name: "psd-clinical", file: "psd-clinical.yaml", displayName: "PSD Clinical", language: "en", revision: revision("psd-clinical") },
|
||||
])),
|
||||
http.get("/api/workspaces/psd-clinical", async () => {
|
||||
policyRequestStarted = true;
|
||||
@@ -347,49 +350,6 @@ test("initial restored workspace waits for its delayed policy before creating a
|
||||
}));
|
||||
});
|
||||
|
||||
test("initial submit rejects a migration-required workspace after summaries load", async () => {
|
||||
let body: unknown;
|
||||
let failure: string | undefined;
|
||||
let releaseSummaries!: () => void;
|
||||
let summaryRequestStarted = false;
|
||||
const summariesMayFinish = new Promise<void>((resolve) => { releaseSummaries = resolve; });
|
||||
localStorage.setItem("thothii.workspace-registry.v1.preferences", JSON.stringify({
|
||||
workspaceId: "legacy-workspace", provider: "deepseek", model: "deepseek-v4-pro", thinking: "medium",
|
||||
}));
|
||||
server.use(
|
||||
http.get("/api/settings", () => HttpResponse.json({ workspace: "legacy-workspace" })),
|
||||
http.get("/api/workspaces", async () => {
|
||||
summaryRequestStarted = true;
|
||||
await summariesMayFinish;
|
||||
return HttpResponse.json([{
|
||||
id: "legacy-workspace", name: "legacy-workspace", file: "legacy-workspace.yaml", displayName: "Legacy workspace",
|
||||
revision: { id: "legacy-workspace", commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: "/snapshot", state: "migration_required" },
|
||||
}]);
|
||||
}),
|
||||
http.get("/api/workspaces/legacy-workspace", () => new HttpResponse(null, { status: 409 })),
|
||||
http.get("/api/models", () => HttpResponse.json({ models: [
|
||||
{ provider: "deepseek", id: "deepseek-v4-pro", name: "DeepSeek V4 Pro", reasoning: true },
|
||||
] })),
|
||||
http.post("/api/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(summaryRequestStarted).toBe(true));
|
||||
await userEvent.type(screen.getByRole("textbox", { name: /new question/i }), "q");
|
||||
await userEvent.click(screen.getByRole("button", { name: /send/i }));
|
||||
|
||||
expect(body).toBeUndefined();
|
||||
expect(screen.getByRole("button", { name: /send/i })).toBeDisabled();
|
||||
releaseSummaries();
|
||||
|
||||
await waitFor(() => expect(failure).toBe("Could not load selected workspace policy. Please retry."));
|
||||
expect(body).toBeUndefined();
|
||||
});
|
||||
|
||||
test("initial submit rejects a workspace summary that omits the canonical revision", async () => {
|
||||
let body: unknown;
|
||||
let failure: string | undefined;
|
||||
@@ -399,7 +359,7 @@ test("initial submit rejects a workspace summary that omits the canonical revisi
|
||||
server.use(
|
||||
http.get("/api/settings", () => HttpResponse.json({ workspace: "broken-workspace" })),
|
||||
http.get("/api/workspaces", () => HttpResponse.json([{
|
||||
id: "broken-workspace", name: "broken-workspace", file: "broken-workspace.yaml", displayName: "Broken workspace",
|
||||
id: "broken-workspace", name: "broken-workspace", file: "broken-workspace.yaml", displayName: "Broken workspace", language: "en",
|
||||
}])),
|
||||
http.get("/api/models", () => HttpResponse.json({ models: [
|
||||
{ provider: "zai", id: "glm-5.2", name: "GLM-5.2", reasoning: true },
|
||||
@@ -467,14 +427,14 @@ test("submit follows a rapid workspace switch instead of waiting for an abandone
|
||||
workspaceId: "research", provider: "deepseek", model: "deepseek-v4-pro", thinking: "medium",
|
||||
}));
|
||||
const revision = (id: string) => ({
|
||||
id, commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: "/snapshot", state: "operational" as const,
|
||||
id, commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: "/snapshot",
|
||||
});
|
||||
server.use(
|
||||
http.get("/api/settings", () => HttpResponse.json({ workspace: "research" })),
|
||||
http.get("/api/workspaces", () => HttpResponse.json([
|
||||
{ id: "research", name: "research", file: "research.yaml", displayName: "Research", revision: revision("research") },
|
||||
{ id: "workspace-b", name: "workspace-b", file: "workspace-b.yaml", displayName: "Workspace B", revision: revision("workspace-b") },
|
||||
{ id: "workspace-c", name: "workspace-c", file: "workspace-c.yaml", displayName: "Workspace C", revision: revision("workspace-c") },
|
||||
{ id: "research", name: "research", file: "research.yaml", displayName: "Research", language: "en", revision: revision("research") },
|
||||
{ id: "workspace-b", name: "workspace-b", file: "workspace-b.yaml", displayName: "Workspace B", language: "en", revision: revision("workspace-b") },
|
||||
{ id: "workspace-c", name: "workspace-c", file: "workspace-c.yaml", displayName: "Workspace C", language: "en", revision: revision("workspace-c") },
|
||||
])),
|
||||
http.get("/api/workspaces/research", () => HttpResponse.json({
|
||||
workspace: canonicalWorkspaceFixture("research", ["deepseek/deepseek-v4-pro"]), revision: revision("research"),
|
||||
|
||||
Reference in New Issue
Block a user