Skip to content

Commit fed2944

Browse files
fix(ai): restore embedText mock in QueryRecentTurns.spec afterAll (#12682) (#12683)
1 parent 11a96f8 commit fed2944

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

test/playwright/unit/ai/services/memory-core/QueryRecentTurns.spec.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import RequestContextService from '../../../../../../ai/mcp/server/shared/servic
3030
* mechanically prevents the fail-open default — AC7a alone passes even if this path is broken).
3131
*/
3232
test.describe('Neo.ai.services.memory-core.queryRecentTurns', () => {
33-
let MemoryService, GraphService, LifecycleService, TextEmbeddingService, StorageRouter, originalGetMemoryCollection;
33+
let MemoryService, GraphService, LifecycleService, TextEmbeddingService, StorageRouter, originalGetMemoryCollection, originalEmbedText;
3434

3535
test.beforeAll(async () => {
3636
GraphService = (await import('../../../../../../ai/services/memory-core/GraphService.mjs')).default;
@@ -60,7 +60,10 @@ test.describe('Neo.ai.services.memory-core.queryRecentTurns', () => {
6060
await LifecycleService.ready();
6161
}
6262

63-
// Offline tests cannot hit a real embedder.
63+
// Offline tests cannot hit a real embedder. Save the original first so afterAll can restore
64+
// it: an unrestored embedText mock leaks a 4096-length vector into sibling specs sharing the
65+
// worker (e.g. the retry spec asserting a [0.1, 0.2, 0.3] return), reddening their unit run.
66+
originalEmbedText = TextEmbeddingService.embedText;
6467
TextEmbeddingService.embedText = async () => new Array(4096).fill(0.1);
6568

6669
// Seed the AgentIdentity nodes the AUTHORED_BY edge + '@me' resolution depend on.
@@ -70,6 +73,7 @@ test.describe('Neo.ai.services.memory-core.queryRecentTurns', () => {
7073

7174
test.afterAll(async () => {
7275
if (originalGetMemoryCollection) StorageRouter.getMemoryCollection = originalGetMemoryCollection;
76+
if (originalEmbedText) TextEmbeddingService.embedText = originalEmbedText;
7377
const {cleanupChromaManager} = await import('./util.mjs');
7478
await cleanupChromaManager();
7579
});

0 commit comments

Comments
 (0)