From 7befda1147b9511e6daa8effc72d51257d8a0cfe Mon Sep 17 00:00:00 2001 From: Dudu-0223 Date: Tue, 22 Sep 2026 14:32:01 +0800 Subject: [PATCH] test(agent-team): release fixtures and respect snapshot types --- .../agent-team/tests/built-lib.e2e.ts | 2 +- .../experimental/agent-team/tests/team.spec.ts | 7 ++++++- .../tests/team-action.client.spec.tsx | 16 +++++++--------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/packages/experimental/agent-team/tests/built-lib.e2e.ts b/packages/experimental/agent-team/tests/built-lib.e2e.ts index 897ba36e4a..d171624d80 100644 --- a/packages/experimental/agent-team/tests/built-lib.e2e.ts +++ b/packages/experimental/agent-team/tests/built-lib.e2e.ts @@ -1,4 +1,4 @@ -/** Plain-Node smoke for the built Agent Teams service and Remote contribution. */ +/** Plain-Node smoke for the built Agent Teams service. */ import { execFile } from 'node:child_process' import { existsSync } from 'node:fs' diff --git a/packages/experimental/agent-team/tests/team.spec.ts b/packages/experimental/agent-team/tests/team.spec.ts index 55b6b5efe3..af939b0108 100644 --- a/packages/experimental/agent-team/tests/team.spec.ts +++ b/packages/experimental/agent-team/tests/team.spec.ts @@ -22,9 +22,11 @@ import { TestSessionQuery } from './test-session-query.ts' const SIGNAL = new AbortController().signal const roots: string[] = [] +const contexts: Context[] = [] -afterEach(() => { +afterEach(async () => { vi.useRealTimers() + for (const ctx of contexts.splice(0).reverse()) await ctx.fiber.dispose() for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true }) }) @@ -60,6 +62,7 @@ async function setup( config: ConstructorParameters[1] = {}, ) { const ctx = new Context() + contexts.push(ctx) await mountAgentLoopTestDependencies(ctx) const storageRoot = mkdtempSync(join(tmpdir(), 'dsh-team-')) roots.push(storageRoot) @@ -167,6 +170,7 @@ describe('Team identity and provisioning', () => { it('supports direct-constructor defaults and recovers roots that already exist', async () => { const ctx = new Context() + contexts.push(ctx) await mountAgentLoopTestDependencies(ctx) const storageRoot = mkdtempSync(join(tmpdir(), 'dsh-team-direct-')) roots.push(storageRoot) @@ -1346,6 +1350,7 @@ describe('Team mailbox and waiting', () => { it('waits for one change, supports cancellation, times out, and releases waiters on HMR disposal', async () => { const ctx = new Context() + contexts.push(ctx) await mountAgentLoopTestDependencies(ctx) const storageRoot = mkdtempSync(join(tmpdir(), 'dsh-team-wait-')) roots.push(storageRoot) diff --git a/packages/experimental/client-ui-agent-team/tests/team-action.client.spec.tsx b/packages/experimental/client-ui-agent-team/tests/team-action.client.spec.tsx index 9949212f5e..c1c588995a 100644 --- a/packages/experimental/client-ui-agent-team/tests/team-action.client.spec.tsx +++ b/packages/experimental/client-ui-agent-team/tests/team-action.client.spec.tsx @@ -225,9 +225,10 @@ describe('TeamAction', () => { expect(b.injected.loadProjections).not.toHaveBeenCalled() act(() => { - b.session.update((draft) => { - draft.openState = 'error' - draft.openError = new RemoteError('gateway/internal', 'history unavailable', {}) + b.session.set({ + ...b.session.getSnapshot(), + openState: 'error', + openError: new RemoteError('gateway/internal', 'history unavailable', {}), }) }) expect(screen.getByRole('alert').textContent).toBe('history unavailable (gateway/internal)') @@ -235,10 +236,7 @@ describe('TeamAction', () => { expect(b.injected.loadProjections).not.toHaveBeenCalled() act(() => { - b.session.update((draft) => { - draft.openState = 'open' - draft.openError = null - }) + b.session.set({ ...b.session.getSnapshot(), openState: 'open', openError: null }) }) expect(screen.getByRole('status').textContent).toBe(zh.unavailable) setProjection(b.sessions, SESSION, team) @@ -259,10 +257,10 @@ describe('TeamAction', () => { .map(([id, snapshot]) => [id, { ...snapshot }])) b.sessions.set({ ...current, - byId: { ...current.byId, unrelated: summary('unrelated' as SessionId, true) }, + byId: { ...current.byId, ['unrelated' as SessionId]: summary('unrelated' as SessionId, true) }, projectionsBySession: { ...projectionsBySession, - unrelated: { state: 'ready', error: null, values: { agentTeam: { members: [], tasks: [] } } }, + ['unrelated' as SessionId]: { state: 'ready', error: null, values: { agentTeam: { members: [], tasks: [] } } }, }, }) b.statuses.set(new Map([['unrelated' as SessionId, { running: true, pendingInteraction: undefined, completionUnread: false }]]))