test(agent-team): release fixtures and respect snapshot types

This commit is contained in:
Dudu-0223 committed 2026-09-22 14:32:01 +08:00
1 parent b7d9c0f6a4
commit 7befda1147
3 files changed
+14 -11

No files matched your search

@@ -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'
@@ -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<typeof TeamService>[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)
@@ -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 }]]))