revise tool calls
This commit is contained in:
@@ -14,6 +14,7 @@ import { MOCK_MESSAGE_LIST, MOCK_MESSAGES, MOCK_EMPTY_LIST } from "../fixtures/m
|
||||
const mockGmailList = vi.fn();
|
||||
const mockGmailGet = vi.fn();
|
||||
const mockGmailTrash = vi.fn();
|
||||
const mockGmailBatchModify = vi.fn();
|
||||
let tmpDir: string;
|
||||
|
||||
vi.mock("../../src/loaders/prompt-config-loaders.js", () => {
|
||||
@@ -45,6 +46,7 @@ vi.mock("../../src/loaders/prompt-config-loaders.js", () => {
|
||||
list: mockGmailList,
|
||||
get: mockGmailGet,
|
||||
trash: mockGmailTrash,
|
||||
batchModify: mockGmailBatchModify,
|
||||
},
|
||||
},
|
||||
}),
|
||||
@@ -207,6 +209,51 @@ describe("Phase 1: Email Review Workflow", () => {
|
||||
});
|
||||
});
|
||||
|
||||
// ----- Step 2b: Star A, C, and D emails -----
|
||||
describe("star_emails", () => {
|
||||
it("stars and marks read the specified message IDs", async () => {
|
||||
mockGmailBatchModify.mockResolvedValue({});
|
||||
|
||||
const text = await callTool("star_emails", {
|
||||
account: "work",
|
||||
messageIds: ["msg-cat-a-001", "msg-cat-c-001", "msg-cat-d-001"],
|
||||
});
|
||||
|
||||
expect(mockGmailBatchModify).toHaveBeenCalledTimes(1);
|
||||
expect(mockGmailBatchModify).toHaveBeenCalledWith({
|
||||
userId: "me",
|
||||
requestBody: {
|
||||
ids: ["msg-cat-a-001", "msg-cat-c-001", "msg-cat-d-001"],
|
||||
addLabelIds: ["STARRED"],
|
||||
removeLabelIds: ["UNREAD"],
|
||||
},
|
||||
});
|
||||
expect(text).toContain("Successfully starred and marked read 3 email(s).");
|
||||
});
|
||||
|
||||
it("returns early when no message IDs are provided", async () => {
|
||||
const text = await callTool("star_emails", {
|
||||
account: "work",
|
||||
messageIds: [],
|
||||
});
|
||||
|
||||
expect(mockGmailBatchModify).not.toHaveBeenCalled();
|
||||
expect(text).toBe("No message IDs provided.");
|
||||
});
|
||||
|
||||
it("handles Gmail API errors gracefully", async () => {
|
||||
mockGmailBatchModify.mockRejectedValue(new Error("Quota exceeded"));
|
||||
|
||||
const text = await callTool("star_emails", {
|
||||
account: "work",
|
||||
messageIds: ["msg-cat-a-001"],
|
||||
});
|
||||
|
||||
expect(text).toContain("Error starring emails");
|
||||
expect(text).toContain("Quota exceeded");
|
||||
});
|
||||
});
|
||||
|
||||
// ----- Step 3: Summarize B and D -----
|
||||
describe("append_to_summary", () => {
|
||||
it("creates a summary file and appends entries", async () => {
|
||||
|
||||
Reference in New Issue
Block a user