Wiki-Bearbeitung im MCP ergänzen
All checks were successful
Build and Push Docker Images / build-backend (push) Successful in 46s
Build and Push Docker Images / build-frontend (push) Successful in 23s
Build and Push Docker Images / build-website (push) Successful in 22s
Build and Push Docker Images / build-central-services-api (push) Successful in 22s
Build and Push Docker Images / build-docs (push) Successful in 23s
Build and Push Docker Images / build-central-services-admin (push) Successful in 22s
All checks were successful
Build and Push Docker Images / build-backend (push) Successful in 46s
Build and Push Docker Images / build-frontend (push) Successful in 23s
Build and Push Docker Images / build-website (push) Successful in 22s
Build and Push Docker Images / build-central-services-api (push) Successful in 22s
Build and Push Docker Images / build-docs (push) Successful in 23s
Build and Push Docker Images / build-central-services-admin (push) Successful in 22s
This commit is contained in:
79
backend/tests/mcpWiki.test.ts
Normal file
79
backend/tests/mcpWiki.test.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
import assert from "node:assert/strict"
|
||||
import test from "node:test"
|
||||
import { mcpToolMap } from "../src/mcp/registry"
|
||||
import { prepareWikiScope, wikiTools } from "../src/mcp/tools/wiki"
|
||||
|
||||
const tool = (name: string) => wikiTools.find((candidate) => candidate.name === name)
|
||||
|
||||
test("registers read and write tools for global and entity wiki pages", () => {
|
||||
const expected = [
|
||||
["wiki.pages.list", "wiki.read"],
|
||||
["wiki.pages.get", "wiki.read"],
|
||||
["wiki.pages.create", "wiki.write"],
|
||||
["wiki.pages.update", "wiki.write"],
|
||||
["wiki.pages.delete", "wiki.write"],
|
||||
] as const
|
||||
|
||||
for (const [name, permission] of expected) {
|
||||
assert.deepEqual(tool(name)?.requiredPermissions, [permission])
|
||||
assert.equal(mcpToolMap.get(name), tool(name))
|
||||
}
|
||||
})
|
||||
|
||||
test("exposes entity scope on list and create tools", () => {
|
||||
for (const name of ["wiki.pages.list", "wiki.pages.create"]) {
|
||||
const properties = (tool(name)?.inputSchema as any)?.properties
|
||||
assert.equal(properties.entityType.type, "string")
|
||||
assert.equal(properties.entityId.type, "number")
|
||||
assert.equal(properties.entityUuid.type, "string")
|
||||
}
|
||||
})
|
||||
|
||||
test("prepares global, numeric entity and UUID entity wiki scopes", () => {
|
||||
assert.deepEqual(prepareWikiScope({}), {
|
||||
entityType: null,
|
||||
entityId: null,
|
||||
entityUuid: null,
|
||||
})
|
||||
assert.deepEqual(prepareWikiScope({ entityType: "customers", entityId: 42 }), {
|
||||
entityType: "customers",
|
||||
entityId: 42,
|
||||
entityUuid: null,
|
||||
})
|
||||
assert.deepEqual(prepareWikiScope({
|
||||
entityType: "ownaccounts",
|
||||
entityUuid: "57d31d62-11a2-47c5-b074-69f9c5ab8bba",
|
||||
}), {
|
||||
entityType: "ownaccounts",
|
||||
entityId: null,
|
||||
entityUuid: "57d31d62-11a2-47c5-b074-69f9c5ab8bba",
|
||||
})
|
||||
})
|
||||
|
||||
test("rejects incomplete or ambiguous entity wiki scopes", () => {
|
||||
assert.throws(() => prepareWikiScope({ entityType: "customers" }), /entityId oder entityUuid/)
|
||||
assert.throws(() => prepareWikiScope({ entityId: 42 }), /entityType/)
|
||||
assert.throws(
|
||||
() => prepareWikiScope({
|
||||
entityType: "customers",
|
||||
entityId: 42,
|
||||
entityUuid: "57d31d62-11a2-47c5-b074-69f9c5ab8bba",
|
||||
}),
|
||||
/entweder entityId oder entityUuid/,
|
||||
)
|
||||
assert.throws(
|
||||
() => prepareWikiScope({ entityType: "customers", entityUuid: "not-a-uuid" }),
|
||||
/gültige UUID/,
|
||||
)
|
||||
})
|
||||
|
||||
test("requires identifiers and editable fields on mutating tools", () => {
|
||||
assert.deepEqual((tool("wiki.pages.create")?.inputSchema as any).required, ["title"])
|
||||
assert.deepEqual((tool("wiki.pages.update")?.inputSchema as any).required, ["id"])
|
||||
assert.deepEqual((tool("wiki.pages.delete")?.inputSchema as any).required, ["id"])
|
||||
|
||||
const updateProperties = (tool("wiki.pages.update")?.inputSchema as any).properties
|
||||
for (const field of ["title", "content", "parentId", "sortOrder", "isFolder"]) {
|
||||
assert.ok(updateProperties[field], `${field} fehlt im Update-Schema`)
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user