From 79d23a0d3e5bcba2abdea61e2e9ac3e83e868d5c Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Sat, 29 Aug 2026 18:44:44 -0700 Subject: [PATCH] test(profile): update memoryWrite mocks for #1336's sort + AgentProfile main has been red since d17f95f2: the route chain became find().sort().select().lean() and requires AgentProfile; this suite's mocks predate both, so the handler 500'd with 'sort is not a function'. Test-only fix; the route is correct. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013pc6nGXRS8mHvrwcXMSRDK --- .../unit/routes/agentProfile.memoryWrite.test.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/__tests__/unit/routes/agentProfile.memoryWrite.test.js b/backend/__tests__/unit/routes/agentProfile.memoryWrite.test.js index f8a3744443..e6d54cfddd 100644 --- a/backend/__tests__/unit/routes/agentProfile.memoryWrite.test.js +++ b/backend/__tests__/unit/routes/agentProfile.memoryWrite.test.js @@ -16,6 +16,12 @@ jest.mock('../../../models/AgentMemory', () => ({ jest.mock('../../../models/AgentRun', () => ({ find: jest.fn() })); jest.mock('../../../models/PodAsset', () => ({ find: jest.fn() })); jest.mock('../../../models/pg/Message', () => ({})); +// #1336 added AgentProfile + a .sort() on the installation chain; this +// suite's mocks predate both (main went red on merge — the author updated +// the sibling suites' mocks but not this one). +jest.mock('../../../models/AgentProfile', () => ({ + find: jest.fn(() => ({ select: () => ({ lean: async () => [] }) })), +})); jest.mock('../../../models/AgentRegistry', () => ({ AgentInstallation: { findOne: jest.fn(), find: jest.fn() }, AgentRegistry: { findOne: jest.fn(), updateOne: jest.fn() }, @@ -67,7 +73,8 @@ const runProfile = async (sections) => { createdAt: new Date('2026-01-01T00:00:00Z'), })); PodAsset.find.mockReturnValue(selectLean([])); - AgentInstallation.find.mockReturnValue(selectLean([])); + // Route chain is find().sort().select().lean() since #1336. + AgentInstallation.find.mockReturnValue({ sort: () => selectLean([]) }); Pod.find.mockReturnValue(selectLean([])); AgentMemory.findOne.mockReturnValue(selectLean({ sections })); AgentRun.find.mockReturnValue({