mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-23 17:33:51 +02:00
Fix LLM Wiki update-space archive response
This commit is contained in:
1 parent
284e0d49b9
commit
559ab2afdc
2 files changed
+58
No files matched your search
@@ -1465,6 +1465,17 @@ export async function updateSpace(ctx: PluginContext, input: UpdateSpaceInput):
|
||||
nextStatus ?? null,
|
||||
],
|
||||
);
|
||||
if (nextStatus === "archived") {
|
||||
return {
|
||||
status: "ok",
|
||||
space: {
|
||||
...space,
|
||||
displayName: nextDisplayName ?? space.displayName,
|
||||
settings: input.settings ? { ...space.settings, ...input.settings } : space.settings,
|
||||
status: "archived",
|
||||
},
|
||||
};
|
||||
}
|
||||
return { status: "ok", space: await resolveSpace(ctx, { companyId: input.companyId, wikiId: space.wikiId, spaceSlug: space.slug }) };
|
||||
}
|
||||
|
||||
|
||||
@@ -2821,6 +2821,53 @@ Duplicate headings receive stable suffixes.
|
||||
execute.params?.includes("archived"))).toBe(false);
|
||||
});
|
||||
|
||||
it("archives a non-default space through update-space without re-resolving it as active", async () => {
|
||||
const harness = createTestHarness({ manifest });
|
||||
const spaceRow = wikiSpaceRow({
|
||||
id: "77777777-7777-4777-8777-7777777777b1",
|
||||
slug: "qa-space",
|
||||
displayName: "QA Space",
|
||||
pathPrefix: "spaces/qa-space",
|
||||
status: "active",
|
||||
settings: { owner: "qa" },
|
||||
});
|
||||
let archived = false;
|
||||
const originalQuery = harness.ctx.db.query.bind(harness.ctx.db);
|
||||
harness.ctx.db.query = async <T,>(sql: string, params?: unknown[]) => {
|
||||
harness.dbQueries.push({ sql, params });
|
||||
if (sql.includes("wiki_spaces") && params?.[2] === "qa-space") {
|
||||
return archived && sql.includes("status <> 'archived'") ? [] as T[] : [spaceRow] as T[];
|
||||
}
|
||||
return originalQuery<T>(sql, params);
|
||||
};
|
||||
const originalExecute = harness.ctx.db.execute.bind(harness.ctx.db);
|
||||
harness.ctx.db.execute = async (sql: string, params?: unknown[]) => {
|
||||
if (sql.includes("UPDATE") && sql.includes("wiki_spaces") && params?.includes("archived")) archived = true;
|
||||
return originalExecute(sql, params);
|
||||
};
|
||||
|
||||
await plugin.definition.setup(harness.ctx);
|
||||
const updated = await harness.performAction<{
|
||||
status: string;
|
||||
space: { slug: string; displayName: string; status: string; settings: Record<string, unknown> };
|
||||
}>("update-space", {
|
||||
companyId: COMPANY_ID,
|
||||
spaceSlug: "qa-space",
|
||||
displayName: "Archived QA",
|
||||
settings: { archivedBy: "test" },
|
||||
status: "archived",
|
||||
});
|
||||
|
||||
expect(updated.status).toBe("ok");
|
||||
expect(updated.space).toMatchObject({
|
||||
slug: "qa-space",
|
||||
displayName: "Archived QA",
|
||||
status: "archived",
|
||||
settings: { owner: "qa", archivedBy: "test" },
|
||||
});
|
||||
expect(archived).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects unknown space statuses through update-space", async () => {
|
||||
const harness = createTestHarness({ manifest });
|
||||
await plugin.definition.setup(harness.ctx);
|
||||
|
||||
Reference in new issue
Block a user