fix(frontend): list provider integrations in settings

This commit is contained in:
Wesley Tanner authored and GitHub committed 2026-10-29 13:04:20 +00:00
1 parent c8647c1eec
commit 024b3d969f
9 files changed
+211 -46

No files matched your search

+35
View File
@@ -126,6 +126,41 @@ describe('oauth routes /auth-methods', () => {
})
})
describe('oauth routes /integrations', () => {
it('returns every integration with its methods and connections', async () => {
const client = createStubOpenCodeClient()
const integrations = [
integrationFixture({
id: 'openrouter',
name: 'OpenRouter',
methods: [{ type: 'key' }],
}),
integrationFixture({
id: 'anthropic',
name: 'Anthropic',
methods: [{ type: 'key' }, { type: 'env', names: ['ANTHROPIC_API_KEY'] }],
connections: [{ type: 'credential', id: 'cred_1', label: 'Anthropic', method: 'key' }],
}),
]
vi.mocked(client.api.integration.list).mockResolvedValueOnce({ location: LOCATION, data: integrations })
const res = await createOAuthApp(client).request('/oauth/integrations')
expect(res.status).toBe(200)
expect(await res.json()).toEqual({ integrations })
})
it('returns 502 when the upstream is unreachable', async () => {
const client = createStubOpenCodeClient()
vi.mocked(client.api.integration.list).mockRejectedValueOnce(new ClientError('UnexpectedStatus'))
const res = await createOAuthApp(client).request('/oauth/integrations')
expect(res.status).toBe(502)
expect(await res.json()).toEqual({ error: 'Failed to list provider integrations', code: 'ClientError' })
})
})
describe('oauth routes /:id/oauth/authorize', () => {
it('starts the V2 attempt with the method and answer and returns it', async () => {
const client = createStubOpenCodeClient()
+9
View File
@@ -23,6 +23,15 @@ export function createOAuthRoutes(openCodeClient: OpenCodeClient) {
}
})
app.get('/integrations', async (c) => {
try {
const integrations = await openCodeClient.api.integration.list()
return c.json({ integrations: integrations.data })
} catch (error) {
return handleOpenCodeError(c, error, 'Failed to list provider integrations')
}
})
app.post('/:id/oauth/authorize', async (c) => {
try {
const body = await c.req.json()