sdk-app.spec.ts 1.5 KB

1234567891011121314151617181920212223242526272829
  1. /** The SDK app bundle's declared profile patch. */
  2. import { readFileSync } from 'node:fs'
  3. import { resolve } from 'node:path'
  4. import { fileURLToPath } from 'node:url'
  5. import * as yaml from 'js-yaml'
  6. import { describe, expect, it } from 'vitest'
  7. import { entryListSchema } from '@deepseek-ai/cordis-plugin-include'
  8. describe('dsh-sdk-app bundle', () => {
  9. it('declares startup-gated JSON-RPC serving without overriding base HMR policy', () => {
  10. const root = fileURLToPath(new URL('..', import.meta.url))
  11. const manifest = JSON.parse(readFileSync(resolve(root, 'package.json'), 'utf8')) as {
  12. dependencies?: Record<string, string>
  13. dsh?: { bundle?: { patch?: string } }
  14. }
  15. expect(manifest.dsh?.bundle?.patch).toBe('./cordis.patch.yml')
  16. expect(manifest.dependencies).toHaveProperty('@deepseek-ai/dsh-sdk-jsonrpc-server')
  17. const patches = yaml.load(
  18. readFileSync(resolve(root, manifest.dsh!.bundle!.patch!), 'utf8'),
  19. { schema: entryListSchema },
  20. ) as Array<{ id?: string; disabled?: boolean; insert?: Array<{ id?: string; inject?: string[]; name?: string }> }>
  21. expect(patches.find(patch => patch.id === 'hmr')).toMatchObject({ disabled: true })
  22. expect(patches.find(patch => patch.id === 'session-title-llm')).toMatchObject({ disabled: true })
  23. const rows = patches.flatMap(patch => patch.insert ?? [])
  24. expect(rows.find(row => row.id === 'sdk-app-startup')?.name).toBe('@deepseek-ai/dsh-sdk-app')
  25. expect(rows.find(row => row.id === 'sdk-jsonrpc-server')?.inject).toEqual(['sdkAppStartup', 'loader'])
  26. })
  27. })