refactor: improve network error and allow verbose output (#36923)

This commit is contained in:
Yunlu Wen authored and GitHub committed 2026-06-02 10:43:40 +00:00
1 parent b682591c7a
commit f19679b217
28 files changed
+339 -231

No files matched your search

+3 -3
View File
@@ -2,7 +2,7 @@ import type { StubServer } from '@test/fixtures/stub-server'
import { testHttpClient } from '@test/fixtures/http-client'
import { jsonResponder, startStubServer } from '@test/fixtures/stub-server'
import { afterEach, describe, expect, it } from 'vitest'
import { isBaseError } from '@/errors/base'
import { isHttpClientError } from '@/errors/base'
import { WorkspacesClient } from './workspaces.js'
// WorkspacesClient.switch is covered in members.test.ts; this file covers list().
@@ -30,14 +30,14 @@ describe('WorkspacesClient.list', () => {
expect(stub.captured.method).toBe('GET')
expect(stub.captured.url).toBe('/openapi/v1/workspaces')
expect(res.workspaces[0].id).toBe('ws-1')
expect(res.workspaces[0]?.id).toBe('ws-1')
})
it('maps 401 to a classified BaseError', async () => {
stub = await startStubServer(cap => jsonResponder(401, { error: 'expired' }, cap))
await expect(makeClient(stub.url).list()).rejects.toSatisfy(
err => isBaseError(err) && err.httpStatus === 401,
err => isHttpClientError(err) && err.httpStatus === 401,
)
})
})