Files
deepseek-harness/packages/client/ui-session-panel/tests/sections.client.spec.ts
T
LegGasai 968223aaa2 feat(web): add the floating Session panel
Add dsh-client-ui-session-panel: a Session header toggle and a floating
panel seated in the main Conversation body. Plugins register sections
(id, order, label) and title controls; the built-in Environment section
shows the project directory and accepts rows from other plugins.

The panel docks only while the transcript's end gutter can hold it; the
Conversation width controls report that gutter through
ctx.uiConversation.layouts. A narrower gutter hides it, and the toggle
then opens a transient overlay. The turn rail moves to the start edge.
2026-11-05 17:15:29 +08:00

44 lines
1.7 KiB
TypeScript

import { describe, expect, it, vi } from 'vitest'
import type { StoredEntry } from '@deepseek-ai/dsh-client-ui-slots'
import { projectSections } from '../src/client/sections.ts'
function entry(id: string, order: number | undefined, label: StoredEntry['options']['label'], registrant?: string): StoredEntry {
return {
component: () => null,
options: { id, ...order === undefined ? {} : { order }, ...label === undefined ? {} : { label } },
...registrant === undefined ? {} : { registrant },
}
}
describe('projectSections', () => {
it('orders sections by ascending order, keeping registration order for ties, and resolves locale thunks', () => {
const report = vi.fn()
const sections = projectSections([
entry('later', 100, 'Change requests'),
entry('first', 0, () => 'Environment'),
entry('tie', 100, 'Outputs'),
entry('default', undefined, 'Default order'),
], report)
expect(sections).toEqual([
{ id: 'first', label: 'Environment' },
{ id: 'default', label: 'Default order' },
{ id: 'later', label: 'Change requests' },
{ id: 'tie', label: 'Outputs' },
])
expect(report).not.toHaveBeenCalled()
})
it('reports and leaves out a section that cannot be titled', () => {
const report = vi.fn()
const sections = projectSections([
entry('untitled', 0, undefined, 'acme-plugin'),
entry('blank', 1, ''),
entry('titled', 2, 'Titled'),
], report)
expect(sections).toEqual([{ id: 'titled', label: 'Titled' }])
expect(report).toHaveBeenCalledTimes(2)
expect(report.mock.calls[0]?.[0]).toContain('"untitled" from acme-plugin')
expect(report.mock.calls[1]?.[0]).toContain('"blank" from an unknown registrant')
})
})