mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-30 13:20:54 +01:00
Validate LLM Wiki space status updates
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
fb86c6c8e5
commit
284e0d49b9
2 files changed
+19
-1
No files matched your search
@@ -1442,7 +1442,10 @@ export async function createSpace(ctx: PluginContext, input: CreateSpaceInput):
|
||||
export async function updateSpace(ctx: PluginContext, input: UpdateSpaceInput): Promise<{ status: "ok"; space: WikiSpace }> {
|
||||
const space = await resolveSpace(ctx, input);
|
||||
const nextDisplayName = stringField(input.displayName);
|
||||
const nextStatus = input.status;
|
||||
const nextStatus = input.status ?? null;
|
||||
if (nextStatus !== null && nextStatus !== "active" && nextStatus !== "archived") {
|
||||
throw new Error("LLM Wiki space status must be active or archived.");
|
||||
}
|
||||
if (space.slug === DEFAULT_SPACE_SLUG && nextStatus === "archived") {
|
||||
throw new Error("The default LLM Wiki space cannot be archived.");
|
||||
}
|
||||
|
||||
@@ -2821,6 +2821,21 @@ Duplicate headings receive stable suffixes.
|
||||
execute.params?.includes("archived"))).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects unknown space statuses through update-space", async () => {
|
||||
const harness = createTestHarness({ manifest });
|
||||
await plugin.definition.setup(harness.ctx);
|
||||
|
||||
await expect(harness.performAction("update-space", {
|
||||
companyId: COMPANY_ID,
|
||||
spaceSlug: "default",
|
||||
status: "suspended",
|
||||
})).rejects.toThrow("LLM Wiki space status must be active or archived.");
|
||||
expect(harness.dbExecutes.some((execute) =>
|
||||
execute.sql.includes("UPDATE") &&
|
||||
execute.sql.includes("wiki_spaces") &&
|
||||
execute.params?.includes("suspended"))).toBe(false);
|
||||
});
|
||||
|
||||
it("omits archived spaces from the spaces data API", async () => {
|
||||
const harness = createTestHarness({ manifest });
|
||||
const activeRow = wikiSpaceRow({
|
||||
|
||||
Reference in new issue
Block a user