|
|
@@ -59,7 +59,7 @@ function stubAgent(session: Session): Agent {
|
|
|
/** Compose the API over real Session, Agent, Storage, Domain, and Workspace services. */
|
|
|
async function harness(
|
|
|
workspaceRoot = realpathSync(mkdtempSync(join(tmpdir(), 'dsh-apiproxy-workspace-'))),
|
|
|
- picker: DirectoryPickerCapability = { kind: 'dialog', pick: async () => null },
|
|
|
+ picker: DirectoryPickerCapability = { kind: 'native', pick: async () => null },
|
|
|
) {
|
|
|
const ctx = new Context()
|
|
|
await ctx.plugin(SessionStore)
|
|
|
@@ -107,19 +107,19 @@ async function harness(
|
|
|
}
|
|
|
|
|
|
describe('host.pickDirectory', () => {
|
|
|
- it('returns a selected path or explicit cancellation from the dialog capability', async () => {
|
|
|
- const selected = await harness(undefined, { kind: 'dialog', pick: async () => '/tmp/project' })
|
|
|
+ it('returns a selected path or explicit cancellation from the native capability', async () => {
|
|
|
+ const selected = await harness(undefined, { kind: 'native', pick: async () => '/tmp/project' })
|
|
|
expect((await selected.api.host.pickDirectory(request({}), new AbortController().signal)).result)
|
|
|
.toEqual({ ok: true, value: { path: '/tmp/project' } })
|
|
|
|
|
|
- const cancelled = await harness(undefined, { kind: 'dialog', pick: async () => null })
|
|
|
+ const cancelled = await harness(undefined, { kind: 'native', pick: async () => null })
|
|
|
expect((await cancelled.api.host.pickDirectory(request({}), new AbortController().signal)).result)
|
|
|
.toEqual({ ok: true, value: { path: null } })
|
|
|
})
|
|
|
|
|
|
- it('propagates abort into the dialog capability as a cancelled RPC error', async () => {
|
|
|
+ it('propagates abort into the native capability as a cancelled RPC error', async () => {
|
|
|
const { api } = await harness(undefined, {
|
|
|
- kind: 'dialog',
|
|
|
+ kind: 'native',
|
|
|
pick: signal => new Promise((_resolve, reject) => {
|
|
|
signal.addEventListener('abort', () => { reject(new Error('aborted')) }, { once: true })
|
|
|
}),
|
|
|
@@ -130,13 +130,13 @@ describe('host.pickDirectory', () => {
|
|
|
expect((await pending).result).toMatchObject({ ok: false, error: { code: 'cancelled' } })
|
|
|
})
|
|
|
|
|
|
- it('folds a non-abort dialog failure into an internal error', async () => {
|
|
|
- const { api } = await harness(undefined, { kind: 'dialog', pick: async () => { throw new Error('no chooser installed') } })
|
|
|
+ it('folds a non-abort native-chooser failure into an internal error', async () => {
|
|
|
+ const { api } = await harness(undefined, { kind: 'native', pick: async () => { throw new Error('no chooser installed') } })
|
|
|
const response = await api.host.pickDirectory(request({}), new AbortController().signal)
|
|
|
expect(response.result).toMatchObject({ ok: false, error: { code: 'internal' } })
|
|
|
})
|
|
|
|
|
|
- it('refuses the dialog RPC under a browse composition', async () => {
|
|
|
+ it('refuses the native RPC under a browse composition', async () => {
|
|
|
const { api } = await harness(undefined, BROWSE_STUB)
|
|
|
const response = await api.host.pickDirectory(request({}), new AbortController().signal)
|
|
|
expect(response.result).toMatchObject({
|
|
|
@@ -190,14 +190,14 @@ describe('host.listDirectory / host.createDirectory', () => {
|
|
|
})
|
|
|
})
|
|
|
|
|
|
- it('refuses the browse RPCs under a dialog composition and advertises the kind in describe', async () => {
|
|
|
+ it('refuses the browse RPCs under a native composition and advertises the kind in describe', async () => {
|
|
|
const { api } = await harness()
|
|
|
- expect((await api.host.describe(request({}))).result).toMatchObject({ ok: true, value: { directoryPicker: 'dialog' } })
|
|
|
+ expect((await api.host.describe(request({}))).result).toMatchObject({ ok: true, value: { directoryPicker: 'native' } })
|
|
|
expect((await api.host.listDirectory(request({}))).result).toMatchObject({
|
|
|
- ok: false, error: { code: 'directory-picker-unavailable', details: { capability: 'dialog' } },
|
|
|
+ ok: false, error: { code: 'directory-picker-unavailable', details: { capability: 'native' } },
|
|
|
})
|
|
|
expect((await api.host.createDirectory(request({ path: '/x', name: 'y' }))).result).toMatchObject({
|
|
|
- ok: false, error: { code: 'directory-picker-unavailable', details: { capability: 'dialog' } },
|
|
|
+ ok: false, error: { code: 'directory-picker-unavailable', details: { capability: 'native' } },
|
|
|
})
|
|
|
const browse = await harness(undefined, BROWSE_STUB)
|
|
|
expect((await browse.api.host.describe(request({}))).result).toMatchObject({ ok: true, value: { directoryPicker: 'browse' } })
|