Files
deepseek-harness/packages/experimental/client-ui-agent-team/tests/browser-plugin.client.spec.ts
T

58 lines
2.1 KiB
TypeScript

import { Context } from '@deepseek-ai/cordis'
import { describe, expect, it } from 'vitest'
import { LocaleRuntime } from '@deepseek-ai/dsh-client-locale/client'
import { SlotRegistry } from '@deepseek-ai/dsh-client-ui-renderer/client'
import { TeamAction } from '../src/client/TeamAction.tsx'
import { apply, inject } from '../src/client/index.ts'
import { apply as nodeApply } from '../src/index.ts'
async function bench() {
const ctx = new Context()
ctx.provide('locale', new LocaleRuntime(ctx))
await ctx.plugin(SlotRegistry).await()
const collapseHeader = ctx.slots.register({
name: 'root',
children: { 'conversation.session.header.actions': { kind: 'list', scope: 'session' } },
} as never, () => null)
const fiber = ctx.plugin({ inject: [...inject], apply })
await fiber.await()
const entry = () => ctx.slots.entries('conversation.session.header.actions')
.find(candidate => candidate.component === TeamAction)
return { ctx, fiber, entry, collapseHeader }
}
describe('task-board browser plugin', () => {
it('registers one disposable task-board action without navigation or Team Remote services', async () => {
const b = await bench()
expect(inject).toEqual(['slots', 'locale'])
expect(b.entry()).toMatchObject({
options: { id: 'agent-team', order: -20 },
locale: 'agent-team',
})
expect(b.entry()!.inject).toBeUndefined()
const t = b.ctx.locale.bind('agent-team')
expect(t('trigger')).toBe('Task board')
await b.fiber.dispose()
expect(b.entry()).toBeUndefined()
expect(t('empty')).toBe('empty')
})
it('re-registers when the conversation header slot is declared again', async () => {
const b = await bench()
expect(b.entry()).toBeDefined()
b.collapseHeader()
expect(b.entry()).toBeUndefined()
b.ctx.slots.register({
name: 'root',
children: { 'conversation.session.header.actions': { kind: 'list', scope: 'session' } },
} as never, () => null)
await Promise.resolve()
expect(b.entry()).toBeDefined()
await b.fiber.dispose()
})
it('keeps the node half inert', () => {
expect(() => { nodeApply() }).not.toThrow()
})
})