Skip to content

Commit fa0cde5

Browse files
test(permissions): lock the declared error tag as FetchError.code
1 parent 041ca20 commit fa0cde5

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎frontend/src/api/opencode.test.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,21 @@ describe('OpenCode facade', () => {
392392
expect((failure as FetchError).message).toBe('Session not found')
393393
})
394394

395+
it('preserves the declared error tag as FetchError.code', async () => {
396+
fetchMock.mockResolvedValue(
397+
new Response(
398+
JSON.stringify({ _tag: 'PermissionNotFoundError', sessionID: 'ses_1', requestID: 'per_1', message: 'Permission request not found' }),
399+
{ status: 404, headers: { 'Content-Type': 'application/json' } },
400+
),
401+
)
402+
403+
const failure = await replyPermission('ses_1', 'per_1', 'once').catch((error: unknown) => error)
404+
405+
expect(failure).toBeInstanceOf(FetchError)
406+
expect((failure as FetchError).statusCode).toBe(404)
407+
expect((failure as FetchError).code).toBe('PermissionNotFoundError')
408+
})
409+
395410
it('maps a declared V2 conflict error to 409', async () => {
396411
fetchMock.mockResolvedValue(
397412
new Response(

0 commit comments

Comments
 (0)