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}`.
61 lines
2.4 KiB
TypeScript
61 lines
2.4 KiB
TypeScript
// @vitest-environment jsdom
|
|
// Branch tails the acceptance specs do not reach: the node-half apply
|
|
// without a settings service and AssistantMarkdown reasoning/unknown block arms.
|
|
|
|
import { afterEach, describe, expect, it } from 'vitest'
|
|
import { Context } from '@deepseek-ai/cordis'
|
|
import { cleanup, render } from '@testing-library/react'
|
|
import { makeTranslate } from '@deepseek-ai/dsh-client-test-runtime'
|
|
import { zh as commonZh } from '@deepseek-ai/dsh-client-locale/src/locales/zh.ts'
|
|
import { apply as nodeApply } from '../src/index.ts'
|
|
import { AssistantMarkdown, type AssistantMarkdownProps } from '../src/client/chat/AssistantMarkdown.tsx'
|
|
import { zh } from '../src/client/locales.ts'
|
|
|
|
// Mirrors the real lookup chain (conversation namespace, then common).
|
|
const t: AssistantMarkdownProps['t'] = makeTranslate(zh, commonZh)
|
|
|
|
afterEach(cleanup)
|
|
|
|
describe('tails', () => {
|
|
it('node-half apply tolerates a Host without settings', () => {
|
|
expect(() => { nodeApply(new Context()) }).not.toThrow()
|
|
})
|
|
|
|
it('AssistantMarkdown renders reasoning as a Think row and unknown blocks as JSON fallback', () => {
|
|
const view = render(
|
|
<AssistantMarkdown
|
|
t={t}
|
|
blocks={[
|
|
{ kind: 'reasoning', text: 'thinking hard\nsecond line' },
|
|
{ kind: 'tool-call', callId: 'c', name: 'bash', argsRaw: '{}' },
|
|
{ kind: 'other', block: { type: 'mystery' } },
|
|
]}
|
|
streaming
|
|
/>,
|
|
)
|
|
expect(view.getByText('Think')).toBeTruthy()
|
|
expect(view.getByText('thinking hard')).toBeTruthy()
|
|
expect(view.getByText(/未知内容块/)).toBeTruthy()
|
|
const stopped = render(
|
|
<AssistantMarkdown t={t} blocks={[{ kind: 'text', text: 'partial words' }]} streaming={false} interrupted />,
|
|
)
|
|
expect(stopped.getByText('已停止')).toBeTruthy()
|
|
})
|
|
|
|
it('AssistantMarkdown skips the root shell when only tool-call heads remain', () => {
|
|
// Tool heads are drawn by ChatView's tool groups; an empty root between
|
|
// groups is layout noise (no text, no pulse, no interrupted marker).
|
|
const empty = render(
|
|
<AssistantMarkdown
|
|
t={t}
|
|
blocks={[{ kind: 'tool-call', callId: 'c', name: 'todo_write', argsRaw: '{}' }]}
|
|
streaming={false}
|
|
/>,
|
|
)
|
|
expect(empty.container.firstChild).toBeNull()
|
|
const blank = render(<AssistantMarkdown t={t} blocks={[]} streaming={false} />)
|
|
expect(blank.container.firstChild).toBeNull()
|
|
})
|
|
|
|
})
|