host.client.spec.ts 1.3 KB

123456789101112131415161718192021222324252627282930
  1. import { Context } from '@deepseek-ai/cordis'
  2. import { describe, expect, it } from 'vitest'
  3. import { SettingsProvider, type SettingsNamespace } from '@deepseek-ai/dsh-settings'
  4. import {
  5. CONVERSATION_SETTINGS_NAMESPACE, DEFAULT_BUSY_ENTER_BEHAVIOR, apply,
  6. } from '@deepseek-ai/dsh-client-ui-conversation'
  7. class MemorySettings extends SettingsProvider {
  8. readonly writable = true
  9. protected load(): Promise<Record<string, unknown>> { return Promise.resolve({}) }
  10. protected persist(_ns: SettingsNamespace, _section: Record<string, unknown>): Promise<void> {
  11. return Promise.resolve()
  12. }
  13. }
  14. describe('ui-conversation host', () => {
  15. it('registers, validates, and disposes the durable busy-Enter preference', async () => {
  16. const ctx = new Context()
  17. await ctx.plugin(MemorySettings).await()
  18. const fiber = ctx.plugin({ apply })
  19. await fiber.await()
  20. const ns = CONVERSATION_SETTINGS_NAMESPACE
  21. expect(ctx.settings.get(ns)).toEqual({ busyEnter: DEFAULT_BUSY_ENTER_BEHAVIOR })
  22. await ctx.settings.update(ns, { busyEnter: 'steer' })
  23. expect(ctx.settings.get(ns)).toEqual({ busyEnter: 'steer' })
  24. await expect(ctx.settings.update(ns, { busyEnter: 'invalid' })).rejects.toThrow()
  25. await fiber.dispose()
  26. expect(ctx.settings.describe().map(row => row.ns)).not.toContain(ns)
  27. })
  28. })