test(api): cover assistant reminder tools

This commit is contained in:
2026-04-01 00:06:51 +02:00
parent 5c6941d675
commit 5fae007a3b
5 changed files with 485 additions and 0 deletions
@@ -0,0 +1,53 @@
import { describe, expect, it, vi } from "vitest";
import { SystemRole } from "@capakraken/shared";
vi.mock("@capakraken/application", async (importOriginal) => {
const actual = await importOriginal<typeof import("@capakraken/application")>();
return {
...actual,
getDashboardBudgetForecast: vi.fn().mockResolvedValue([]),
getDashboardPeakTimes: vi.fn().mockResolvedValue([]),
listAssignmentBookings: vi.fn().mockResolvedValue([]),
};
});
import { executeTool } from "../router/assistant-tools.js";
import { createToolContext, withUserLookup } from "./assistant-tools-notification-test-helpers.js";
describe("assistant reminder mutation tools - errors", () => {
it("returns a stable assistant error when updating a missing reminder", async () => {
const ctx = createToolContext(withUserLookup({
notification: {
findFirst: vi.fn().mockResolvedValue(null),
},
}), SystemRole.ADMIN);
const result = await executeTool(
"update_reminder",
JSON.stringify({ id: "rem_missing", title: "Updated" }),
ctx,
);
expect(JSON.parse(result.content)).toEqual({
error: "Reminder not found with the given criteria.",
});
});
it("returns a stable assistant error when deleting a missing reminder", async () => {
const ctx = createToolContext(withUserLookup({
notification: {
findFirst: vi.fn().mockResolvedValue(null),
},
}), SystemRole.ADMIN);
const result = await executeTool(
"delete_reminder",
JSON.stringify({ id: "rem_missing" }),
ctx,
);
expect(JSON.parse(result.content)).toEqual({
error: "Reminder not found with the given criteria.",
});
});
});