mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
A test file under packages/client now says which face it covers:
`*.client.spec.{ts,tsx}` and its `*.client.{ts,tsx}` helpers belong to the
Client aggregate, `*.host.spec.ts` to the host aggregate. The carrier's four
node-half specs take the Host suffix.
The two suffixes are mutually exclusive, so each aggregate excludes the
other's and both keep one broad test glob: `exclude` wins over `include`, and
`packages/client/**` no longer has to be excluded wholesale from the host
program with per-file `files` entries carved back out of it. A Host-face spec
that reaches only Host source therefore needs no cross-face project
reference, which the split-project rule rejects.
vitest still discovers every file through `**/*.spec.{ts,tsx}`.
66 lines
2.5 KiB
TypeScript
66 lines
2.5 KiB
TypeScript
// @vitest-environment jsdom
|
|
/**
|
|
* buildRenderApp on SlotTestRuntime: the fail-loud sessions precondition, the
|
|
* one ctx-level renderSlot('root') call, and the document-title projection
|
|
* arms over the real slot stack.
|
|
*/
|
|
import { afterEach, describe, expect, it } from 'vitest'
|
|
import { cleanup, render } from '@testing-library/react'
|
|
import { Context } from '@deepseek-ai/cordis'
|
|
import { SlotTestRuntime } from '@deepseek-ai/dsh-client-test-runtime'
|
|
import type { SessionId } from '@deepseek-ai/dsh-client-runtime/client'
|
|
import { buildRenderApp } from '@deepseek-ai/dsh-client-web/src/app.tsx'
|
|
|
|
let runtime: SlotTestRuntime | undefined
|
|
|
|
afterEach(async () => {
|
|
cleanup()
|
|
await runtime?.dispose()
|
|
runtime = undefined
|
|
document.title = ''
|
|
})
|
|
|
|
async function bench() {
|
|
runtime = await SlotTestRuntime.create()
|
|
await runtime.root.declare({}, () => <div data-testid="frame" />)
|
|
return { runtime, renderApp: buildRenderApp({ ctx: runtime.ctx }) }
|
|
}
|
|
|
|
describe('buildRenderApp', () => {
|
|
it('fails loud when the sessions service is unavailable', () => {
|
|
expect(() => buildRenderApp({ ctx: new Context() })).toThrow('sessions service unavailable')
|
|
})
|
|
|
|
it('renders the root slot tree through the one ctx-level renderSlot call', async () => {
|
|
const b = await bench()
|
|
const view = render(<>{b.renderApp()}</>)
|
|
expect(view.getByTestId('frame')).toBeTruthy()
|
|
})
|
|
|
|
it('projects the current session durable title and falls back to the product title', async () => {
|
|
document.title = 'Product'
|
|
const b = await bench()
|
|
render(<>{b.renderApp()}</>)
|
|
// No current session: the product title stands.
|
|
expect(document.title).toBe('Product')
|
|
await b.runtime.sessions.add({ id: 's1', summary: { title: 'First' } })
|
|
expect(document.title).toBe('First — Product')
|
|
await b.runtime.sessions.setCurrent(undefined)
|
|
expect(document.title).toBe('Product')
|
|
// A session without a durable title keeps the product title.
|
|
await b.runtime.sessions.add({ id: 's2' })
|
|
expect(document.title).toBe('Product')
|
|
})
|
|
|
|
it('a current id without a list row falls back (selection/list arbitration transient)', async () => {
|
|
document.title = 'Product'
|
|
const b = await bench()
|
|
await b.runtime.sessions.add({ id: 's1', summary: { title: 'First' } })
|
|
render(<>{b.renderApp()}</>)
|
|
expect(document.title).toBe('First — Product')
|
|
b.runtime.sessions.list.update((draft) => { draft.current = 'ghost' as SessionId })
|
|
await b.runtime.flush()
|
|
expect(document.title).toBe('Product')
|
|
})
|
|
})
|