test(api): cover assistant project reads
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { SystemRole } from "@capakraken/shared";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import {
|
||||
createToolContext,
|
||||
executeTool,
|
||||
} from "./assistant-tools-project-test-helpers.js";
|
||||
|
||||
describe("assistant project read tools - errors", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it("returns a generic assistant error for internal project lookup failures", async () => {
|
||||
const ctx = createToolContext(
|
||||
{
|
||||
project: {
|
||||
findUnique: vi.fn().mockRejectedValue(
|
||||
new TRPCError({
|
||||
code: "INTERNAL_SERVER_ERROR",
|
||||
message: "database connection pool exhausted",
|
||||
}),
|
||||
),
|
||||
},
|
||||
},
|
||||
{ userRole: SystemRole.CONTROLLER },
|
||||
);
|
||||
|
||||
const result = await executeTool(
|
||||
"get_project",
|
||||
JSON.stringify({ identifier: "GDM" }),
|
||||
ctx,
|
||||
);
|
||||
|
||||
expect(JSON.parse(result.content)).toEqual({
|
||||
error: "The tool could not complete due to an internal error.",
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user