node-plugin.spec.ts 948 B

12345678910111213141516171819202122232425262728
  1. import { Context } from 'cordis'
  2. import { afterEach, describe, expect, it } from 'vitest'
  3. import ToolRegistry from '@deepseek-ai/dsh-tools'
  4. import SystemPrompt from '@deepseek-ai/dsh-system-prompt'
  5. import UserInteractionService from '@deepseek-ai/dsh-user-interaction'
  6. import { apply, inject } from '../src/index.ts'
  7. let ctx: Context | undefined
  8. afterEach(async () => {
  9. await ctx?.fiber.dispose()
  10. ctx = undefined
  11. })
  12. describe('ui-question node plugin', () => {
  13. it('exposes ask_user_question only for the selected Web feature lifecycle', async () => {
  14. ctx = new Context()
  15. await ctx.plugin(SystemPrompt)
  16. await ctx.plugin(ToolRegistry)
  17. await ctx.plugin(UserInteractionService)
  18. const feature = ctx.plugin({ inject: [...inject], apply })
  19. await feature.await()
  20. expect(ctx.tools.get('ask_user_question')).toBeDefined()
  21. await feature.dispose()
  22. expect(ctx.tools.get('ask_user_question')).toBeUndefined()
  23. })
  24. })