Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

fix(web): update email route test mocks for agent query rename

Gener4665510d7320
diff --git a/src/web/src/app/api/email/[id]/route.test.ts b/src/web/src/app/api/email/[id]/route.test.ts
index d0248d96f..628f712e3 100644
--- a/src/web/src/app/api/email/[id]/route.test.ts
+++ b/src/web/src/app/api/email/[id]/route.test.ts
@@ -2,7 +2,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
import { NextRequest } from "next/server";
const mockGetEmailById = vi.fn();
-const mockGetAgentInWorkspace = vi.fn();
+const mockGetAgent = vi.fn();
const mockDeleteEmail = vi.fn();
vi.mock("@opennextjs/cloudflare", () => ({
@@ -19,7 +19,7 @@ vi.mock("@alook/shared", () => ({
deleteEmail: (...args: unknown[]) => mockDeleteEmail(...args),
},
agent: {
- getAgentInWorkspace: (...args: unknown[]) => mockGetAgentInWorkspace(...args),
+ getAgent: (...args: unknown[]) => mockGetAgent(...args),
},
},
}));
@@ -50,7 +50,7 @@ describe("DELETE /api/email/[id]", () => {
it("deletes an email and returns 204", async () => {
mockGetEmailById.mockResolvedValue({ id: "e1", agentId: "a1" });
- mockGetAgentInWorkspace.mockResolvedValue({ id: "a1" });
+ mockGetAgent.mockResolvedValue({ id: "a1" });
mockDeleteEmail.mockResolvedValue(undefined);
const req = new NextRequest("http://localhost/api/email/e1?workspace_id=ws1", { method: "DELETE" });
@@ -71,7 +71,7 @@ describe("DELETE /api/email/[id]", () => {
it("returns 404 when agent not in workspace", async () => {
mockGetEmailById.mockResolvedValue({ id: "e1", agentId: "a1" });
- mockGetAgentInWorkspace.mockResolvedValue(null);
+ mockGetAgent.mockResolvedValue(null);
const req = new NextRequest("http://localhost/api/email/e1?workspace_id=ws1", { method: "DELETE" });
const res = await DELETE(req, { params: Promise.resolve({ id: "e1" }) } as any);
diff --git a/src/web/src/app/api/email/send/route.test.ts b/src/web/src/app/api/email/send/route.test.ts
index 458dc4acc..a1dab205b 100644
--- a/src/web/src/app/api/email/send/route.test.ts
+++ b/src/web/src/app/api/email/send/route.test.ts
@@ -1,7 +1,7 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
import { NextRequest } from "next/server";
-const mockGetAgentInWorkspace = vi.fn();
+const mockGetAgent = vi.fn();
const mockCreateEmail = vi.fn();
const mockR2Put = vi.fn();
const mockR2Get = vi.fn();
@@ -27,7 +27,7 @@ vi.mock("@alook/shared", () => ({
createEmail: (...args: unknown[]) => mockCreateEmail(...args),
},
agent: {
- getAgentInWorkspace: (...args: unknown[]) => mockGetAgentInWorkspace(...args),
+ getAgent: (...args: unknown[]) => mockGetAgent(...args),
},
},
}));
@@ -61,7 +61,7 @@ describe("POST /api/email/send", () => {
beforeEach(() => vi.clearAllMocks());
it("sends an email and returns the created record", async () => {
- mockGetAgentInWorkspace.mockResolvedValue({ id: "a1", emailHandle: "test-agent" });
+ mockGetAgent.mockResolvedValue({ id: "a1", emailHandle: "test-agent" });
mockCreateEmail.mockResolvedValue({
id: "e1", agentId: "a1", fromEmail: "[email protected]",
toEmail: "[email protected]", subject: "Hello",
@@ -92,7 +92,7 @@ describe("POST /api/email/send", () => {
});
it("sends email with attachments as MIME multipart/mixed", async () => {
- mockGetAgentInWorkspace.mockResolvedValue({ id: "a1", emailHandle: "test-agent" });
+ mockGetAgent.mockResolvedValue({ id: "a1", emailHandle: "test-agent" });
mockCreateEmail.mockResolvedValue({ id: "e1" });
mockR2Put.mockResolvedValue(undefined);
mockSendEmailSend.mockResolvedValue({ messageId: "msg1" });
@@ -130,7 +130,7 @@ describe("POST /api/email/send", () => {
});
it("skips missing R2 attachments gracefully", async () => {
- mockGetAgentInWorkspace.mockResolvedValue({ id: "a1", emailHandle: "test-agent" });
+ mockGetAgent.mockResolvedValue({ id: "a1", emailHandle: "test-agent" });
mockCreateEmail.mockResolvedValue({ id: "e1" });
mockR2Put.mockResolvedValue(undefined);
mockSendEmailSend.mockResolvedValue({ messageId: "msg1" });
@@ -154,7 +154,7 @@ describe("POST /api/email/send", () => {
});
it("returns 400 when agent has no emailHandle", async () => {
- mockGetAgentInWorkspace.mockResolvedValue({ id: "a1", emailHandle: null });
+ mockGetAgent.mockResolvedValue({ id: "a1", emailHandle: null });
const req = new NextRequest("http://localhost/api/email/send?workspace_id=ws1", {
method: "POST",
@@ -171,7 +171,7 @@ describe("POST /api/email/send", () => {
});
it("returns 404 when agent not in workspace", async () => {
- mockGetAgentInWorkspace.mockResolvedValue(null);
+ mockGetAgent.mockResolvedValue(null);
const req = new NextRequest("http://localhost/api/email/send?workspace_id=ws1", {
method: "POST",