test: finish the Remote-result and picker-split test migrations
Every generated Remote method resolves to `RemoteResult<T>`, so the Gateway client spec asserts the ok and error branches instead of the unwrapped value and a throw, and the generator fixtures declare the wrapper in the consumer face they typecheck. The RPC-failure test splits into the Host error carried verbatim in the error branch plus a transport throw folded into it. The runtime client, ui-command and ui-plan benches answer the generated commands Remote through its result branches and provide the `remote.commands` namespace their plugins now inject; the ui-command bench also serves the `$on` the service subscribes on construction. The directory-picker chooser mounts a backend and its surface as a pair, so the real-Loader composition serves both surface packages and asserts each entry arrives and leaves with its backend.
This commit is contained in:
@@ -26,7 +26,7 @@ async function bench() {
|
||||
children: { 'conversation.input.plan': { kind: 'single', scope: 'session' } },
|
||||
} as never, () => null)
|
||||
const execute = vi.fn((_sessionId: SessionId, _line: string) =>
|
||||
Promise.resolve({ commandId: 'c1', result: { kind: 'success' as const } }))
|
||||
Promise.resolve({ ok: true, value: { commandId: 'c1', result: { kind: 'success' as const } } }))
|
||||
const commandsRemote = { execute }
|
||||
ctx.provide('remote', { commands: commandsRemote })
|
||||
ctx.provide('remote.commands', commandsRemote)
|
||||
@@ -71,14 +71,15 @@ describe('ui-plan browser apply', () => {
|
||||
expect(b.execute).toHaveBeenLastCalledWith(SID, '/plan off')
|
||||
|
||||
// Business failure folds to the composer-visible line: the generated method
|
||||
// throws with the RPC failure as its cause.
|
||||
b.execute.mockRejectedValueOnce(new Error('client api: commands/execute failed', {
|
||||
cause: { code: 'session-not-found', message: 'gone', details: {} },
|
||||
}))
|
||||
// reports the RPC failure in its error branch.
|
||||
b.execute.mockResolvedValueOnce({
|
||||
ok: false,
|
||||
error: { code: 'session-not-found', message: 'gone', details: {} },
|
||||
} as never)
|
||||
await expect(injected.exitPlanMode()).resolves.toBe('gone (session-not-found)')
|
||||
|
||||
// Unmatched admission (plan-mode not composed host-side) is also a failure line.
|
||||
b.execute.mockResolvedValueOnce(undefined as never)
|
||||
b.execute.mockResolvedValueOnce({ ok: true, value: undefined } as never)
|
||||
await expect(injected.exitPlanMode()).resolves.toBe('unknown command: /plan off')
|
||||
|
||||
await fiber.dispose()
|
||||
|
||||
Reference in New Issue
Block a user