Parcourir la source

test(apiproxy): round-trip every agent-preset method through the carrier

The domain's five registrations were unexercised on both halves of the
carrier, so a method missing from `handler.ts` or `client.ts` would have
surfaced in the browser rather than here. `read`/`write`/`remove` widened
the gap; this closes it for the whole domain.
Yichen Jiang il y a 2 mois
Parent
commit
3a60d97d21
1 fichiers modifiés avec 20 ajouts et 0 suppressions
  1. 20 0
      packages/host/apiproxy/tests/fetch-carrier.spec.ts

+ 20 - 0
packages/host/apiproxy/tests/fetch-carrier.spec.ts

@@ -359,6 +359,26 @@ describe('unary round trip (handler ⇄ client, no network)', () => {
     expect((await c.host.describe({})).result.ok).toBe(true)
     expect((await c.host.describe({})).result.ok).toBe(true)
   })
   })
 
 
+  it('round-trips every agent-preset method, authoring included', async () => {
+    const c = client()
+
+    // The whole domain crosses the carrier: the roster a picker reads, the
+    // per-session switch, and the three authoring calls the settings editor
+    // makes. Each has its own request schema, so a registration missing from
+    // either half fails here rather than in the browser.
+    expect((await c.agentPresets.list({})).result).toEqual({
+      ok: true, value: { presets: [], authorable: false },
+    })
+    expect((await c.agentPresets.select({ sessionId: 's' as never, agentPreset: 'core-web' })).result)
+      .toEqual({ ok: true, value: { agentPreset: 'core-web' } })
+    expect((await c.agentPresets.read({ agentPreset: 'mine' })).result).toEqual({
+      ok: true, value: { agentPreset: 'mine', trust: 'user', content: '', writable: true },
+    })
+    expect((await c.agentPresets.write({ agentPreset: 'mine', content: '- id: x\n' })).result)
+      .toEqual({ ok: true, value: { agentPreset: 'mine' } })
+    expect((await c.agentPresets.remove({ agentPreset: 'mine' })).result).toEqual({ ok: true, value: {} })
+  })
+
   it('round-trips the native picker without the default unary timeout', async () => {
   it('round-trips the native picker without the default unary timeout', async () => {
     const api = fakeApi()
     const api = fakeApi()
     api.host.pickDirectory = async (request) => {
     api.host.pickDirectory = async (request) => {