From 2b529bc2aa5ad8d834b59b8bf457e27c8ce28729 Mon Sep 17 00:00:00 2001 From: Tianyi Cui <53024+tianyicui@users.noreply.github.com> Date: Wed, 2 Sep 2026 13:50:00 +0800 Subject: [PATCH] test(session-persistence-jsonl): keep migration assertions typed --- .../tests/jsonl.spec.ts | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/session/session-persistence-jsonl/tests/jsonl.spec.ts b/packages/session/session-persistence-jsonl/tests/jsonl.spec.ts index 106f4e188d..fa5fc2929d 100644 --- a/packages/session/session-persistence-jsonl/tests/jsonl.spec.ts +++ b/packages/session/session-persistence-jsonl/tests/jsonl.spec.ts @@ -491,9 +491,8 @@ describe('JsonlSessionPersistence: immutable format generations', () => { expect(await ctx.sessionPersistence.stat(header.id)).toMatchObject({ header: { id: header.id, version: SESSION_FORMAT_VERSION }, }) - expect(await ctx.sessionPersistence.list()).toEqual([ - expect.objectContaining({ header: expect.objectContaining({ id: header.id, version: SESSION_FORMAT_VERSION }) }), - ]) + const [listed] = await ctx.sessionPersistence.list() + expect(listed?.header).toMatchObject({ id: header.id, version: SESSION_FORMAT_VERSION }) expect(await readFile(sourcePath)).toEqual(source) await expect(stat(currentPath)).rejects.toMatchObject({ code: 'ENOENT' }) }) @@ -539,7 +538,7 @@ describe('JsonlSessionPersistence: immutable format generations', () => { it('reports no current generation when ensure-current finds no stored id', async () => { const storage = ctx.sessionPersistence as unknown as { - ensureCurrentLog(id: SessionId, signal?: AbortSignal): Promise + ensureCurrentLog(id: SessionId, signal?: AbortSignal): Promise } await expect(storage.ensureCurrentLog(SessionId('missing-generation'))).resolves.toBeUndefined() @@ -666,10 +665,11 @@ describe('JsonlSessionPersistence: immutable format generations', () => { await mkdir(dirname(sourcePath), { recursive: true }) await writeFile(sourcePath, source) - await expect(ctx.sessionPersistence.open(header.id, 'read')).rejects.toMatchObject({ - name: 'SessionFormatUnsupportedError', - message: expect.stringContaining('unknown historical event type "external/info" at seq 0'), - }) + const failure = await ctx.sessionPersistence.open(header.id, 'read') + .then(() => undefined, (error: unknown) => error) + expect(failure).toBeInstanceOf(Error) + expect((failure as Error).name).toBe('SessionFormatUnsupportedError') + expect((failure as Error).message).toContain('unknown historical event type "external/info" at seq 0') expect(await readFile(sourcePath)).toEqual(source) await expect(stat(rawLogPath(root, header.cwd, header.id))).rejects.toMatchObject({ code: 'ENOENT' }) }) @@ -683,10 +683,11 @@ describe('JsonlSessionPersistence: immutable format generations', () => { readStoredLog(path: string, expectedId: SessionId, signal?: AbortSignal): Promise } - await expect(storage.readStoredLog(path, header.id)).rejects.toMatchObject({ - name: 'SessionFormatUnsupportedError', - message: expect.stringContaining(`(raw log: ${path})`), - }) + const failure = await storage.readStoredLog(path, header.id) + .then(() => undefined, (error: unknown) => error) + expect(failure).toBeInstanceOf(Error) + expect((failure as Error).name).toBe('SessionFormatUnsupportedError') + expect((failure as Error).message).toContain(`(raw log: ${path})`) }) it('refuses a current Zstandard path without a complete header frame', async () => {