Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(e2e): match the API paths the browser actually requests
Alfredo Lopeze553a93633ef
diff --git a/tests/e2e/playwright/desktop/codex-subscription-approved-tools.spec.ts b/tests/e2e/playwright/desktop/codex-subscription-approved-tools.spec.tsindex 75ef2fdb0..a33440af8 100644--- a/tests/e2e/playwright/desktop/codex-subscription-approved-tools.spec.ts+++ b/tests/e2e/playwright/desktop/codex-subscription-approved-tools.spec.ts@@ -13,6 +13,7 @@ import { type Page, expect, test } from '@playwright/test'import {type Scenario,type UpstreamEvidence,+ browserApiPath,localUrl,readEvidence,readUpstreamEvidence,@@ -47,7 +48,8 @@ if (process.env.PLAYWRIGHT_DESKTOP_BUILT !== 'true')async function saveConnector(page: Page, scenario: Scenario, remove: boolean) {const response = page.waitForResponse(response =>- new URL(response.url()).pathname === `/api/v1/admin/contexts/${scenario.contextName}` &&+ new URL(response.url()).pathname ===+ browserApiPath(`/api/v1/admin/contexts/${scenario.contextName}`) &&response.request().method() === 'PUT')if (remove) {@@ -448,7 +450,7 @@ for (const scenario of cases) {const persistedDetail = page.waitForResponse(response =>new URL(response.url()).pathname ===- `/api/v1/admin/hosts/${scenario.agentName}/detail` &&+ browserApiPath(`/api/v1/admin/hosts/${scenario.agentName}/detail`) &&response.request().method() === 'GET')await new AgentListPage(page).openNamed(scenario.agentName)diff --git a/tests/e2e/playwright/helpers/approved-tools-scenarios.ts b/tests/e2e/playwright/helpers/approved-tools-scenarios.tsindex d84905006..20a393387 100644--- a/tests/e2e/playwright/helpers/approved-tools-scenarios.ts+++ b/tests/e2e/playwright/helpers/approved-tools-scenarios.ts@@ -1,5 +1,29 @@// E2E_GUARDIAN_IPC_FLOW: configuration and read-only fixture evidence only.export const catalogSizes = [83, 150, 250] as const++/**+ * The Control UI does not call control-api directly from the browser: every+ * request goes through its own Next.js proxy route, so `control-ui/lib/api.ts`+ * prepends `API_BASE`, which defaults to `/control-api` and is only overridden+ * by `NEXT_PUBLIC_CONTROL_API_BASE_URL`, which this deployment does not set.+ * A `page.waitForResponse` predicate therefore sees `/control-api/api/v1/...`+ * in `response.url()`, never the bare control-api path.+ *+ * That mismatch does not surface as a failed assertion but as a waiter that+ * never resolves, which reports as a timeout while the product flow succeeds —+ * the most expensive failure shape to read. Routing every browser-side matcher+ * through this helper keeps the prefix in one place.+ *+ * Direct HTTP callers (`helpers/api-client.ts`, `global-setup.ts`) talk to+ * control-api itself and correctly stay unprefixed; they must not use this.+ */+export const CONTROL_UI_API_PREFIX = '/control-api'++export function browserApiPath(path: string): string {+ if (!path.startsWith('/api/'))+ throw new Error(`browserApiPath expects a control-api path starting with /api/, got: ${path}`)+ return `${CONTROL_UI_API_PREFIX}${path}`+}export type Scenario = {catalogSize: numberrunId: stringdiff --git a/tests/e2e/playwright/helpers/approved-tools-subscription.ts b/tests/e2e/playwright/helpers/approved-tools-subscription.tsindex 9369e127e..7b2b6f704 100644--- a/tests/e2e/playwright/helpers/approved-tools-subscription.ts+++ b/tests/e2e/playwright/helpers/approved-tools-subscription.ts@@ -7,13 +7,22 @@import { type Page, type Route, expect } from '@playwright/test'import { beginConnectionCapture } from '../../../../scripts/e2e/approved-tools-connection-journal.mjs'import { ControlUiShell, SecretsLlmSubscriptionsPage } from '../pages/codex-subscription'-import { type Scenario, required } from './approved-tools-scenarios'+import {+ CONTROL_UI_API_PREFIX,+ type Scenario,+ browserApiPath,+ required,+} from './approved-tools-scenarios'const verificationUrl = 'https://auth.openai.com/codex/device'const devicePath = (connectionKey: string, step: 'start' | 'poll') =>- `/api/v1/admin/llm/providers/codex-subscription/connections/${connectionKey}/device/${step}`+ browserApiPath(+ `/api/v1/admin/llm/providers/codex-subscription/connections/${connectionKey}/device/${step}`+ )const anyDevicePath = (step: 'start' | 'poll') =>- new RegExp(`^/api/v1/admin/llm/providers/codex-subscription/connections/[^/]+/device/${step}$`)+ new RegExp(+ `^${CONTROL_UI_API_PREFIX}/api/v1/admin/llm/providers/codex-subscription/connections/[^/]+/device/${step}$`+ )export async function prepareSubscriptionVisible(page: Page, scenario: Scenario): Promise<string> {if (required('APPROVED_TOOLS_UPSTREAM_MODE') === 'real') {diff --git a/tests/e2e/playwright/helpers/approved-tools-workflow.ts b/tests/e2e/playwright/helpers/approved-tools-workflow.tsindex afec4c469..62ac0a01b 100644--- a/tests/e2e/playwright/helpers/approved-tools-workflow.ts+++ b/tests/e2e/playwright/helpers/approved-tools-workflow.ts@@ -8,6 +8,7 @@ import { type Page, type TestInfo, expect, test } from '@playwright/test'import { AgentListPage, AgentModelPage, ControlUiShell } from '../pages/codex-subscription'import {type Scenario,+ browserApiPath,localUrl,readEvidence,readUpstreamEvidence,@@ -106,7 +107,8 @@ export async function workflowJourney(page: Page, testInfo: TestInfo) {await advanced.getByRole('button', { name: 'Add', exact: true }).click()const update = page.waitForResponse(response =>- new URL(response.url()).pathname === `/api/v1/admin/hosts/${scenario.agentName}` &&+ new URL(response.url()).pathname ===+ browserApiPath(`/api/v1/admin/hosts/${scenario.agentName}`) &&response.request().method() === 'PUT')await advanced.getByRole('button', { name: 'Save', exact: true }).click()diff --git a/tests/e2e/playwright/package-lock.json b/tests/e2e/playwright/package-lock.jsonindex 3f82ffd68..66506b733 100644--- a/tests/e2e/playwright/package-lock.json+++ b/tests/e2e/playwright/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-playwright-tests",- "version": "0.1.54",+ "version": "0.1.55","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-playwright-tests",- "version": "0.1.54",+ "version": "0.1.55","devDependencies": {"@playwright/test": "^1.50.0","@types/node": "^22.0.0",diff --git a/tests/e2e/playwright/package.json b/tests/e2e/playwright/package.jsonindex f83674c1e..cc0f1f065 100644--- a/tests/e2e/playwright/package.json+++ b/tests/e2e/playwright/package.json@@ -1,6 +1,6 @@{"name": "clerum-playwright-tests",- "version": "0.1.54",+ "version": "0.1.55","private": true,"description": "Playwright E2E tests for Control UI and Desktop App","scripts": {