diff --git a/server/src/__tests__/issues-goal-context-routes.test.ts b/server/src/__tests__/issues-goal-context-routes.test.ts index 25ce2042..db2bdbc4 100644 --- a/server/src/__tests__/issues-goal-context-routes.test.ts +++ b/server/src/__tests__/issues-goal-context-routes.test.ts @@ -10,6 +10,7 @@ const mockIssueService = vi.hoisted(() => ({ findMentionedProjectIds: vi.fn(), getCommentCursor: vi.fn(), getComment: vi.fn(), + listAttachments: vi.fn(), })); const mockProjectService = vi.hoisted(() => ({ @@ -129,6 +130,7 @@ describe("issue goal context routes", () => { latestCommentAt: null, }); mockIssueService.getComment.mockResolvedValue(null); + mockIssueService.listAttachments.mockResolvedValue([]); mockProjectService.getById.mockResolvedValue({ id: legacyProjectLinkedIssue.projectId, companyId: "company-1", @@ -197,5 +199,6 @@ describe("issue goal context routes", () => { }), ); expect(mockGoalService.getDefaultCompanyGoal).not.toHaveBeenCalled(); + expect(res.body.attachments).toEqual([]); }); }); diff --git a/server/src/routes/issues.ts b/server/src/routes/issues.ts index 2898feae..0c334ee7 100644 --- a/server/src/routes/issues.ts +++ b/server/src/routes/issues.ts @@ -482,11 +482,12 @@ export function issueRoutes( ? req.query.wakeCommentId.trim() : null; - const [{ project, goal }, ancestors, commentCursor, wakeComment] = await Promise.all([ + const [{ project, goal }, ancestors, commentCursor, wakeComment, attachments] = await Promise.all([ resolveIssueProjectAndGoal(issue), svc.getAncestors(issue.id), svc.getCommentCursor(issue.id), wakeCommentId ? svc.getComment(wakeCommentId) : null, + svc.listAttachments(issue.id), ]); res.json({ @@ -533,6 +534,14 @@ export function issueRoutes( wakeComment && wakeComment.issueId === issue.id ? wakeComment : null, + attachments: attachments.map((a) => ({ + id: a.id, + filename: a.originalFilename, + contentType: a.contentType, + byteSize: a.byteSize, + contentPath: withContentPath(a).contentPath, + createdAt: a.createdAt, + })), }); });