[codex] proxy provider model fetches (#777)

* proxy provider model fetches

* add provider model proxy e2e
This commit is contained in:
ekko
2026-05-16 08:57:00 +08:00
committed by GitHub
parent d066806d86
commit 07257a8964
6 changed files with 120 additions and 12 deletions
+5
View File
@@ -143,6 +143,11 @@ export async function mockHermesApi(page: Page, options: MockHermesApiOptions =
return
}
if (pathname === '/api/hermes/provider-models') {
await route.fulfill(jsonResponse({ models: ['proxy-model-a', 'proxy-model-b'] }))
return
}
if (pathname === '/api/hermes/profiles') {
await route.fulfill(jsonResponse({
profiles: [
+37
View File
@@ -0,0 +1,37 @@
import { expect, test } from '@playwright/test'
import { authenticate, mockHermesApi, TEST_ACCESS_KEY } from './fixtures'
test('fetches custom provider models through the backend proxy', async ({ page }) => {
await authenticate(page, TEST_ACCESS_KEY)
const api = await mockHermesApi(page)
const thirdPartyRequests: string[] = []
page.on('request', (request) => {
const url = request.url()
if (url.startsWith('https://provider.example.test')) {
thirdPartyRequests.push(url)
}
})
await page.goto('/#/hermes/models')
await page.getByRole('button', { name: 'Add Provider' }).click()
await page.getByRole('button', { name: 'Custom' }).click()
await page.getByPlaceholder('e.g. https://api.example.com/v1').fill('https://provider.example.test/v1')
await page.getByPlaceholder('sk-...').fill('test-provider-key')
await page.getByRole('button', { name: 'Fetch' }).click()
await expect(page.getByText('Found 2 models')).toBeVisible()
await expect(page.getByText('proxy-model-a')).toBeVisible()
const proxyRequest = api.requests.find((request) => request.pathname === '/api/hermes/provider-models')
expect(proxyRequest).toBeTruthy()
expect(proxyRequest?.method).toBe('POST')
expect(proxyRequest?.headers.authorization).toBe(`Bearer ${TEST_ACCESS_KEY}`)
expect(JSON.parse(proxyRequest?.postData || '{}')).toMatchObject({
base_url: 'https://provider.example.test/v1',
api_key: 'test-provider-key',
})
expect(thirdPartyRequests).toEqual([])
expect(api.unexpectedRequests).toEqual([])
})