Files
deepseek-harness/packages/host/directory-picker/tests/seam.spec.ts
creatixchu 5579b13503 refactor(host): rename the directory-picker dialog backend and kind to native
The browse interaction also presents a dialog (the in-app modal), so 'dialog'
failed to discriminate the two capability kinds; 'native' names where the
chooser runs. Package directory-picker-dialog -> directory-picker-native, kind
'dialog' -> 'native', with every seam/gateway/client/doc reference updated and
the seam Agent Note's naming rationale rewritten to match.
2026-07-28 21:07:28 +08:00

36 lines
1.5 KiB
TypeScript

/** Contract behavior the seam itself owns: registration identity and typed failures. */
import { describe, expect, it } from 'vitest'
import { Context } from 'cordis'
import { DirectoryPicker, DirectoryPickerError } from '../src/index.ts'
import type { DirectoryPickerCapability } from '../src/index.ts'
/** Minimal concrete backend: all a subclass owes the abstract class is capability(). */
class StubPicker extends DirectoryPicker {
private readonly stub: DirectoryPickerCapability = { kind: 'native', pick: async () => null }
capability(): DirectoryPickerCapability {
return this.stub
}
}
describe('DirectoryPicker seam', () => {
it('registers a subclass as ctx.directoryPicker and leaves with its fiber', async () => {
const ctx = new Context()
const fiber = ctx.plugin(StubPicker)
await fiber.await()
expect(ctx.get('directoryPicker')).toBeInstanceOf(StubPicker)
expect(ctx.get('directoryPicker')!.capability().kind).toBe('native')
await fiber.dispose()
expect(ctx.get('directoryPicker')).toBeUndefined()
})
it('carries the business code and subject path on DirectoryPickerError', () => {
const failure = new DirectoryPickerError('directory-exists', '/home/u/x', '/home/u/x already exists')
expect(failure.name).toBe('DirectoryPickerError')
expect(failure.code).toBe('directory-exists')
expect(failure.path).toBe('/home/u/x')
expect(failure.message).toContain('already exists')
expect(failure).toBeInstanceOf(Error)
})
})