From 5e586efad7c194712dad2d3b33594940daf3fdf3 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Wed, 22 Jul 2026 10:49:57 -0700 Subject: [PATCH] fix(test): canonical beforeAll/afterAll PGLite pattern in query-embed-deadline test check-test-isolation R3+R4: engine creation moves into beforeAll, add afterAll(disconnect) so the engine doesn't leak across files in the shard process. Co-Authored-By: Claude Fable 5 --- test/search/query-embed-deadline.test.ts | 33 +++++++++++++----------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/test/search/query-embed-deadline.test.ts b/test/search/query-embed-deadline.test.ts index 1efef3f8e..cd72ba437 100644 --- a/test/search/query-embed-deadline.test.ts +++ b/test/search/query-embed-deadline.test.ts @@ -12,7 +12,7 @@ * insufficient against a wedged provider), and that a shared/elapsed deadline * makes a second embed fail FAST (worst case ~one timeout, not two). */ -import { describe, test, expect, beforeEach, afterEach } from 'bun:test'; +import { describe, test, expect, beforeAll, afterAll, beforeEach, afterEach } from 'bun:test'; import { configureGateway, resetGateway, @@ -93,21 +93,24 @@ describe('embedQueryBounded — query-embed deadline', () => { describe('hybridSearch meta.degraded_reason (#2028)', () => { let engine: import('../../src/core/pglite-engine.ts').PGLiteEngine; - beforeEach(async () => { + beforeAll(async () => { + const { PGLiteEngine } = await import('../../src/core/pglite-engine.ts'); + engine = new PGLiteEngine(); + await engine.connect({}); + await engine.initSchema(); + await engine.putPage('notes/hello', { + type: 'note' as any, + title: 'hello', + compiled_truth: 'hello world content', + timeline: '', + frontmatter: {}, + }); + }); + afterAll(async () => { + await engine.disconnect(); + }); + beforeEach(() => { resetGateway(); - if (!engine) { - const { PGLiteEngine } = await import('../../src/core/pglite-engine.ts'); - engine = new PGLiteEngine(); - await engine.connect({}); - await engine.initSchema(); - await engine.putPage('notes/hello', { - type: 'note' as any, - title: 'hello', - compiled_truth: 'hello world content', - timeline: '', - frontmatter: {}, - }); - } }); afterEach(async () => { __setEmbedTransportForTests(null);