All checks were successful
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-central-services-admin (push) Successful in 22s
Build and Push Docker Images / build-docs (push) Successful in 22s
Build and Push Docker Images / build-backend (push) Successful in 45s
Build and Push Docker Images / build-frontend (push) Successful in 22s
76 lines
2.9 KiB
TypeScript
76 lines
2.9 KiB
TypeScript
import assert from "node:assert/strict"
|
|
import test from "node:test"
|
|
import { organisationTools } from "../src/mcp/tools/organisation"
|
|
import { activateProjectPhase } from "../src/mcp/projectPhases"
|
|
|
|
const phases = [
|
|
{ key: "start", label: "Erstkontakt", active: true, optional: false },
|
|
{ key: "planning", label: "Planung", optional: false },
|
|
{ key: "review", label: "Prüfung", optional: true },
|
|
{ key: "execution", label: "Umsetzung", optional: false },
|
|
{ key: "done", label: "Abgeschlossen", optional: false },
|
|
]
|
|
|
|
test("registers a write-protected project phase update tool", () => {
|
|
const tool = organisationTools.find((candidate) => candidate.name === "organisation.projects.phase.update")
|
|
|
|
assert.deepEqual(tool?.requiredPermissions, ["organisation.projects.write"])
|
|
assert.deepEqual((tool?.inputSchema as any).required, ["id"])
|
|
})
|
|
|
|
test("activates the next project phase by key and records actor and timestamp", () => {
|
|
const result = activateProjectPhase(phases, { phaseKey: "planning" }, "user-1", "2026-08-31T12:00:00.000Z")
|
|
|
|
assert.equal(result.activePhase, "Planung")
|
|
assert.equal(result.previousPhase, "Erstkontakt")
|
|
assert.equal(result.phases[0].active, false)
|
|
assert.deepEqual(result.phases[1], {
|
|
key: "planning",
|
|
label: "Planung",
|
|
optional: false,
|
|
active: true,
|
|
activated_at: "2026-08-31T12:00:00.000Z",
|
|
activated_by: "user-1",
|
|
})
|
|
})
|
|
|
|
test("allows skipping optional phases and selecting a unique phase label", () => {
|
|
const planningActive = phases.map((phase) => ({ ...phase, active: phase.key === "planning" }))
|
|
const result = activateProjectPhase(planningActive, { phaseLabel: "Umsetzung" }, "user-1", "2026-08-31T12:00:00.000Z")
|
|
|
|
assert.equal(result.activePhase, "Umsetzung")
|
|
})
|
|
|
|
test("rejects skipping required phases", () => {
|
|
assert.throws(
|
|
() => activateProjectPhase(phases, { phaseKey: "execution" }, "user-1", "2026-08-31T12:00:00.000Z"),
|
|
/Planung.*zuerst aktiviert/,
|
|
)
|
|
})
|
|
|
|
test("allows completing a project directly like the UI", () => {
|
|
const result = activateProjectPhase(phases, { phaseKey: "done" }, "user-1", "2026-08-31T12:00:00.000Z")
|
|
|
|
assert.equal(result.activePhase, "Abgeschlossen")
|
|
})
|
|
|
|
test("rejects unknown, ambiguous and already activated phases", () => {
|
|
assert.throws(
|
|
() => activateProjectPhase(phases, { phaseKey: "missing" }, "user-1", "2026-08-31T12:00:00.000Z"),
|
|
/nicht gefunden/,
|
|
)
|
|
|
|
assert.throws(
|
|
() => activateProjectPhase([
|
|
...phases,
|
|
{ key: "planning-2", label: "Planung", optional: true },
|
|
], { phaseLabel: "Planung" }, "user-1", "2026-08-31T12:00:00.000Z"),
|
|
/nicht eindeutig/,
|
|
)
|
|
|
|
assert.throws(
|
|
() => activateProjectPhase(phases, { phaseKey: "start" }, "user-1", "2026-08-31T12:00:00.000Z"),
|
|
/bereits aktiv/,
|
|
)
|
|
})
|