From 93a51f476327e7fac6c245664535b4240799f6a5 Mon Sep 17 00:00:00 2001 From: Kartik Date: Thu, 16 Apr 2026 01:37:51 +0530 Subject: [PATCH] test: update integration tests for v1.1 output_format (#4847) --- mem0-ts/src/client/tests/integration/crud.test.ts | 13 ++++++++++--- mem0-ts/src/client/tests/integration/helpers.ts | 8 ++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/mem0-ts/src/client/tests/integration/crud.test.ts b/mem0-ts/src/client/tests/integration/crud.test.ts index d0771b11f..d3c8a703e 100644 --- a/mem0-ts/src/client/tests/integration/crud.test.ts +++ b/mem0-ts/src/client/tests/integration/crud.test.ts @@ -120,10 +120,13 @@ describeIntegration("MemoryClient Integration — CRUD", () => { // ─── Get all ────────────────────────────────────────────── describe("get all memories", () => { test("returns all memories for test user", async () => { - const memories = await client.getAll({ + const response = await client.getAll({ filters: { user_id: TEST_USER_ID }, }); + // v1.1 output_format returns { results: [...] } + expect(response).toHaveProperty("results"); + const memories = (response as any).results; expect(Array.isArray(memories)).toBe(true); expect(memories.length).toBeGreaterThanOrEqual(memoryIds.length); @@ -142,6 +145,7 @@ describeIntegration("MemoryClient Integration — CRUD", () => { // Paginated response is an object with results array expect(page1).toBeDefined(); + expect(page1).toHaveProperty("results"); }); }); @@ -197,11 +201,14 @@ describeIntegration("MemoryClient Integration — CRUD", () => { expect(result).toHaveProperty("eventId"); }); - test("getAll for non-existent user returns empty array", async () => { - const memories = await client.getAll({ + test("getAll for non-existent user returns empty results", async () => { + const response = await client.getAll({ filters: { user_id: `nonexistent-user-${randomUUID()}` }, }); + // v1.1 output_format returns { results: [...] } + expect(response).toHaveProperty("results"); + const memories = (response as any).results; expect(Array.isArray(memories)).toBe(true); expect(memories.length).toBe(0); }); diff --git a/mem0-ts/src/client/tests/integration/helpers.ts b/mem0-ts/src/client/tests/integration/helpers.ts index b8890a3eb..84279375a 100644 --- a/mem0-ts/src/client/tests/integration/helpers.ts +++ b/mem0-ts/src/client/tests/integration/helpers.ts @@ -67,10 +67,14 @@ export async function waitForMemories( maxRetries = 4, ): Promise { for (let attempt = 1; attempt <= maxRetries; attempt++) { - const memories = await withRetry(() => + const response = await withRetry(() => client.getAll({ filters: { user_id: userId } }), ); - if (Array.isArray(memories) && memories.length >= minCount) { + // v1.1 output_format returns { results: [...] } + const memories = Array.isArray(response) + ? response + : ((response as any)?.results ?? []); + if (memories.length >= minCount) { return memories; } if (attempt < maxRetries) {