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.7 KiB
TypeScript
66 lines
2.7 KiB
TypeScript
import { Context } from '@deepseek-ai/cordis'
|
|
import { describe, expect, it } from 'vitest'
|
|
import type { HttpServerService } from '@deepseek-ai/dsh-host-webserver'
|
|
import { Settings, settingsNamespace, type SettingsNamespace } from '@deepseek-ai/dsh-settings'
|
|
import {
|
|
DEFAULT_PREFERENCE, THEME_SETTINGS_NAMESPACE, apply,
|
|
} from '@deepseek-ai/dsh-client-ui-theme'
|
|
|
|
class MemorySettings extends Settings {
|
|
readonly writable = true
|
|
protected load(): Promise<Record<string, unknown>> { return Promise.resolve({}) }
|
|
protected persist(_ns: SettingsNamespace, _section: Record<string, unknown>): Promise<void> {
|
|
return Promise.resolve()
|
|
}
|
|
}
|
|
|
|
describe('ui-theme host', () => {
|
|
it('registers, validates, and disposes the durable theme namespace with its fiber', async () => {
|
|
const ctx = new Context()
|
|
await ctx.plugin(MemorySettings).await()
|
|
const fiber = ctx.plugin({ apply })
|
|
await fiber.await()
|
|
const ns = settingsNamespace(THEME_SETTINGS_NAMESPACE)
|
|
expect(ctx.settings.get(ns)).toEqual({ preference: DEFAULT_PREFERENCE })
|
|
await ctx.settings.update(ns, { preference: 'dark' })
|
|
expect(ctx.settings.get(ns)).toEqual({ preference: 'dark' })
|
|
await expect(ctx.settings.update(ns, { preference: 'sepia' })).rejects.toThrow()
|
|
await fiber.dispose()
|
|
expect(ctx.settings.describe().map(row => row.ns)).not.toContain(ns)
|
|
})
|
|
|
|
it('renders the current durable preference and disposes the index transform', async () => {
|
|
const ctx = new Context()
|
|
await ctx.plugin(MemorySettings).await()
|
|
let transform: ((html: string) => string) | undefined
|
|
let disposed = false
|
|
ctx.provide('httpServer', {
|
|
tapIndex: (next: (html: string) => string) => {
|
|
transform = next
|
|
return () => { disposed = true }
|
|
},
|
|
} as HttpServerService)
|
|
const fiber = ctx.plugin({ apply })
|
|
await fiber.await()
|
|
expect(transform?.('<body></body>')).toContain('const preference = "system"')
|
|
await ctx.settings.update(settingsNamespace(THEME_SETTINGS_NAMESPACE), { preference: 'dark' })
|
|
expect(transform?.('<body></body>')).toContain('const preference = "dark"')
|
|
await fiber.dispose()
|
|
expect(disposed).toBe(true)
|
|
expect(transform?.('<body></body>')).toContain('const preference = "system"')
|
|
})
|
|
|
|
it('uses the system preference when only an HTTP server exists', async () => {
|
|
const ctx = new Context()
|
|
let transform: ((html: string) => string) | undefined
|
|
ctx.provide('httpServer', {
|
|
tapIndex: (next: (html: string) => string) => {
|
|
transform = next
|
|
return () => undefined
|
|
},
|
|
} as HttpServerService)
|
|
await ctx.plugin({ apply }).await()
|
|
expect(transform?.('<body></body>')).toContain('const preference = "system"')
|
|
})
|
|
})
|