Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

feat: tons of e2e tests

Miguelon Peluchon3daf915d8342
diff --git a/control-ui/app/profile-admin/users/[userId]/page.tsx b/control-ui/app/profile-admin/users/[userId]/page.tsx
index 148d1ae0b..8b1fdab5d 100644
--- a/control-ui/app/profile-admin/users/[userId]/page.tsx
+++ b/control-ui/app/profile-admin/users/[userId]/page.tsx
@@ -135,6 +135,16 @@ export default function UserDetailsPage() {
const [roleEditDraft, setRoleEditDraft] = useState<TeamRole>('member')
const existingTeamIds = useMemo(() => new Set(userTeams.map(team => team.id)), [userTeams])
+ // Label resolution must be declared before its first consumer
+ // (`availableContextOptions` below) — accessing it earlier throws a TDZ
+ // ReferenceError that takes the whole member page down.
+ const accessLabeler = useMemo(
+ () => accessScopeLabeler(contextResources, hosts || []),
+ [contextResources, hosts]
+ )
+ function accessLabelFor(contextId: string): { label: string; resolved: boolean } {
+ return accessLabeler(contextId)
+ }
const hostNameOptions = useMemo(
() =>
Array.from(
@@ -218,17 +228,6 @@ export default function UserDetailsPage() {
return String(item.spec?.contextId || item.metadata?.name || '').trim()
}
- // Rows are context IDs on the wire, but the user sees what that access
- // means: the owning agent(s) for private scopes, the stored display name
- // for anything else, and the raw id as a last-resort muted fallback.
- const accessLabeler = useMemo(
- () => accessScopeLabeler(contextResources, hosts || []),
- [contextResources, hosts]
- )
- function accessLabelFor(contextId: string): { label: string; resolved: boolean } {
- return accessLabeler(contextId)
- }
-
async function loadData() {
setBusy(true)
setError('')
diff --git a/control-ui/e2e/qa-recorder-agent-connectors-conflict.spec.ts b/control-ui/e2e/qa-recorder-agent-connectors-conflict.spec.ts
index 53a383ecf..44507aed0 100644
--- a/control-ui/e2e/qa-recorder-agent-connectors-conflict.spec.ts
+++ b/control-ui/e2e/qa-recorder-agent-connectors-conflict.spec.ts
@@ -96,7 +96,6 @@ test.describe('optional QA recorder: Control UI agent connectors conflict', () =
contextRef: contextName,
secretRef: '',
channels: [],
- model: { provider: 'openai', name: 'gpt-5.4-mini' },
},
})
expect(hostRes.status, `create host: ${JSON.stringify(hostRes.data)}`).toBeLessThan(300)
diff --git a/control-ui/e2e/qa-recorder-agent-connectors.spec.ts b/control-ui/e2e/qa-recorder-agent-connectors.spec.ts
index 0e5dce2f2..238b1a8c4 100644
--- a/control-ui/e2e/qa-recorder-agent-connectors.spec.ts
+++ b/control-ui/e2e/qa-recorder-agent-connectors.spec.ts
@@ -86,7 +86,6 @@ test.describe('optional QA recorder: Control UI agent connectors', () => {
contextRef: contextName,
secretRef: '',
channels: [],
- model: { provider: 'openai', name: 'gpt-5.4-mini' },
},
})
expect(hostRes.status, `create host: ${JSON.stringify(hostRes.data)}`).toBeLessThan(300)
diff --git a/control-ui/e2e/qa-recorder-connector-create-access.spec.ts b/control-ui/e2e/qa-recorder-connector-create-access.spec.ts
index cad1e9f68..dcc364e4e 100644
--- a/control-ui/e2e/qa-recorder-connector-create-access.spec.ts
+++ b/control-ui/e2e/qa-recorder-connector-create-access.spec.ts
@@ -36,7 +36,9 @@ async function continueWizard(page: Page): Promise<void> {
async function openCreateConnectorWizard(page: Page): Promise<void> {
await page.getByRole('link', { name: 'Installed Connectors', exact: true }).click()
await expect(page).toHaveURL(/\/connectors$/, { timeout: 20_000 })
- await page.getByRole('button', { name: 'Create Connector', exact: true }).click()
+ // Creation lives behind the "Connector actions" kebab (lowercase c menuitem).
+ await page.getByRole('button', { name: 'Connector actions' }).click()
+ await page.getByRole('menuitem', { name: 'Create connector', exact: true }).click()
await expect(page).toHaveURL(/\/connectors\/new$/, { timeout: 20_000 })
}
@@ -102,10 +104,12 @@ async function createConnectorThroughWizard(
}
async function expandConnector(page: Page, connectorName: string) {
- const row = page.getByRole('row', { name: new RegExp(connectorName) })
+ const row = page.getByRole('button', { name: new RegExp(`Expand connector ${connectorName}`) })
await expect(row).toBeVisible({ timeout: 20_000 })
await row.click()
- await expect(row).toHaveAttribute('aria-expanded', 'true', { timeout: 10_000 })
+ await expect(
+ page.getByRole('button', { name: new RegExp(`Collapse connector ${connectorName}`) })
+ ).toBeVisible({ timeout: 10_000 })
const detail = page.locator('.cu-connector-detail')
await expect(detail).toBeVisible({ timeout: 10_000 })
return detail
@@ -153,7 +157,6 @@ test.describe('optional QA recorder: Control UI connector create Access step', (
contextRef: contextName,
secretRef: '',
channels: [],
- model: { provider: 'openai', name: 'gpt-5.4-mini' },
},
})
expect(hostRes.status, `create host: ${JSON.stringify(hostRes.data)}`).toBeLessThan(300)
diff --git a/control-ui/e2e/qa-recorder-connector-edit.spec.ts b/control-ui/e2e/qa-recorder-connector-edit.spec.ts
index 7f470b3a9..69637c878 100644
--- a/control-ui/e2e/qa-recorder-connector-edit.spec.ts
+++ b/control-ui/e2e/qa-recorder-connector-edit.spec.ts
@@ -49,7 +49,9 @@ async function createEmptyContext(page: Page, contextName: string): Promise<void
async function createDiscoveryConnector(page: Page, connectorName: string): Promise<void> {
await page.getByRole('link', { name: 'Installed Connectors', exact: true }).click()
await expect(page).toHaveURL(/\/connectors$/, { timeout: 20_000 })
- await page.getByRole('button', { name: 'Create Connector', exact: true }).click()
+ // Creation lives behind the "Connector actions" kebab (lowercase c menuitem).
+ await page.getByRole('button', { name: 'Connector actions' }).click()
+ await page.getByRole('menuitem', { name: 'Create connector', exact: true }).click()
await expect(page).toHaveURL(/\/connectors\/new$/, { timeout: 20_000 })
await page.getByPlaceholder('my-mcp-server').fill(connectorName)
@@ -136,7 +138,7 @@ test.describe('optional QA recorder: Control UI connector edit', () => {
await expect(page.getByRole('heading', { name: 'Agent access', exact: true })).toBeVisible({
timeout: 20_000,
})
- await expect(page.getByLabel('Agent access')).toBeVisible()
+ await expect(page.locator('.cu-entity-access')).toBeVisible()
// Legacy deep link: the removed Context tab's /edit/context URL must
// permanently redirect to the Access tab (next.config.js rewrite) so
@@ -276,7 +278,7 @@ test.describe('optional QA recorder: Control UI connector edit', () => {
// on the Credentials tab — navigate there via the tab link.
await page.getByRole('tab', { name: 'Credentials', exact: true }).click()
await expect(page).toHaveURL(
- new RegExp(`/connectors/${encodeURIComponent(connectorName)}/edit/credentials$`),
+ new RegExp(`/connectors/${encodeURIComponent(connectorName)}/edit(/credentials)?$`),
{ timeout: 20_000 }
)
diff --git a/control-ui/e2e/qa-recorder-connectors-agent-access.spec.ts b/control-ui/e2e/qa-recorder-connectors-agent-access.spec.ts
index 088088274..0358d21ce 100644
--- a/control-ui/e2e/qa-recorder-connectors-agent-access.spec.ts
+++ b/control-ui/e2e/qa-recorder-connectors-agent-access.spec.ts
@@ -51,7 +51,6 @@ test.describe('optional QA recorder: Control UI connectors agent access', () =>
contextRef,
secretRef: '',
channels: [],
- model: { provider: 'openai', name: 'gpt-5.4-mini' },
},
})
expect(res.status, `create host: ${JSON.stringify(res.data)}`).toBeLessThan(300)
@@ -113,10 +112,13 @@ test.describe('optional QA recorder: Control UI connectors agent access', () =>
).toBeVisible({ timeout: 20_000 })
const expandConnector = async () => {
- const row = page.getByRole('row', { name: new RegExp(serverName) })
+ const row = page.getByRole('button', { name: new RegExp(`Expand connector ${serverName}`) })
await expect(row).toBeVisible({ timeout: 20_000 })
await row.click()
- await expect(row).toHaveAttribute('aria-expanded', 'true', { timeout: 20_000 })
+ const collapse = page.getByRole('button', {
+ name: new RegExp(`Collapse connector ${serverName}`),
+ })
+ await expect(collapse).toBeVisible({ timeout: 20_000 })
const detail = page.locator('.cu-connector-detail')
await expect(detail).toBeVisible({ timeout: 20_000 })
return detail
diff --git a/control-ui/e2e/qa-recorder-connectors-search-agent.spec.ts b/control-ui/e2e/qa-recorder-connectors-search-agent.spec.ts
index 195cbb974..bb91099d1 100644
--- a/control-ui/e2e/qa-recorder-connectors-search-agent.spec.ts
+++ b/control-ui/e2e/qa-recorder-connectors-search-agent.spec.ts
@@ -81,7 +81,6 @@ test.describe('optional QA recorder: Control UI connectors search by agent', ()
contextRef: contextName,
secretRef: '',
channels: [],
- model: { provider: 'openai', name: 'gpt-5.4-mini' },
},
})
expect(hostRes.status, `create host: ${JSON.stringify(hostRes.data)}`).toBeLessThan(300)
@@ -92,7 +91,7 @@ test.describe('optional QA recorder: Control UI connectors search by agent', ()
page.getByText('Browse connector deployments and agent access.', { exact: true })
).toBeVisible({ timeout: 20_000 })
- const row = page.getByRole('row', { name: new RegExp(serverName) })
+ const row = page.getByRole('button', { name: new RegExp(`Expand connector ${serverName}`) })
await expect(row).toBeVisible({ timeout: 20_000 })
// Typing the agent display name keeps the row: access principals are
diff --git a/control-ui/e2e/qa-recorder-context-redirects.spec.ts b/control-ui/e2e/qa-recorder-context-redirects.spec.ts
index 8909a06ef..04e7bce00 100644
--- a/control-ui/e2e/qa-recorder-context-redirects.spec.ts
+++ b/control-ui/e2e/qa-recorder-context-redirects.spec.ts
@@ -85,7 +85,6 @@ test.describe('optional QA recorder: Control UI context redirects', () => {
contextRef: contextName,
secretRef: '',
channels: [],
- model: { provider: 'openai', name: 'gpt-5.4-mini' },
},
})
expect(hostRes.status, `create host: ${JSON.stringify(hostRes.data)}`).toBeLessThan(300)
diff --git a/control-ui/e2e/qa-recorder-context-vocab-sweep.spec.ts b/control-ui/e2e/qa-recorder-context-vocab-sweep.spec.ts
index 3949788aa..eca3df1ed 100644
--- a/control-ui/e2e/qa-recorder-context-vocab-sweep.spec.ts
+++ b/control-ui/e2e/qa-recorder-context-vocab-sweep.spec.ts
@@ -10,10 +10,12 @@
//
// Approach (one rule): every swept route renders through DashboardLayout's
// <main>, so each page is asserted on its main-content text (body as
-// fallback). The single exception is /plugins, whose table rows show
-// user-authored recipe names we do not control — for that page only, the
-// assertion is scoped to product-owned static chrome (sidebar, panel
-// subtitles, headings), which cannot be polluted by data-derived names.
+// fallback). The exceptions are routes whose tables show data-derived text we
+// do not control — /plugins (user-authored recipe names), /connectors, and
+// /marketplace/connectors (deployed connector and marketplace package
+// names/descriptions). For those routes only, the assertion is scoped to
+// product-owned static chrome (sidebar, panel subtitles, headings), which
+// cannot be polluted by data-derived names.
//
// Lines containing "context window" (legitimate LLM copy) are allowed.
import { type Page, expect, test } from '@playwright/test'
@@ -39,7 +41,7 @@ const SWEPT_ROUTES = {
plugins: '/plugins',
} as const
-// Product-owned chrome for the /plugins exception (see header comment).
+// Product-owned chrome for the static-chrome exceptions (see header comment).
const STATIC_CHROME_SELECTOR = '.cu-sidebar, .cu-table-panel__subtitle, h1, h2, h3'
function offendingLines(text: string): string[] {
@@ -56,6 +58,16 @@ async function mainText(page: Page): Promise<string> {
return page.locator('body').innerText()
}
+async function chromeText(page: Page): Promise<string> {
+ const chrome = page.locator(STATIC_CHROME_SELECTOR)
+ const count = await chrome.count()
+ const texts: string[] = []
+ for (let i = 0; i < count; i += 1) {
+ texts.push(await chrome.nth(i).innerText())
+ }
+ return texts.join('\n')
+}
+
function screenshotName(route: string): string {
return `control-ui-context-vocab-sweep${route.replace(/\//g, '-')}`
}
@@ -70,10 +82,10 @@ test.describe('optional QA recorder: Control UI context vocabulary sweep', () =>
const mainNav = page.getByRole('navigation', { name: 'Main sections' })
- async function recordAndSweep(route: string): Promise<void> {
+ async function recordAndSweep(route: string, chromeOnly = false): Promise<void> {
await expect(page.locator('main').first()).toBeVisible({ timeout: 20_000 })
await screenshotAndLog(page, testInfo, screenshotName(route))
- const text = await mainText(page)
+ const text = chromeOnly ? await chromeText(page) : await mainText(page)
const offending = offendingLines(text)
expect(
offending,
@@ -89,13 +101,14 @@ test.describe('optional QA recorder: Control UI context vocabulary sweep', () =>
).toBeVisible({ timeout: 20_000 })
await recordAndSweep(SWEPT_ROUTES.agents)
- // /connectors
+ // /connectors — rows show data-derived connector names/descriptions, so
+ // the sweep is scoped to product-owned static chrome.
await mainNav.getByRole('link', { name: 'Installed Connectors', exact: true }).click()
await expect(page).toHaveURL(/\/connectors\/?$/, { timeout: 20_000 })
await expect(
page.getByText('Browse connector deployments and agent access.', { exact: true })
).toBeVisible({ timeout: 20_000 })
- await recordAndSweep(SWEPT_ROUTES.connectors)
+ await recordAndSweep(SWEPT_ROUTES.connectors, true)
// /users-and-teams/users
await mainNav.getByRole('link', { name: 'Users & Teams', exact: true }).click()
@@ -115,13 +128,14 @@ test.describe('optional QA recorder: Control UI context vocabulary sweep', () =>
await expect(page).toHaveURL(/\/users-and-teams\/teams$/, { timeout: 20_000 })
await recordAndSweep(SWEPT_ROUTES.teams)
- // /marketplace/connectors
+ // /marketplace/connectors — package cards show marketplace-authored
+ // names/descriptions, so the sweep is scoped to static chrome too.
await mainNav.getByRole('link', { name: 'Marketplace', exact: true }).click()
await expect(page).toHaveURL(/\/marketplace\/connectors$/, { timeout: 20_000 })
await expect(
page.getByText('Discover and install connectors from the Marketplace.')
).toBeVisible({ timeout: 20_000 })
- await recordAndSweep(SWEPT_ROUTES.marketplace)
+ await recordAndSweep(SWEPT_ROUTES.marketplace, true)
// /agent-files — hidden from the sidebar (the Files group's children do
// not include it), so reach it the way a bookmarked link would.
@@ -153,14 +167,7 @@ test.describe('optional QA recorder: Control UI context vocabulary sweep', () =>
await expect(page.locator('.cu-panel-title').first()).toBeVisible({ timeout: 20_000 })
await screenshotAndLog(page, testInfo, screenshotName(SWEPT_ROUTES.plugins))
- const chrome = page.locator(STATIC_CHROME_SELECTOR)
- const count = await chrome.count()
- const texts: string[] = []
- for (let i = 0; i < count; i += 1) {
- texts.push(await chrome.nth(i).innerText())
- }
-
- const chromeOffending = offendingLines(texts.join('\n'))
+ const chromeOffending = offendingLines(await chromeText(page))
expect(
chromeOffending,
`"${SWEPT_ROUTES.plugins}" chrome must not use context vocabulary; offending lines: ${chromeOffending.join(' | ')}`
diff --git a/control-ui/e2e/qa-recorder-marketplace-install.spec.ts b/control-ui/e2e/qa-recorder-marketplace-install.spec.ts
index ed2417f51..1a2d01db8 100644
--- a/control-ui/e2e/qa-recorder-marketplace-install.spec.ts
+++ b/control-ui/e2e/qa-recorder-marketplace-install.spec.ts
@@ -78,7 +78,6 @@ test.describe('optional QA recorder: Control UI marketplace install', () => {
contextRef: contextName,
secretRef: '',
channels: [],
- model: { provider: 'openai', name: 'gpt-5.4-mini' },
},
})
expect(hostRes.status, `create host: ${JSON.stringify(hostRes.data)}`).toBeLessThan(300)
@@ -198,10 +197,12 @@ test.describe('optional QA recorder: Control UI marketplace install', () => {
await expect(page).toHaveURL(/\/connectors$/, { timeout: 20_000 })
// The fresh install has no agents yet.
- const row = page.getByRole('row', { name: new RegExp(serverName) })
+ const row = page.getByRole('button', { name: new RegExp(`Expand connector ${serverName}`) })
await expect(row).toBeVisible({ timeout: 30_000 })
await row.click()
- await expect(row).toHaveAttribute('aria-expanded', 'true', { timeout: 10_000 })
+ await expect(
+ page.getByRole('button', { name: new RegExp(`Collapse connector ${serverName}`) })
+ ).toBeVisible({ timeout: 10_000 })
const detail = page.locator('.cu-connector-detail')
await expect(detail).toBeVisible({ timeout: 10_000 })
await expect(detail.getByText('No agents have access yet.', { exact: true })).toBeVisible()
diff --git a/control-ui/e2e/qa-recorder-member-access-multi.spec.ts b/control-ui/e2e/qa-recorder-member-access-multi.spec.ts
new file mode 100644
index 000000000..9a30a6526
--- /dev/null
+++ b/control-ui/e2e/qa-recorder-member-access-multi.spec.ts
@@ -0,0 +1,206 @@
+// control-ui/e2e/qa-recorder-member-access-multi.spec.ts
+//
+// Optional QA recorder journey (MUTATING). Requires QA_RECORDER_CONFIRM_MUTATIONS=1.
+// Records the member detail Access tab multi-select add flow: two host-backed
+// scopes are seeded out-of-band (one context + one host each), then the
+// "Add access" picker selects BOTH agent display names at once and submits —
+// toast "Access updated." — and both rows render with the agent display names
+// (never the raw contextIds). Each row is then removed through its confirm
+// dialog. The member's original contextIds are restored and the seeded hosts
+// + contexts are deleted in the finally (hosts before contexts).
+//
+// Contract: docs/testing/optional-playwright-qa-recorder.md ("Extending the
+// recorder").
+import { expect, test } from '@playwright/test'
+import {
+ CONTROL_API_URL,
+ CONTROL_UI_URL,
+ adminCredentials,
+ api,
+ assertAllowedTarget,
+ loginThroughUi,
+ requireRecorderConfirm,
+ screenshotAndLog,
+ uniqueE2EName,
+} from './qa-recorder-helpers'
+
+test.describe('optional QA recorder: Control UI member Access multi-select', () => {
+ test('records adding and removing two member access scopes in one picker submit', async ({
+ page,
+ }, testInfo) => {
+ requireRecorderConfirm(
+ 'QA_RECORDER_CONFIRM_MUTATIONS',
+ 'This journey grants and removes member access and seeds/deletes two hosts and contexts.'
+ )
+ assertAllowedTarget('CONTROL_UI_URL', CONTROL_UI_URL)
+ assertAllowedTarget('CONTROL_API_URL', CONTROL_API_URL)
+
+ const credentials = adminCredentials()
+ const journey = 'control-ui-member-access-multi'
+ const contextNameA = uniqueE2EName('qa-recorder-mam-ctx-a')
+ const contextIdA = uniqueE2EName('qa-recorder-mam-scope-a')
+ const contextNameB = uniqueE2EName('qa-recorder-mam-ctx-b')
+ const contextIdB = uniqueE2EName('qa-recorder-mam-scope-b')
+ const hostNameA = uniqueE2EName('qa-recorder-mam-host-a')
+ const hostNameB = uniqueE2EName('qa-recorder-mam-host-b')
+ const hostDisplayA = uniqueE2EName('qa-recorder-mam-agent-a')
+ const hostDisplayB = uniqueE2EName('qa-recorder-mam-agent-b')
+ let userId = ''
+ let originalContextIds: string[] | null = null
+
+ try {
+ await loginThroughUi(page, credentials)
+
+ // Member detail — open the first user row from the directory.
+ const usersRes = await api<{ items?: Array<{ id: string }> }>(
+ page.request,
+ 'GET',
+ '/api/v1/admin/users'
+ )
+ expect(usersRes.status, `list users: ${JSON.stringify(usersRes.data)}`).toBe(200)
+ test.skip(
+ (usersRes.data.items ?? []).length === 0,
+ 'No users seeded in this environment; skipping member access multi journey.'
+ )
+
+ await page.goto(`${CONTROL_UI_URL}/users-and-teams/users`)
+ const firstMemberRow = page.locator('tr[aria-label^="Open member "]').first()
+ await expect(firstMemberRow).toBeVisible({ timeout: 20_000 })
+ await firstMemberRow.click()
+ await expect(page).toHaveURL(/\/users-and-teams\/users\/[^/]+/, { timeout: 20_000 })
+ const match = page.url().match(/\/users-and-teams\/users\/([^/?#]+)/)
+ userId = decodeURIComponent(match?.[1] || '')
+ expect(userId, 'member id from detail URL').toBeTruthy()
+
+ const memberTabs = page.getByRole('tablist', { name: 'Member sections' })
+ await expect(memberTabs).toBeVisible({ timeout: 20_000 })
+ const accessTab = memberTabs.getByRole('tab', { name: 'Access', exact: true })
+ await expect(accessTab).toBeVisible()
+ await accessTab.click()
+ await expect(page).toHaveURL(/\/users-and-teams\/users\/[^/]+\/access$/, {
+ timeout: 20_000,
+ })
+ await expect(
+ page.getByText('Agents and connector scopes this member may access.', { exact: true })
+ ).toBeVisible({ timeout: 20_000 })
+ await screenshotAndLog(page, testInfo, `${journey}-tab`)
+
+ // Remember the member's original contextIds before any mutation.
+ const originalRes = await api<{ contextIds?: string[] }>(
+ page.request,
+ 'GET',
+ `/api/v1/admin/users/${encodeURIComponent(userId)}/contexts`
+ )
+ expect(
+ originalRes.status,
+ `get user contexts: ${JSON.stringify(originalRes.data)}`
+ ).toBeLessThan(300)
+ originalContextIds = originalRes.data.contextIds ?? []
+
+ // Seed two host-backed scopes out-of-band; the behavior under test is
+ // the picker granting BOTH in a single submit.
+ for (const [contextName, contextId, hostName, hostDisplay] of [
+ [contextNameA, contextIdA, hostNameA, hostDisplayA],
+ [contextNameB, contextIdB, hostNameB, hostDisplayB],
+ ] as const) {
+ const ctxRes = await api(page.request, 'POST', '/api/v1/admin/contexts', {
+ metadata: { name: contextName },
+ spec: {
+ contextId,
+ description: 'QA recorder member access multi scope',
+ mcpServers: [],
+ },
+ })
+ expect(ctxRes.status, `create context: ${JSON.stringify(ctxRes.data)}`).toBeLessThan(300)
+
+ const hostRes = await api(page.request, 'POST', '/api/v1/admin/hosts', {
+ metadata: { name: hostName },
+ spec: {
+ host: hostDisplay,
+ contextRef: contextId,
+ secretRef: '',
+ channels: [],
+ },
+ })
+ expect(hostRes.status, `create host: ${JSON.stringify(hostRes.data)}`).toBeLessThan(300)
+ }
+
+ // Reload the tab so the picker offers the freshly seeded scopes, then
+ // select BOTH agent display names at once and submit.
+ await page.reload()
+ await expect(
+ page.getByText('Agents and connector scopes this member may access.', { exact: true })
+ ).toBeVisible({ timeout: 20_000 })
+
+ await page.getByRole('button', { name: 'Add access', exact: true }).click()
+ const dialog = page.getByRole('dialog', { name: 'Add access' })
+ await expect(dialog).toBeVisible()
+ await expect(dialog.getByLabel('Access')).toBeVisible()
+ const optionA = dialog.getByRole('option', { name: hostDisplayA, exact: true })
+ const optionB = dialog.getByRole('option', { name: hostDisplayB, exact: true })
+ await expect(optionA).toBeVisible({ timeout: 20_000 })
+ await expect(optionB).toBeVisible({ timeout: 20_000 })
+ await optionA.click()
+ await optionB.click()
+ await expect(optionA).toHaveAttribute('aria-selected', 'true')
+ await expect(optionB).toHaveAttribute('aria-selected', 'true')
+ await screenshotAndLog(page, testInfo, `${journey}-add-modal`)
+ await dialog.getByRole('button', { name: 'Add access', exact: true }).click()
+
+ // One toast, both rows — each labelled with its agent display name,
+ // never the raw wire contextId.
+ await expect(
+ page.getByRole('status').filter({ hasText: 'Access updated.' }).first()
+ ).toBeVisible({
+ timeout: 20_000,
+ })
+ const rowA = page
+ .getByRole('row')
+ .filter({ has: page.getByRole('cell', { name: hostDisplayA, exact: true }) })
+ const rowB = page
+ .getByRole('row')
+ .filter({ has: page.getByRole('cell', { name: hostDisplayB, exact: true }) })
+ await expect(rowA).toBeVisible({ timeout: 20_000 })
+ await expect(rowB).toBeVisible({ timeout: 20_000 })
+ await expect(rowA).not.toContainText(contextIdA)
+ await expect(rowB).not.toContainText(contextIdB)
+ await screenshotAndLog(page, testInfo, `${journey}-granted`)
+
+ // Remove both rows: confirm dialog → toast → row gone, one at a time.
+ for (const row of [rowA, rowB]) {
+ await row.getByLabel('Remove access').click()
+ const confirmDialog = page.getByRole('alertdialog', { name: 'Remove Access' })
+ await expect(confirmDialog).toBeVisible()
+ await confirmDialog.getByRole('button', { name: 'Remove access', exact: true }).click()
+ await expect(
+ page.getByRole('status').filter({ hasText: 'Access updated.' }).first()
+ ).toBeVisible({
+ timeout: 20_000,
+ })
+ await expect(row.getByLabel('Remove access')).toHaveCount(0)
+ }
+ await screenshotAndLog(page, testInfo, `${journey}-removed`)
+ } finally {
+ if (userId && originalContextIds !== null) {
+ await api(
+ page.request,
+ 'PUT',
+ `/api/v1/admin/users/${encodeURIComponent(userId)}/contexts`,
+ { contextIds: originalContextIds }
+ )
+ }
+ await api(page.request, 'DELETE', `/api/v1/admin/hosts/${encodeURIComponent(hostNameA)}`)
+ await api(page.request, 'DELETE', `/api/v1/admin/hosts/${encodeURIComponent(hostNameB)}`)
+ await api(
+ page.request,
+ 'DELETE',
+ `/api/v1/admin/contexts/${encodeURIComponent(contextNameA)}`
+ )
+ await api(
+ page.request,
+ 'DELETE',
+ `/api/v1/admin/contexts/${encodeURIComponent(contextNameB)}`
+ )
+ }
+ })
+})
diff --git a/control-ui/e2e/qa-recorder-member-access.spec.ts b/control-ui/e2e/qa-recorder-member-access.spec.ts
index d6b8e1d1b..493c465fb 100644
--- a/control-ui/e2e/qa-recorder-member-access.spec.ts
+++ b/control-ui/e2e/qa-recorder-member-access.spec.ts
@@ -64,7 +64,9 @@ test.describe('optional QA recorder: Control UI member Access tab', () => {
await teamsTab.click()
await expect(page).toHaveURL(/\/users-and-teams\/teams$/, { timeout: 20_000 })
await expect(
- page.locator('table', { hasText: 'Team name' }).getByRole('button', { name: 'Access' })
+ page
+ .locator('table', { hasText: 'Team name' })
+ .getByRole('button', { name: 'Sort by access' })
).toBeVisible({ timeout: 20_000 })
await expect(page.getByRole('columnheader', { name: 'Contexts' })).toHaveCount(0)
await screenshotAndLog(page, testInfo, `${journey}-teams-table`)
@@ -133,7 +135,6 @@ test.describe('optional QA recorder: Control UI member Access tab', () => {
contextRef: contextId,
secretRef: '',
channels: [],
- model: { provider: 'openai', name: 'gpt-5.4-mini' },
},
})
expect(hostRes.status, `create host: ${JSON.stringify(hostRes.data)}`).toBeLessThan(300)
@@ -178,7 +179,7 @@ test.describe('optional QA recorder: Control UI member Access tab', () => {
await expect(page.getByRole('status').filter({ hasText: 'Access updated.' })).toBeVisible({
timeout: 20_000,
})
- await expect(row).toHaveCount(0)
+ await expect(row.getByLabel('Remove access')).toHaveCount(0)
await screenshotAndLog(page, testInfo, `${journey}-removed`)
} finally {
if (userId && originalContextIds !== null) {
diff --git a/control-ui/e2e/qa-recorder-member-removed-access.spec.ts b/control-ui/e2e/qa-recorder-member-removed-access.spec.ts
index 061dc8403..faddec6a9 100644
--- a/control-ui/e2e/qa-recorder-member-removed-access.spec.ts
+++ b/control-ui/e2e/qa-recorder-member-removed-access.spec.ts
@@ -92,7 +92,6 @@ test.describe('optional QA recorder: Control UI member removed access', () => {
contextRef: contextId,
secretRef: '',
channels: [],
- model: { provider: 'openai', name: 'gpt-5.4-mini' },
},
})
expect(hostRes.status, `create host: ${JSON.stringify(hostRes.data)}`).toBeLessThan(300)
diff --git a/control-ui/e2e/qa-recorder-team-access-shared-label.spec.ts b/control-ui/e2e/qa-recorder-team-access-shared-label.spec.ts
new file mode 100644
index 000000000..925786715
--- /dev/null
+++ b/control-ui/e2e/qa-recorder-team-access-shared-label.spec.ts
@@ -0,0 +1,176 @@
+// control-ui/e2e/qa-recorder-team-access-shared-label.spec.ts
+//
+// Optional QA recorder journey (MUTATING). Requires QA_RECORDER_CONFIRM_MUTATIONS=1.
+// Creates a team through the Control API, seeds ONE host-backed access scope
+// shared by TWO hosts, and grants it via PUT /teams/<id>/contexts. The team
+// detail Access tab must render that shared scope as a SINGLE row labelled
+// with both agent display names joined by ", " (lib/accessScopeLabels joins
+// the sorted owner names), never two rows and never the raw contextId.
+// Removal confirms with the joined label in the dialog text and toasts
+// "Team access updated.". The team, hosts, and context are deleted via the
+// Control API in the finally (hosts before the context).
+//
+// Contract: docs/testing/optional-playwright-qa-recorder.md ("Extending the
+// recorder").
+import { expect, test } from '@playwright/test'
+import {
+ CONTROL_API_URL,
+ CONTROL_UI_URL,
+ adminCredentials,
+ api,
+ assertAllowedTarget,
+ loginThroughUi,
+ requireRecorderConfirm,
+ screenshotAndLog,
+ uniqueE2EName,
+} from './qa-recorder-helpers'
+
+test.describe('optional QA recorder: Control UI team Access shared-scope label', () => {
+ test('records the joined shared-scope label on the team Access tab and its removal', async ({
+ page,
+ }, testInfo) => {
+ requireRecorderConfirm(
+ 'QA_RECORDER_CONFIRM_MUTATIONS',
+ 'This journey creates and deletes a team, two hosts, and a context.'
+ )
+ assertAllowedTarget('CONTROL_UI_URL', CONTROL_UI_URL)
+ assertAllowedTarget('CONTROL_API_URL', CONTROL_API_URL)
+
+ const credentials = adminCredentials()
+ const journey = 'control-ui-team-access-shared'
+ const teamName = uniqueE2EName('qa-recorder-team-shared')
+ const contextName = uniqueE2EName('qa-recorder-tas-ctx')
+ const contextId = uniqueE2EName('qa-recorder-tas-scope')
+ const hostNameA = uniqueE2EName('qa-recorder-tas-host-a')
+ const hostNameB = uniqueE2EName('qa-recorder-tas-host-b')
+ const hostDisplayA = uniqueE2EName('qa-recorder-tas-agent-a')
+ const hostDisplayB = uniqueE2EName('qa-recorder-tas-agent-b')
+ // accessScopeLabels joins the sorted owner names with ", " — the "a"
+ // agent sorts before the "b" agent, so the joined label is deterministic.
+ const joinedLabel = `${hostDisplayA}, ${hostDisplayB}`
+ let teamId = ''
+
+ try {
+ await loginThroughUi(page, credentials)
+
+ // Stage the team and its shared scope out-of-band; the behavior under
+ // test is the Access tab presentation and removal round-trip.
+ const teamRes = await api<{ id?: string }>(page.request, 'POST', '/api/v1/admin/teams', {
+ name: teamName,
+ })
+ expect(teamRes.status, `create team: ${JSON.stringify(teamRes.data)}`).toBeLessThan(300)
+ teamId = String(teamRes.data.id ?? '')
+
+ const ctxRes = await api(page.request, 'POST', '/api/v1/admin/contexts', {
+ metadata: { name: contextName },
+ spec: {
+ contextId,
+ description: 'QA recorder team shared access scope',
+ mcpServers: [],
+ },
+ })
+ expect(ctxRes.status, `create context: ${JSON.stringify(ctxRes.data)}`).toBeLessThan(300)
+
+ for (const [hostName, hostDisplay] of [
+ [hostNameA, hostDisplayA],
+ [hostNameB, hostDisplayB],
+ ] as const) {
+ const hostRes = await api(page.request, 'POST', '/api/v1/admin/hosts', {
+ metadata: { name: hostName },
+ spec: {
+ host: hostDisplay,
+ contextRef: contextId,
+ secretRef: '',
+ channels: [],
+ },
+ })
+ expect(hostRes.status, `create host: ${JSON.stringify(hostRes.data)}`).toBeLessThan(300)
+ }
+
+ const grantRes = await api(
+ page.request,
+ 'PUT',
+ `/api/v1/admin/teams/${encodeURIComponent(teamId)}/contexts`,
+ { contextIds: [contextId] }
+ )
+ expect(grantRes.status, `grant team contexts: ${JSON.stringify(grantRes.data)}`).toBeLessThan(
+ 300
+ )
+
+ // Open the team from the Users & Teams directory and switch to Access.
+ await page.getByRole('link', { name: 'Users & Teams', exact: true }).click()
+ await expect(page).toHaveURL(/\/users-and-teams\/users$/, { timeout: 20_000 })
+ const teamsTab = page.getByRole('tab', { name: 'Teams', exact: true })
+ await expect(teamsTab).toBeEnabled({ timeout: 20_000 })
+ await teamsTab.click()
+ await expect(page).toHaveURL(/\/users-and-teams\/teams$/, { timeout: 20_000 })
+
+ const teamLink = page.getByRole('button', { name: teamName, exact: true })
+ await expect(teamLink).toBeVisible({ timeout: 20_000 })
+ await teamLink.click()
+ await expect(page).toHaveURL(/\/users-and-teams\/teams\/[^/]+\/members$/, {
+ timeout: 20_000,
+ })
+
+ const accessTab = page.getByRole('tab', { name: 'Access', exact: true })
+ await accessTab.click()
+ await expect(page).toHaveURL(/\/users-and-teams\/teams\/[^/]+\/access$/, {
+ timeout: 20_000,
+ })
+
+ // The shared scope renders as ONE row with the joined "A, B" label —
+ // never the raw wire contextId, never one row per host.
+ await expect(
+ page.getByText('Agents and connector scopes this team may access.', { exact: true })
+ ).toBeVisible({ timeout: 20_000 })
+ const row = page.getByRole('listitem').filter({ hasText: joinedLabel })
+ await expect(row).toBeVisible({ timeout: 20_000 })
+ await expect(row).not.toContainText(contextId)
+ await expect(page.getByRole('listitem').getByText(hostDisplayA, { exact: true })).toHaveCount(
+ 0
+ )
+ await expect(page.getByRole('listitem').getByText(hostDisplayB, { exact: true })).toHaveCount(
+ 0
+ )
+ await screenshotAndLog(page, testInfo, `${journey}-granted`)
+
+ // Remove the row: confirm dialog names the joined label → toast → row gone.
+ await row.getByLabel('Remove access').click()
+ const confirmDialog = page.getByRole('alertdialog', { name: 'Remove Access' })
+ await expect(confirmDialog).toBeVisible()
+ await expect(confirmDialog).toContainText(joinedLabel)
+ await expect(confirmDialog).not.toContainText(contextId)
+ await screenshotAndLog(page, testInfo, `${journey}-remove-confirm`)
+ await confirmDialog.getByRole('button', { name: 'Remove access', exact: true }).click()
+ await expect(
+ page.getByRole('status').filter({ hasText: 'Team access updated.' })
+ ).toBeVisible({ timeout: 20_000 })
+ await expect(row.getByLabel('Remove access')).toHaveCount(0)
+ await expect(page.getByText('No access assigned yet.', { exact: true })).toBeVisible()
+ await screenshotAndLog(page, testInfo, `${journey}-removed`)
+ } finally {
+ try {
+ const request = page.request
+ let idToDelete = teamId
+ if (!idToDelete) {
+ const { status, data } = await api<{ items?: Array<{ id: string; name: string }> }>(
+ request,
+ 'GET',
+ '/api/v1/admin/teams'
+ )
+ if (status === 200) {
+ idToDelete = (data.items || []).find(team => team.name === teamName)?.id || ''
+ }
+ }
+ if (idToDelete) {
+ await api(request, 'DELETE', `/api/v1/admin/teams/${encodeURIComponent(idToDelete)}`)
+ }
+ } catch {
+ // Best-effort cleanup; the disposable environment tolerates leftovers.
+ }
+ await api(page.request, 'DELETE', `/api/v1/admin/hosts/${encodeURIComponent(hostNameA)}`)
+ await api(page.request, 'DELETE', `/api/v1/admin/hosts/${encodeURIComponent(hostNameB)}`)
+ await api(page.request, 'DELETE', `/api/v1/admin/contexts/${encodeURIComponent(contextName)}`)
+ }
+ })
+})
diff --git a/control-ui/e2e/qa-recorder-team-access.spec.ts b/control-ui/e2e/qa-recorder-team-access.spec.ts
index 13eff2add..9d30b7340 100644
--- a/control-ui/e2e/qa-recorder-team-access.spec.ts
+++ b/control-ui/e2e/qa-recorder-team-access.spec.ts
@@ -73,7 +73,6 @@ test.describe('optional QA recorder: Control UI team Access tab', () => {
contextRef: contextId,
secretRef: '',
channels: [],
- model: { provider: 'openai', name: 'gpt-5.4-mini' },
},
})
expect(hostRes.status, `create host: ${JSON.stringify(hostRes.data)}`).toBeLessThan(300)
@@ -114,16 +113,15 @@ test.describe('optional QA recorder: Control UI team Access tab', () => {
})
// Exact subtitle and intro; the row shows the host display name, never
- // the raw wire contextId.
+ // the raw wire contextId. Access rows are role="listitem" divs
+ // (.cu-access-row), not table rows.
await expect(
page.getByText('Members, connector access, and agents.', { exact: true })
).toBeVisible({ timeout: 20_000 })
await expect(
page.getByText('Agents and connector scopes this team may access.', { exact: true })
).toBeVisible()
- const row = page
- .getByRole('row')
- .filter({ has: page.getByRole('cell', { name: hostDisplayName, exact: true }) })
+ const row = page.getByRole('listitem').filter({ hasText: hostDisplayName })
await expect(row).toBeVisible({ timeout: 20_000 })
await expect(row).not.toContainText(contextId)
await screenshotAndLog(page, testInfo, `${journey}-granted`)
@@ -146,7 +144,9 @@ test.describe('optional QA recorder: Control UI team Access tab', () => {
await expect(
page.getByRole('status').filter({ hasText: 'Team access updated.' })
).toBeVisible({ timeout: 20_000 })
- await expect(row).toHaveCount(0)
+ // The mapping moves to the "Removed access" tombstone (deleted history),
+ // so the actionable row disappears but a read-only row may remain.
+ await expect(row.getByLabel('Remove access')).toHaveCount(0)
await expect(page.getByText('No access assigned yet.', { exact: true })).toBeVisible()
await screenshotAndLog(page, testInfo, `${journey}-removed`)
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index e391146bb..e21405a89 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.467",
+ "version": "0.1.468",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.467",
+ "version": "0.1.468",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/llm-providers": "file:../packages/llm-providers",
diff --git a/control-ui/package.json b/control-ui/package.json
index ffaff7c7d..88b57e50d 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.467",
+ "version": "0.1.468",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",
@@ -51,11 +51,12 @@
"qa:recorder:recipe-scope-copy": "PLAYWRIGHT_BROWSERS_PATH=../.local-notes/qa-recorder/browsers playwright test --config=playwright.qa-recorder.config.ts qa-recorder-recipe-scope-copy.spec.ts",
"qa:recorder:token-budget-scope": "PLAYWRIGHT_BROWSERS_PATH=../.local-notes/qa-recorder/browsers playwright test --config=playwright.qa-recorder.config.ts qa-recorder-token-budget-scope.spec.ts",
"qa:recorder:context-vocab-sweep": "PLAYWRIGHT_BROWSERS_PATH=../.local-notes/qa-recorder/browsers playwright test --config=playwright.qa-recorder.config.ts qa-recorder-context-vocab-sweep.spec.ts",
+ "qa:recorder:member-access-multi": "PLAYWRIGHT_BROWSERS_PATH=../.local-notes/qa-recorder/browsers playwright test --config=playwright.qa-recorder.config.ts qa-recorder-member-access-multi.spec.ts",
+ "qa:recorder:team-access-shared-label": "PLAYWRIGHT_BROWSERS_PATH=../.local-notes/qa-recorder/browsers playwright test --config=playwright.qa-recorder.config.ts qa-recorder-team-access-shared-label.spec.ts",
"qa:recorder:agent-connectors-conflict": "PLAYWRIGHT_BROWSERS_PATH=../.local-notes/qa-recorder/browsers playwright test --config=playwright.qa-recorder.config.ts qa-recorder-agent-connectors-conflict.spec.ts",
"qa:recorder:member-removed-access": "PLAYWRIGHT_BROWSERS_PATH=../.local-notes/qa-recorder/browsers playwright test --config=playwright.qa-recorder.config.ts qa-recorder-member-removed-access.spec.ts",
"qa:recorder:connectors-search-agent": "PLAYWRIGHT_BROWSERS_PATH=../.local-notes/qa-recorder/browsers playwright test --config=playwright.qa-recorder.config.ts qa-recorder-connectors-search-agent.spec.ts",
"qa:recorder:all": "PLAYWRIGHT_BROWSERS_PATH=../.local-notes/qa-recorder/browsers playwright test --config=playwright.qa-recorder.config.ts",
- "qa:recorder:convert-mp4": "bash ../scripts/qa-recorder/convert-videos-mp4.sh",
"test": "vitest run",
"test:watch": "vitest"
},
diff --git a/scripts/qa-recorder/mock-control-api.mjs b/scripts/qa-recorder/mock-control-api.mjs
new file mode 100644
index 000000000..240ffbf17
--- /dev/null
+++ b/scripts/qa-recorder/mock-control-api.mjs
@@ -0,0 +1,577 @@
+#!/usr/bin/env node
+// Mock control-api for QA-recorder journeys and UI e2e specs.
+//
+// Serves the exact wire contract control-ui consumes (see
+// docs/features/control-ui-context-removal.md §9 and the endpoint inventory
+// audited from control-ui/lib/api.ts) with in-memory state, so the REAL
+// frontend can be driven end-to-end (and recorded) without a cluster.
+// Evidence produced against this mock is mock-backed UI e2e — never call it
+// a T2/runtime verdict.
+//
+// Usage: node scripts/qa-recorder/mock-control-api.mjs [port]
+// Env: MOCK_ADMIN_USER (default admin) — any password is accepted.
+//
+// Semantics emulated:
+// - cookie session (control_ui_admin_session), any credentials accepted
+// - resourceVersion counters; PUT with a stale metadata.resourceVersion → 409
+// {error:'conflict'} (absent RV = last-write-wins, like the legacy path)
+// - users/:id/contexts and teams/:id/contexts full-replace with
+// deletedContextIds history; contexts/:id/{users,teams} derived reverse-maps
+// - POST /registry/install creates the McpServer, ensures the context, and
+// adds the server to its allowlist (mirrors control-api behavior the
+// install-success copy depends on)
+import { createServer } from 'node:http'
+import { randomUUID } from 'node:crypto'
+
+const PORT = Number(process.argv[2] ?? 8090)
+const COOKIE = 'control_ui_admin_session=mock-session'
+const ADMIN = { id: 'usr-admin', username: 'admin', email: '[email protected]', role: 'admin' }
+
+let rvCounter = 0
+const nextRv = () => `rv-${++rvCounter}`
+
+// ── in-memory stores ────────────────────────────────────────────────────────
+const users = [
+ {
+ id: ADMIN.id,
+ email: ADMIN.email,
+ name: 'Admin Admin',
+ displayName: 'Admin Admin',
+ controlAdminId: null,
+ activeTeamCount: 0,
+ },
+]
+const userContact = new Map(users.map(u => [u.id, { id: u.id, email: u.email, name: u.name, channels: { emails: [], slackUserNames: [], telegramIds: [] } }]))
+const userContexts = new Map([[ADMIN.id, { contextIds: [], deletedContextIds: [] }]])
+const userAgents = new Map([[ADMIN.id, []]])
+
+const teams = []
+const teamMembers = new Map()
+const teamContexts = new Map()
+const teamAgents = new Map()
+const teamInvitations = new Map()
+
+const hosts = new Map() // name → resource
+const contexts = new Map() // name → resource
+const mcpServers = new Map() // name → resource
+const secrets = []
+const budgets = []
+const sharedFileSystems = [
+ {
+ metadata: { name: 'mock-workspace', namespace: 'workspace-files' },
+ spec: { size: '5Gi', accessModes: ['ReadOnlyMany'] },
+ status: { phase: 'Ready', capacity: '5Gi', mountedByContexts: [] },
+ },
+]
+
+const registryEntries = [
+ {
+ id: 'mock-mcp-filesystem',
+ name: 'mock-mcp-filesystem',
+ version: '1.0.0',
+ entry_type: 'mcp-server',
+ description: 'Mock local MCP entry for QA recorder journeys',
+ author: 'evenfire',
+ origin: 'mock',
+ category: 'files',
+ tags: ['mock'],
+ trust_level: 'high',
+ quality_tier: 'verified',
+ status: 'published',
+ server_mode: 'local',
+ transport: 'streamableHttp',
+ recipe_type: null,
+ mcp_server_meta: { tools: ['read_file', 'write_file'] },
+ latest: true,
+ visibility: 'public',
+ },
+]
+
+const llmModels = [
+ { provider: 'openai', model: 'gpt-5.4-mini', enabled: true, source: 'seed', stale: false },
+ { provider: 'zai', model: 'glm-5.1', enabled: true, source: 'seed', stale: false },
+]
+
+const recipes = new Map() // "<ns>/<name>" → resource
+
+// ── helpers ─────────────────────────────────────────────────────────────────
+const json = (res, status, body, extraHeaders = {}) => {
+ const payload = JSON.stringify(body)
+ res.writeHead(status, { 'Content-Type': 'application/json', ...extraHeaders })
+ res.end(payload)
+}
+const readBody = req =>
+ new Promise(resolve => {
+ let data = ''
+ req.on('data', chunk => (data += chunk))
+ req.on('end', () => {
+ try {
+ resolve(data ? JSON.parse(data) : {})
+ } catch {
+ resolve({})
+ }
+ })
+ })
+const nameFrom = path => decodeURIComponent(path.split('/').filter(Boolean).pop() ?? '')
+const rfc1123 = /^[-a-z0-9]+$/
+
+function resourceVersionGuard(resource, body) {
+ const supplied = body?.metadata?.resourceVersion
+ if (supplied !== undefined && supplied !== resource.metadata?.resourceVersion) {
+ return { conflict: true }
+ }
+ return { conflict: false }
+}
+
+function contextUsers(id) {
+ const items = []
+ for (const [userId, access] of userContexts) {
+ if ((access.contextIds ?? []).includes(id)) {
+ const u = users.find(candidate => candidate.id === userId)
+ if (u) items.push({ id: u.id, email: u.email, name: u.name, displayName: u.displayName })
+ }
+ }
+ return { items }
+}
+
+function contextTeams(id) {
+ const items = []
+ for (const [teamId, access] of teamContexts) {
+ if ((access.contextIds ?? []).includes(id)) {
+ const t = teams.find(candidate => candidate.id === teamId)
+ if (t) items.push({ id: t.id, name: t.name })
+ }
+ }
+ return { items }
+}
+
+function putContextsMapping(map, key, contextIds, deletedKey) {
+ const current = map.get(key) ?? { [deletedKey]: [] }
+ const next = Array.isArray(contextIds) ? [...new Set(contextIds.map(String))] : []
+ const removed = (current.contextIds ?? []).filter(id => !next.includes(id))
+ const history = [...new Set([...(current[deletedKey] ?? []), ...removed])]
+ const updated = { contextIds: next }
+ updated[deletedKey] = history.filter(id => !next.includes(id))
+ map.set(key, updated)
+ return { ...updated, [key.includes('team') ? 'teamId' : 'userId']: key }
+}
+
+// ── router ──────────────────────────────────────────────────────────────────
+const server = createServer(async (req, res) => {
+ const url = new URL(req.url, `http://localhost:${PORT}`)
+ const path = url.pathname
+ const method = req.method
+ const authed = (req.headers.cookie ?? '').includes(COOKIE.split('=')[0])
+
+ if (!authed && !path.startsWith('/api/v1/admin/auth/login')) {
+ return json(res, 401, { error: 'Unauthorized' })
+ }
+
+ const body = method === 'GET' || method === 'DELETE' ? {} : await readBody(req)
+ const seg = path.replace(/^\/+/, '').split('/').filter(Boolean) // api v1 admin ...
+ const rest = seg.slice(3).join('/') // after /api/v1/admin
+ const M = method
+
+ try {
+ // ── auth ──
+ if (rest === 'auth/login' && M === 'POST') {
+ if (!body.username) return json(res, 400, { error: 'username required' })
+ return json(res, 200, { me: { ...ADMIN, username: body.username } }, { 'Set-Cookie': `${COOKIE}; Path=/; HttpOnly; SameSite=Lax` })
+ }
+ if (rest === 'auth/logout' && M === 'POST') return json(res, 200, { ok: true })
+ if (rest === 'auth/me' && M === 'GET')
+ return json(res, 200, { me: ADMIN, namespaces: { sandbox: 'sandbox', mcpServer: 'mcp-server' } })
+
+ // ── users ──
+ if (rest === 'users' && M === 'GET') {
+ const q = (url.searchParams.get('q') ?? '').toLowerCase()
+ const items = users.filter(u => !q || `${u.name} ${u.email} ${u.displayName}`.toLowerCase().includes(q))
+ return json(res, 200, { items })
+ }
+ if (/^users\/[^/]+\/context$/.test(rest) && M === 'GET') {
+ const id = nameFrom(rest.replace('/context', ''))
+ return json(res, 200, userContact.get(id) ?? { id, email: '', name: '', channels: { emails: [], slackUserNames: [], telegramIds: [] } })
+ }
+ if (/^users\/[^/]+\/context$/.test(rest) && M === 'PUT') {
+ const id = nameFrom(rest.replace('/context', ''))
+ userContact.set(id, { ...(userContact.get(id) ?? { id }), ...body })
+ return json(res, 200, userContact.get(id))
+ }
+ if (/^users\/[^/]+\/contexts$/.test(rest) && M === 'GET') {
+ const id = nameFrom(rest.replace('/contexts', ''))
+ return json(res, 200, userContexts.get(id) ?? { userId: id, contextIds: [], deletedContextIds: [] })
+ }
+ if (/^users\/[^/]+\/contexts$/.test(rest) && M === 'PUT') {
+ const id = nameFrom(rest.replace('/contexts', ''))
+ return json(res, 200, putContextsMapping(userContexts, id, body.contextIds, 'deletedContextIds'))
+ }
+ if (/^users\/[^/]+\/agents$/.test(rest) && M === 'GET') {
+ const id = nameFrom(rest.replace('/agents', ''))
+ return json(res, 200, { agentNames: userAgents.get(id) ?? [], deletedAgentNames: [] })
+ }
+ if (/^users\/[^/]+\/agents$/.test(rest) && M === 'PUT') {
+ const id = nameFrom(rest.replace('/agents', ''))
+ userAgents.set(id, Array.isArray(body.agentNames) ? body.agentNames : [])
+ return json(res, 200, { agentNames: userAgents.get(id), deletedAgentNames: [] })
+ }
+ if (/^users\/[^/]+\/teams$/.test(rest) && M === 'GET')
+ return json(res, 200, { items: [] })
+
+ // ── teams ──
+ if (rest === 'teams' && M === 'GET')
+ return json(res, 200, { items: teams.map(t => ({ id: t.id, name: t.name, memberCount: teamMembers.get(t.id)?.length ?? 0 })) })
+ if (rest === 'teams' && M === 'POST') {
+ if (!body.name) return json(res, 400, { error: 'name required' })
+ const team = { id: `team-${randomUUID().slice(0, 8)}`, name: String(body.name) }
+ teams.push(team)
+ teamMembers.set(team.id, [])
+ teamContexts.set(team.id, { contextIds: [], deletedContextIds: [] })
+ teamAgents.set(team.id, [])
+ teamInvitations.set(team.id, [])
+ return json(res, 200, team)
+ }
+ if (/^teams\/[^/]+$/.test(rest) && M === 'GET') {
+ const id = nameFrom(rest)
+ const team = teams.find(t => t.id === id)
+ return team ? json(res, 200, team) : json(res, 404, { error: 'not found' })
+ }
+ if (/^teams\/[^/]+$/.test(rest) && M === 'DELETE') {
+ const id = nameFrom(rest)
+ const idx = teams.findIndex(t => t.id === id)
+ if (idx === -1) return json(res, 404, { error: 'not found' })
+ teams.splice(idx, 1)
+ return json(res, 200, { deleted: true, id })
+ }
+ if (/^teams\/[^/]+\/members$/.test(rest) && M === 'GET')
+ return json(res, 200, { items: teamMembers.get(nameFrom(rest.replace('/members', ''))) ?? [] })
+ if (/^teams\/[^/]+\/agents$/.test(rest) && M === 'GET')
+ return json(res, 200, { agentNames: teamAgents.get(nameFrom(rest.replace('/agents', ''))) ?? [], deletedAgentNames: [] })
+ if (/^teams\/[^/]+\/agents$/.test(rest) && M === 'PUT') {
+ const id = nameFrom(rest.replace('/agents', ''))
+ teamAgents.set(id, Array.isArray(body.agentNames) ? body.agentNames : [])
+ return json(res, 200, { agentNames: teamAgents.get(id), deletedAgentNames: [] })
+ }
+ if (/^teams\/[^/]+\/contexts$/.test(rest) && M === 'GET') {
+ const id = nameFrom(rest.replace('/contexts', ''))
+ return json(res, 200, teamContexts.get(id) ?? { teamId: id, contextIds: [], deletedContextIds: [] })
+ }
+ if (/^teams\/[^/]+\/contexts$/.test(rest) && M === 'PUT') {
+ const id = nameFrom(rest.replace('/contexts', ''))
+ const updated = putContextsMapping(teamContexts, id, body.contextIds, 'deletedContextIds')
+ return json(res, 200, { teamId: id, ...updated })
+ }
+ if (/^teams\/[^/]+\/invitations$/.test(rest) && M === 'GET')
+ return json(res, 200, { items: teamInvitations.get(nameFrom(rest.replace('/invitations', ''))) ?? [] })
+ if (/^teams\/[^/]+\/name$/.test(rest) && M === 'PUT') {
+ const id = nameFrom(rest.replace('/name', ''))
+ const team = teams.find(t => t.id === id)
+ if (!team) return json(res, 404, { error: 'not found' })
+ team.name = String(body.name ?? team.name)
+ return json(res, 200, team)
+ }
+
+ // ── hosts ──
+ if (rest === 'hosts' && M === 'GET') return json(res, 200, { items: [...hosts.values()] })
+ if (rest === 'hosts' && M === 'POST') {
+ const name = String(body?.metadata?.name ?? '')
+ if (!rfc1123.test(name)) return json(res, 422, { errors: [{ field: 'metadata.name', message: 'invalid name' }] })
+ if (hosts.has(name)) return json(res, 409, { error: 'already exists' })
+ const host = { ...body, metadata: { ...(body.metadata ?? {}), resourceVersion: nextRv() } }
+ hosts.set(name, host)
+ return json(res, 201, host)
+ }
+ if (/^hosts\/[^/]+\/detail$/.test(rest) && M === 'GET') {
+ const name = nameFrom(rest.replace('/detail', ''))
+ const host = hosts.get(name)
+ if (!host) return json(res, 404, { error: 'not found' })
+ const ref = String(host.spec?.contextRef ?? '')
+ const linked = ref ? [...contexts.values()].filter(c => String(c.metadata?.name) === ref || String(c.spec?.contextId) === ref) : []
+ return json(res, 200, { host, contexts: linked, secrets, users: [], teams: [], agentUsers: [], agentTeams: [] })
+ }
+ if (/^hosts\/[^/]+$/.test(rest) && M === 'GET') {
+ const host = hosts.get(nameFrom(rest))
+ return host ? json(res, 200, host) : json(res, 404, { error: 'not found' })
+ }
+ if (/^hosts\/[^/]+$/.test(rest) && M === 'PUT') {
+ const name = nameFrom(rest)
+ const host = hosts.get(name)
+ if (!host) return json(res, 404, { error: 'not found' })
+ if (resourceVersionGuard(host, body).conflict) return json(res, 409, { error: 'conflict' })
+ const updated = { ...host, ...body, metadata: { ...(host.metadata ?? {}), ...(body.metadata ?? {}), resourceVersion: nextRv() } }
+ hosts.set(name, updated)
+ return json(res, 200, updated)
+ }
+ if (/^hosts\/[^/]+$/.test(rest) && M === 'DELETE') {
+ hosts.delete(nameFrom(rest))
+ return json(res, 200, { deleted: true })
+ }
+
+ // ── contexts ──
+ if (rest === 'contexts' && M === 'GET') return json(res, 200, { items: [...contexts.values()] })
+ if (rest === 'contexts' && M === 'POST') {
+ const name = String(body?.metadata?.name ?? '')
+ if (!rfc1123.test(name)) return json(res, 422, { errors: [{ field: 'metadata.name', message: 'invalid name' }] })
+ if (contexts.has(name)) return json(res, 409, { error: 'already exists' })
+ const context = { ...body, metadata: { ...(body.metadata ?? {}), resourceVersion: nextRv() } }
+ contexts.set(name, context)
+ return json(res, 201, context)
+ }
+ if (/^contexts\/[^/]+\/users$/.test(rest) && M === 'GET') return json(res, 200, contextUsers(nameFrom(rest.replace('/users', ''))))
+ if (/^contexts\/[^/]+\/teams$/.test(rest) && M === 'GET') return json(res, 200, contextTeams(nameFrom(rest.replace('/teams', ''))))
+ if (/^contexts\/[^/]+$/.test(rest) && M === 'GET') {
+ const name = nameFrom(rest)
+ const byId = [...contexts.values()].find(c => String(c.spec?.contextId) === name)
+ const context = contexts.get(name) ?? byId
+ return context ? json(res, 200, context) : json(res, 404, { error: 'not found' })
+ }
+ if (/^contexts\/[^/]+$/.test(rest) && M === 'PUT') {
+ const name = nameFrom(rest)
+ let context = contexts.get(name)
+ if (!context) {
+ const byId = [...contexts.values()].find(c => String(c.spec?.contextId) === name)
+ context = byId
+ }
+ if (!context) return json(res, 404, { error: 'not found' })
+ if (resourceVersionGuard(context, body).conflict) return json(res, 409, { error: 'conflict' })
+ const key = context.metadata?.name ?? name
+ const updated = { ...context, ...body, metadata: { ...(context.metadata ?? {}), ...(body.metadata ?? {}), resourceVersion: nextRv() } }
+ contexts.set(key, updated)
+ return json(res, 200, updated)
+ }
+ if (/^contexts\/[^/]+$/.test(rest) && M === 'DELETE') {
+ const name = nameFrom(rest)
+ const byId = [...contexts.values()].find(c => String(c.spec?.contextId) === name)
+ contexts.delete(name)
+ if (byId) contexts.delete(byId.metadata?.name ?? '')
+ return json(res, 200, { deleted: true })
+ }
+
+ // ── mcp-servers ──
+ if (rest === 'mcp-servers' && M === 'GET') return json(res, 200, { items: [...mcpServers.values()] })
+ if (rest === 'mcp-servers' && M === 'POST') {
+ const name = String(body?.metadata?.name ?? '')
+ if (!rfc1123.test(name)) return json(res, 422, { errors: [{ field: 'metadata.name', message: 'invalid name' }] })
+ if (mcpServers.has(name)) return json(res, 409, { error: 'already exists' })
+ const server = { ...body, metadata: { ...(body.metadata ?? {}), resourceVersion: nextRv() } }
+ mcpServers.set(name, server)
+ return json(res, 201, server)
+ }
+ if (/^mcp-servers\/[^/]+$/.test(rest) && M === 'GET') {
+ const server = mcpServers.get(nameFrom(rest))
+ return server ? json(res, 200, server) : json(res, 404, { error: 'not found' })
+ }
+ if (/^mcp-servers\/[^/]+$/.test(rest) && M === 'PUT') {
+ const name = nameFrom(rest)
+ const server = mcpServers.get(name)
+ if (!server) return json(res, 404, { error: 'not found' })
+ if (resourceVersionGuard(server, body).conflict) return json(res, 409, { error: 'conflict' })
+ const updated = { ...server, ...body, metadata: { ...(server.metadata ?? {}), ...(body.metadata ?? {}), resourceVersion: nextRv() } }
+ mcpServers.set(name, updated)
+ return json(res, 200, updated)
+ }
+ if (/^mcp-servers\/[^/]+$/.test(rest) && M === 'DELETE') {
+ mcpServers.delete(nameFrom(rest))
+ return json(res, 200, { deleted: true })
+ }
+
+ // ── secrets ──
+ if (rest === 'secrets' && M === 'GET') return json(res, 200, { items: secrets.map(s => ({ name: s.name, keys: Object.keys(s.stringData ?? {}) })) })
+ if (rest === 'secrets' && M === 'POST') {
+ const name = String(body.name ?? '')
+ if (!name) return json(res, 400, { error: 'name required' })
+ secrets.push({ name, stringData: body.stringData ?? {} })
+ return json(res, 201, { name })
+ }
+ if (/^secrets\/[^/]+$/.test(rest) && M === 'DELETE') {
+ const name = nameFrom(rest)
+ const idx = secrets.findIndex(s => s.name === name)
+ if (idx >= 0) secrets.splice(idx, 1)
+ return json(res, 200, { deleted: true })
+ }
+ if (rest === 'mcp-secrets' && M === 'POST') return json(res, 201, { name: String(body.name ?? ''), namespace: 'mcp-server' })
+ if (/^mcp-secrets\/[^/]+$/.test(rest) && M === 'PUT') {
+ const secretName = decodeURIComponent(nameFrom(rest))
+ const affectedConnectors = []
+ for (const [name, server] of mcpServers) {
+ if (String(server.spec?.envSecret?.name ?? '') === secretName) {
+ affectedConnectors.push(name)
+ server.status = {
+ conditions: [
+ {
+ type: 'DeploymentReady',
+ status: 'True',
+ reason: 'RotationComplete',
+ message: 'Mock rotation rollout finished',
+ lastTransitionTime: new Date(Date.now() + 1_000).toISOString(),
+ },
+ ],
+ }
+ }
+ }
+ return json(res, 200, {
+ name: secretName,
+ keys: Object.keys(body.data ?? {}),
+ affectedConnectors,
+ })
+ }
+
+ // ── registry ──
+ if (rest === 'registry/entries' && M === 'GET')
+ return json(res, 200, { data: registryEntries, meta: { total: registryEntries.length } })
+ if (/^registry\/entries\/[^/]+\/versions\/[^/]+$/.test(rest) && M === 'GET') {
+ const entry = registryEntries[0]
+ return entry ? json(res, 200, entry) : json(res, 404, { error: 'not found' })
+ }
+ if (/^registry\/entries\/[^/]+\/versions\/[^/]+\/credential-schema$/.test(rest) && M === 'GET')
+ return json(res, 200, { required: false, authType: 'api-key', keys: [] })
+ if (rest === 'registry/catalog' && M === 'GET')
+ return json(res, 200, { data: registryEntries, categories: ['files'], installed: { catalogKeys: [], serverNames: [...mcpServers.keys()], recipeKeys: [] } })
+ if (rest === 'registry/install' && M === 'POST') {
+ const serverName = String(body.serverName ?? body.registryEntryName)
+ const entry = registryEntries.find(e => e.name === body.registryEntryName) ?? registryEntries[0]
+ if (!entry) return json(res, 404, { error: 'entry not found' })
+ mcpServers.set(serverName, {
+ metadata: { name: serverName, resourceVersion: nextRv(), labels: { 'clerum.io/managed-by': 'control-api' }, annotations: { 'clerum.io/catalog-id': entry.name, 'clerum.io/catalog-version': body.registryEntryVersion ?? entry.version } },
+ spec: { image: 'clerum/mock-mcp-server:test', contextRef: body.contextRef, enabled: true, managed: true, transport: { type: 'streamableHttp', port: 3000, url: `http://${serverName}.mcp-server.svc.cluster.local:3000/mcp` } },
+ })
+ const ref = String(body.contextRef ?? '')
+ const existing = contexts.get(ref)
+ if (existing) {
+ const servers = new Set([...(existing.spec?.mcpServers ?? []), serverName])
+ existing.spec = { ...existing.spec, mcpServers: [...servers] }
+ existing.metadata = { ...existing.metadata, resourceVersion: nextRv() }
+ } else if (ref) {
+ contexts.set(ref, { metadata: { name: ref, resourceVersion: nextRv() }, spec: { contextId: ref, description: `Connector access scope for ${serverName}`, mcpServers: [serverName] } })
+ }
+ return json(res, 201, { installed: true, serverName, namespace: 'mcp-server', contextRef: ref })
+ }
+
+ // ── budgets ──
+ if (rest === 'budgets' && M === 'GET') return json(res, 200, { rows: budgets })
+ if (rest === 'budgets' && M === 'POST') {
+ if (!body.name || !body.unit || !body.limit_amount || !body.period) return json(res, 400, { error: 'invalid budget' })
+ const row = { id: randomUUID(), enabled: true, spent: 0, remaining: body.limit_amount, unpriced: false, ...body }
+ budgets.push(row)
+ return json(res, 201, row)
+ }
+ if (/^budgets\/[^/]+$/.test(rest) && M === 'DELETE') {
+ const id = nameFrom(rest)
+ const idx = budgets.findIndex(b => b.id === id)
+ if (idx >= 0) budgets.splice(idx, 1)
+ return json(res, 200, { deleted: true })
+ }
+
+ // ── misc lists the UI boots with ──
+ if (rest === 'shared-filesystems' && M === 'GET') return json(res, 200, { items: sharedFileSystems })
+ if (/^shared-filesystems\/[^/]+$/.test(rest) && M === 'GET') {
+ const name = nameFrom(rest)
+ const sfs = sharedFileSystems.find(s => s.metadata?.name === name)
+ return sfs ? json(res, 200, sfs) : json(res, 404, { error: 'not found' })
+ }
+ if (/^shared-filesystems\/[^/]+\/proxy\/v1\/files$/.test(rest) && M === 'GET')
+ return json(res, 200, { entries: [] })
+ if (rest === 'pending-invitations' && M === 'GET') return json(res, 200, { items: [] })
+ if (rest === 'attention' && M === 'GET') return json(res, 200, { items: [] })
+ if (rest === 'settings/me' && M === 'GET')
+ return json(res, 200, { theme: 'dark', notifications: {} })
+ if (rest === 'llm-prices' && M === 'GET') return json(res, 200, { items: [] })
+ if (rest === 'llm-prices/unpriced' && M === 'GET') return json(res, 200, { models: [] })
+ if (rest === 'recipe-secrets' && M === 'GET') return json(res, 200, { items: [] })
+ if (/^workflows\/[^/]+\/[^/]+\/runs$/.test(rest) && M === 'GET')
+ return json(res, 200, { items: [] })
+ if (/^recipes\/[^/]+\/pods$/.test(rest) && M === 'GET')
+ return json(res, 200, { pods: [] })
+ if (/^recipes\/[^/]+\/status$/.test(rest) && M === 'GET')
+ return json(res, 200, { conditions: [] })
+ if (/^recipes\/[^/]+\/artifacts$/.test(rest) && M === 'GET')
+ return json(res, 200, { items: [] })
+ if (/^mcp-secrets\/[^/]+$/.test(rest) && M === 'DELETE') return json(res, 200, { deleted: true })
+ if (/^recipes\/[^/]+$/.test(rest) && M === 'GET') {
+ const name = decodeURIComponent(nameFrom(rest))
+ const recipe = [...recipes.values()].find(r => String(r.metadata?.name) === name)
+ return recipe ? json(res, 200, recipe) : json(res, 404, { error: 'not found' })
+ }
+ if (/^recipes\/[^/]+$/.test(rest) && M === 'PUT') {
+ const name = decodeURIComponent(nameFrom(rest))
+ const key = [...recipes.keys()].find(k => k.endsWith(`/${name}`)) ?? `default/${name}`
+ recipes.set(key, body)
+ return json(res, 200, body)
+ }
+ if (/^recipes\/[^/]+$/.test(rest) && M === 'DELETE') {
+ const name = decodeURIComponent(nameFrom(rest))
+ for (const k of [...recipes.keys()]) if (k.endsWith(`/${name}`)) recipes.delete(k)
+ return json(res, 200, { deleted: true })
+ }
+ if (rest === 'invitations' && M === 'POST') {
+ const invitation = {
+ id: `inv-${randomUUID().slice(0, 8)}`,
+ team_id: body.teams?.[0]?.teamId ?? null,
+ invitee_name: body.name ?? null,
+ email: body.email ?? '',
+ role: body.role ?? 'member',
+ status: 'pending',
+ }
+ if (invitation.team_id && teamInvitations.has(invitation.team_id)) {
+ teamInvitations.get(invitation.team_id).push(invitation)
+ }
+ return json(res, 201, invitation)
+ }
+ if (rest === 'settings/bridge-status' && M === 'GET') return json(res, 200, {})
+ if (rest === 'registry/publish-scope' && M === 'GET') return json(res, 200, {})
+ if (rest === 'registry/keys' && M === 'GET') return json(res, 200, { items: [], keys: [] })
+ if (rest === 'registry/images' && M === 'GET') return json(res, 200, { org: '', images: [] })
+ if (rest === 'registry/connect' && M === 'GET') return json(res, 200, { connected: false })
+
+ // ── recipes (stored verbatim; editor validation is client-side) ──
+ if (rest === 'recipes/validate' && M === 'POST')
+ return json(res, 200, { valid: true, issues: [] })
+ if (rest === 'recipes' && M === 'POST') {
+ const ns = String(body?.metadata?.namespace ?? 'default')
+ const name = String(body?.metadata?.name ?? '')
+ if (!name) return json(res, 400, { error: 'metadata.name required' })
+ const recipe = { ...body, metadata: { namespace: ns, ...(body.metadata ?? {}) } }
+ recipes.set(`${ns}/${name}`, recipe)
+ return json(res, 201, recipe)
+ }
+ if (/^recipes\/[^/]+\/[^/]+$/.test(rest) && M === 'GET') {
+ const [ns, name] = rest.split('/').slice(1)
+ const recipe = recipes.get(`${decodeURIComponent(ns)}/${decodeURIComponent(name)}`)
+ return recipe ? json(res, 200, recipe) : json(res, 404, { error: 'not found' })
+ }
+ if (/^recipes\/[^/]+\/[^/]+$/.test(rest) && M === 'PUT') {
+ const [ns, name] = rest.split('/').slice(1)
+ recipes.set(`${decodeURIComponent(ns)}/${decodeURIComponent(name)}`, body)
+ return json(res, 200, body)
+ }
+ if (/^recipes\/[^/]+\/[^/]+$/.test(rest) && M === 'DELETE') {
+ const [ns, name] = rest.split('/').slice(1)
+ recipes.delete(`${decodeURIComponent(ns)}/${decodeURIComponent(name)}`)
+ return json(res, 200, { deleted: true })
+ }
+ if (rest === 'recipes' && M === 'GET')
+ return json(res, 200, { items: [...recipes.values()] })
+ if (rest === 'profile-admin/overview' && M === 'GET')
+ return json(res, 200, {
+ teams: teams.map(t => ({ id: t.id, name: t.name })),
+ users: users.map(u => ({ id: u.id, email: u.email, name: u.name, displayName: u.displayName })),
+ pendingInvitations: [],
+ teamAgentCounts: Object.fromEntries(teams.map(t => [t.id, teamAgents.get(t.id)?.length ?? 0])),
+ teamContextCounts: Object.fromEntries(teams.map(t => [t.id, teamContexts.get(t.id)?.contextIds?.length ?? 0])),
+ })
+ if (rest === 'llm-models' && M === 'GET') return json(res, 200, { rows: llmModels })
+ if (rest === 'communication-channels' && M === 'GET') return json(res, 200, { items: [] })
+ if (rest === 'recipes' && M === 'GET') return json(res, 200, { items: [] })
+ if (rest === 'workflow-recipes' && M === 'GET') return json(res, 200, { items: [] })
+
+ // Unknown endpoint: log loudly so missing stubs are obvious, then 404.
+ console.log(`[mock-control-api] UNHANDLED ${M} ${path}`)
+ return json(res, 404, { error: `no mock for ${M} ${path}` })
+ } catch (err) {
+ console.error(`[mock-control-api] ERROR ${M} ${path}:`, err)
+ return json(res, 500, { error: 'mock error' })
+ }
+})
+
+server.listen(PORT, () => {
+ console.log(`[mock-control-api] listening on all local interfaces, port ${PORT} (any credentials accepted; mock-backed UI e2e only)`)
+})
diff --git a/tests/e2e/playwright/control-ui/agent-connectors-tab.spec.ts b/tests/e2e/playwright/control-ui/agent-connectors-tab.spec.ts
index b613a13b0..960cf294a 100644
--- a/tests/e2e/playwright/control-ui/agent-connectors-tab.spec.ts
+++ b/tests/e2e/playwright/control-ui/agent-connectors-tab.spec.ts
@@ -59,7 +59,6 @@ test.describe('Control UI — Agent detail connectors tab', () => {
contextRef: contextName,
secretRef: '',
channels: [],
- model: { provider: 'openai', name: 'gpt-5.4-mini' },
},
})
diff --git a/tests/e2e/playwright/control-ui/agent-overview-connectors.spec.ts b/tests/e2e/playwright/control-ui/agent-overview-connectors.spec.ts
new file mode 100644
index 000000000..2fb772849
--- /dev/null
+++ b/tests/e2e/playwright/control-ui/agent-overview-connectors.spec.ts
@@ -0,0 +1,95 @@
+/**
+ * Control UI — Agent detail overview Connectors summary
+ *
+ * /agents/<name> opens the agent's Overview tab by default. The overview must
+ * summarize the agent's attached connectors (the count badge and the chip
+ * block derive from the private context's mcpServers enrichment) while the
+ * private context slug itself stays an implementation detail — it must never
+ * appear anywhere on the page.
+ */
+import { controlApi } from '../helpers/api-client'
+import { expect, test } from '../helpers/auth-fixture'
+import { CUI_DASHBOARD } from '../helpers/selectors'
+
+test.describe('Control UI — Agent overview Connectors summary', () => {
+ test.beforeEach(async ({ authedPage }) => {
+ await expect(authedPage.locator(CUI_DASHBOARD.HEADING)).toBeVisible()
+ })
+
+ test('overview shows the connectors count and chips without the context slug', async ({
+ authedPage,
+ }) => {
+ test.setTimeout(120_000)
+ const stamp = Date.now()
+ const agentName = `e2e-aoc-agent-${stamp}`
+ const contextName = `e2e-aoc-ctx-${stamp}`
+ const serverOne = `e2e-aoc-srv-a-${stamp}`
+ const serverTwo = `e2e-aoc-srv-b-${stamp}`
+ try {
+ // PRECONDITION (labeled setup): a private context carrying two MCP
+ // servers, plus a host bound to it — the overview summary derives from
+ // this context enrichment, not from the Host CR itself.
+ for (const serverName of [serverOne, serverTwo]) {
+ await controlApi.createMcpServer({
+ metadata: { name: serverName },
+ spec: {
+ image: 'clerum/mock-mcp-server:test',
+ contextRef: contextName,
+ enabled: true,
+ managed: true,
+ transport: {
+ type: 'streamableHttp',
+ port: 3000,
+ url: `http://${serverName}.mcp-server.svc.cluster.local:3000/mcp`,
+ },
+ },
+ })
+ }
+ await controlApi.createContext({
+ metadata: { name: contextName },
+ spec: {
+ contextId: contextName,
+ description: `Overview fixture for ${agentName}`,
+ mcpServers: [serverOne, serverTwo],
+ },
+ })
+ await controlApi.createHost({
+ metadata: { name: agentName },
+ spec: {
+ host: agentName,
+ contextRef: contextName,
+ secretRef: '',
+ channels: [],
+ },
+ })
+
+ // /agents/<name> without a tab segment opens the Overview by default.
+ await authedPage.goto(`/agents/${encodeURIComponent(agentName)}`)
+ await expect(authedPage.getByText(`Agent: ${agentName}`)).toBeVisible({ timeout: 15_000 })
+ await expect(authedPage.getByRole('region', { name: 'Lifecycle' })).toBeVisible()
+
+ // Connectors summary card: nav header with the count badge…
+ const connectorsCard = authedPage.getByRole('region', { name: 'Connectors', exact: true })
+ await expect(connectorsCard).toBeVisible({ timeout: 15_000 })
+ await expect(connectorsCard.locator('.cu-host-overview-nav-header__count')).toHaveText('2', {
+ timeout: 20_000,
+ })
+
+ // …and the chip block with both connector names.
+ const chips = connectorsCard.locator('.cu-host-overview-mcp__chip')
+ await expect(chips).toHaveCount(2, { timeout: 20_000 })
+ await expect(chips.filter({ hasText: serverOne })).toBeVisible()
+ await expect(chips.filter({ hasText: serverTwo })).toBeVisible()
+
+ // The private context slug never renders anywhere on the page.
+ await expect(authedPage.getByText(contextName)).toHaveCount(0)
+ const bodyText = await authedPage.locator('body').innerText()
+ expect(bodyText).not.toContain(contextName)
+ } finally {
+ await controlApi.ensureHostDeleted(agentName)
+ await controlApi.ensureMcpServerDeleted(serverOne)
+ await controlApi.ensureMcpServerDeleted(serverTwo)
+ await controlApi.ensureContextDeleted(contextName)
+ }
+ })
+})
diff --git a/tests/e2e/playwright/control-ui/agents-connectors-hover.spec.ts b/tests/e2e/playwright/control-ui/agents-connectors-hover.spec.ts
index bd10f8cd2..17d687e66 100644
--- a/tests/e2e/playwright/control-ui/agents-connectors-hover.spec.ts
+++ b/tests/e2e/playwright/control-ui/agents-connectors-hover.spec.ts
@@ -60,7 +60,6 @@ test.describe('Control UI — Agents list connectors hover card', () => {
contextRef: contextName,
secretRef: '',
channels: [],
- model: { provider: 'openai', name: 'gpt-5.4-mini' },
},
})
diff --git a/tests/e2e/playwright/control-ui/connector-create-access-step.spec.ts b/tests/e2e/playwright/control-ui/connector-create-access-step.spec.ts
index 70f20cd6d..955bc7920 100644
--- a/tests/e2e/playwright/control-ui/connector-create-access-step.spec.ts
+++ b/tests/e2e/playwright/control-ui/connector-create-access-step.spec.ts
@@ -145,7 +145,6 @@ test.describe('Control UI — Connector create Access step', () => {
contextRef: contextName,
secretRef: '',
channels: [],
- model: { provider: 'openai', name: 'gpt-5.4-mini' },
},
})
})
diff --git a/tests/e2e/playwright/control-ui/connector-edit-access-tab.spec.ts b/tests/e2e/playwright/control-ui/connector-edit-access-tab.spec.ts
index b7f9b427d..d68ea8492 100644
--- a/tests/e2e/playwright/control-ui/connector-edit-access-tab.spec.ts
+++ b/tests/e2e/playwright/control-ui/connector-edit-access-tab.spec.ts
@@ -56,7 +56,6 @@ test.describe('Control UI — Connector edit Access tab', () => {
contextRef: contextName,
secretRef: '',
channels: [],
- model: { provider: 'openai', name: 'gpt-5.4-mini' },
},
})
diff --git a/tests/e2e/playwright/control-ui/connectors-agent-access.spec.ts b/tests/e2e/playwright/control-ui/connectors-agent-access.spec.ts
index 2274004ae..5adb1f364 100644
--- a/tests/e2e/playwright/control-ui/connectors-agent-access.spec.ts
+++ b/tests/e2e/playwright/control-ui/connectors-agent-access.spec.ts
@@ -73,7 +73,6 @@ test.describe('Control UI — Connectors agent access', () => {
contextRef,
secretRef: '',
channels: [],
- model: { provider: 'openai', name: 'gpt-5.4-mini' },
},
})
}
diff --git a/tests/e2e/playwright/control-ui/contexts.spec.ts b/tests/e2e/playwright/control-ui/contexts.spec.ts
index ea0ca8fce..5d70cf318 100644
--- a/tests/e2e/playwright/control-ui/contexts.spec.ts
+++ b/tests/e2e/playwright/control-ui/contexts.spec.ts
@@ -55,7 +55,11 @@ test.describe('Control UI — Contexts removal', () => {
await controlApi.ensureContextDeleted(ctxName)
await controlApi.createContext({
metadata: { name: ctxName },
- spec: { contextId: ctxName, description: 'contexts.spec.ts redirect fixture' },
+ spec: {
+ contextId: ctxName,
+ description: 'contexts.spec.ts redirect fixture',
+ mcpServers: [],
+ },
})
await controlApi.ensureHostDeleted(hostName)
await controlApi.createHost({
@@ -65,7 +69,6 @@ test.describe('Control UI — Contexts removal', () => {
contextRef: ctxName,
secretRef: '',
channels: [],
- model: { provider: 'openai', name: 'gpt-5.4-mini' },
},
})
diff --git a/tests/e2e/playwright/control-ui/global-no-context-vocab.spec.ts b/tests/e2e/playwright/control-ui/global-no-context-vocab.spec.ts
index a0ce3db3d..6028a2538 100644
--- a/tests/e2e/playwright/control-ui/global-no-context-vocab.spec.ts
+++ b/tests/e2e/playwright/control-ui/global-no-context-vocab.spec.ts
@@ -6,8 +6,10 @@
*
* Approach (chosen deliberately, one rule): every swept route renders through
* DashboardLayout's <main>, so each page is asserted on its main-content text
- * (body as fallback). The single exception is /plugins, whose table rows show
- * user-authored recipe names we do not control — for that page only, the
+ * (body as fallback). The exceptions are routes whose tables show
+ * data-derived names we do not control — /plugins (user-authored recipe
+ * names), /connectors, and /marketplace/connectors (deployed connector and
+ * marketplace package names/descriptions). For those routes only, the
* assertion is scoped to product-owned static chrome (sidebar, panel titles,
* subtitles, headings), which cannot be polluted by data-derived names.
*
@@ -28,7 +30,14 @@ const SWEPT_ROUTES = [
'/cost-and-usage/token-budgets',
] as const
-// Product-owned chrome for the /plugins exception (see header comment).
+// Routes whose table rows show data-derived text (see header comment): the
+// sweep is scoped to product-owned static chrome instead of the full main.
+const STATIC_CHROME_ROUTES: ReadonlySet<string> = new Set([
+ '/connectors',
+ '/marketplace/connectors',
+])
+
+// Product-owned chrome for the static-chrome exception (see header comment).
const STATIC_CHROME_SELECTOR = '.cu-sidebar, .cu-panel-title, .cu-table-panel__subtitle, h1, h2, h3'
function offendingLines(text: string): string[] {
@@ -45,12 +54,26 @@ async function mainText(page: Page): Promise<string> {
return page.locator('body').innerText()
}
+async function chromeText(page: Page): Promise<string> {
+ const chrome = page.locator(STATIC_CHROME_SELECTOR)
+ const count = await chrome.count()
+ const texts: string[] = []
+ for (let i = 0; i < count; i++) {
+ texts.push(await chrome.nth(i).innerText())
+ }
+ return texts.join('\n')
+}
+
for (const route of SWEPT_ROUTES) {
test(`"${route}" shows no context vocabulary`, async ({ authedPage }) => {
await authedPage.goto(route)
await expect(authedPage.locator('main').first()).toBeVisible({ timeout: 15_000 })
- const text = await mainText(authedPage)
+ const isChromeRoute = STATIC_CHROME_ROUTES.has(route)
+ if (isChromeRoute) {
+ await expect(authedPage.locator('.cu-panel-title').first()).toBeVisible({ timeout: 15_000 })
+ }
+ const text = isChromeRoute ? await chromeText(authedPage) : await mainText(authedPage)
const offending = offendingLines(text)
expect(
offending,
@@ -64,14 +87,7 @@ test('"/plugins" static chrome shows no context vocabulary', async ({ authedPage
await expect(authedPage.locator('main').first()).toBeVisible({ timeout: 15_000 })
await expect(authedPage.locator('.cu-panel-title').first()).toBeVisible({ timeout: 15_000 })
- const chrome = authedPage.locator(STATIC_CHROME_SELECTOR)
- const count = await chrome.count()
- const texts: string[] = []
- for (let i = 0; i < count; i++) {
- texts.push(await chrome.nth(i).innerText())
- }
-
- const offending = offendingLines(texts.join('\n'))
+ const offending = offendingLines(await chromeText(authedPage))
expect(
offending,
`"/plugins" chrome must not use context vocabulary; offending lines: ${offending.join(' | ')}`
diff --git a/tests/e2e/playwright/control-ui/hosts.spec.ts b/tests/e2e/playwright/control-ui/hosts.spec.ts
index 7bb929d98..0b409bcd3 100644
--- a/tests/e2e/playwright/control-ui/hosts.spec.ts
+++ b/tests/e2e/playwright/control-ui/hosts.spec.ts
@@ -138,9 +138,10 @@ test.describe('Control UI — Hosts', () => {
test('Create Host button opens the create-agent page', async ({ authedPage }) => {
await authedPage.click(CUI_DASHBOARD.CREATE_HOST_BUTTON)
- // The create flow is a canonical page (/hosts/new) titled "Create agent",
- // not a modal — assert the route AND the page heading.
- await expect(authedPage).toHaveURL(/\/hosts\/new/, { timeout: 10_000 })
+ // The create flow is a canonical page (permanently redirected from
+ // /hosts/new to /agents/new) titled "Create agent", not a modal — assert
+ // the route AND the page heading.
+ await expect(authedPage).toHaveURL(/\/agents\/new/, { timeout: 10_000 })
await expect(
authedPage.getByRole('heading', { name: 'Create agent', exact: true })
).toBeVisible({ timeout: 10_000 })
@@ -148,11 +149,11 @@ test.describe('Control UI — Hosts', () => {
test('create-agent page can be left via Back to agents', async ({ authedPage }) => {
await authedPage.click(CUI_DASHBOARD.CREATE_HOST_BUTTON)
- await expect(authedPage).toHaveURL(/\/hosts\/new/, { timeout: 10_000 })
+ await expect(authedPage).toHaveURL(/\/agents\/new/, { timeout: 10_000 })
await dismissAdminEmailPromptIfPresent(authedPage)
await authedPage.getByRole('button', { name: 'Back to agents' }).click()
- // Back on the hosts list, the create action is available again
- await expect(authedPage).toHaveURL(/\/hosts(?!\/new)/, { timeout: 10_000 })
+ // Back on the agents list, the create action is available again
+ await expect(authedPage).toHaveURL(/\/agents(?!\/new)/, { timeout: 10_000 })
await expect(authedPage.locator(CUI_DASHBOARD.CREATE_HOST_BUTTON)).toBeVisible()
})
@@ -169,8 +170,9 @@ test.describe('Control UI — Hosts', () => {
* Stateless Agents (Host spec.lifecycle.stateless)
*
* Covers the three lifecycle flows added with the Agent type selector:
- * a) create flow — selecting "Stateless (suspends when idle)" in the wizard
- * lands spec.lifecycle.stateless=true on the created Host CR
+ * a) create flow — the "Stateless (suspends when idle)" selector is NOT
+ * offered on create (SHOW_STATELESS_AGENT_SELECTOR=false), so the wizard
+ * lands a stateful Host CR
* b) edit flow — saving an unrelated field on a stateless host preserves the
* flag (the admin facade full-replaces the spec)
* c) channel ingress — a CommunicationChannel remains attachable to a
@@ -215,7 +217,7 @@ test.describe('Control UI — Stateless Agents', () => {
await expect(authedPage.locator(CUI_DASHBOARD.HEADING)).toBeVisible()
})
- test('create flow: Stateless selection lands spec.lifecycle.stateless=true on the Host CR', async ({
+ test('create flow: wizard offers no stateless selector and lands a stateful Host CR', async ({
authedPage,
}) => {
test.setTimeout(180_000)
@@ -224,7 +226,7 @@ test.describe('Control UI — Stateless Agents', () => {
const secretName = `${agentName}-secret`
try {
// PRECONDITION (labeled setup): a managed host secret for the picker.
- // The wizard's "Use existing secret" list is label-filtered
+ // The wizard's "Use an existing LLM Secret" list is label-filtered
// (clerum.io/host-secret) and a fresh profile has none -- depending on
// pre-existing environment secrets would be shared-state flakiness.
await controlApi.createHostSecret(secretName, {
@@ -232,24 +234,23 @@ test.describe('Control UI — Stateless Agents', () => {
})
await authedPage.click(CUI_DASHBOARD.CREATE_HOST_BUTTON)
- await expect(authedPage).toHaveURL(/\/hosts\/new/, { timeout: 10_000 })
+ await expect(authedPage).toHaveURL(/\/agents\/new/, { timeout: 10_000 })
await expect(
authedPage.getByRole('heading', { name: 'Create agent', exact: true })
).toBeVisible({ timeout: 10_000 })
await dismissAdminEmailPromptIfPresent(authedPage)
- // Step 0 — agent name + Agent type
+ // Step 0 — agent name only: the Agent type (stateless) selector is not
+ // offered on create while SHOW_STATELESS_AGENT_SELECTOR is false.
await authedPage.getByPlaceholder('agent-name').fill(agentName)
- const statelessRadio = authedPage.getByRole('radio', {
- name: /Stateless \(suspends when idle\)/,
- })
- await statelessRadio.check()
- await expect(statelessRadio).toBeChecked()
+ await expect(
+ authedPage.getByRole('radio', { name: /Stateless \(suspends when idle\)/ })
+ ).toHaveCount(0)
await authedPage.getByRole('button', { name: 'Next', exact: true }).click()
// Step 1 — keep the default model, reuse the first existing secret
- await authedPage.getByRole('radio', { name: /Use existing secret/ }).check()
- await authedPage.getByRole('button', { name: /Select secret/ }).click()
+ await authedPage.getByRole('radio', { name: 'Use an existing LLM Secret' }).check()
+ await authedPage.getByRole('button', { name: 'Select LLM Secret...' }).click()
// Deterministic pick: the exact secret this test seeded, never .first()
const seededSecret = authedPage.getByRole('option', { name: new RegExp(secretName) })
await expect(seededSecret).toBeVisible({ timeout: 10_000 })
@@ -259,19 +260,19 @@ test.describe('Control UI — Stateless Agents', () => {
// Step 2 — access grants are optional
await authedPage.getByRole('button', { name: 'Next', exact: true }).click()
- // Step 3 — no connector is needed for this flag-only flow.
+ // Step 3 — no connector is needed for this flow.
await authedPage.getByRole('button', { name: 'Create Agent', exact: true }).click()
// Completion leaves the create page (canonical routing) — the CR poll
// below is the business signal; this asserts the UI transition.
- await expect(authedPage).not.toHaveURL(/\/hosts\/new/, { timeout: 30_000 })
+ await expect(authedPage).not.toHaveURL(/\/agents\/new/, { timeout: 30_000 })
const created = await waitForHostCr(
agentName,
- host => host.spec?.lifecycle?.stateless === true,
- 'spec.lifecycle.stateless=true'
+ host => Boolean(host.metadata?.name),
+ 'Host CR created'
)
contextName = String(created.spec?.contextRef || '')
- expect(created.spec?.lifecycle?.stateless).toBe(true)
+ expect(created.spec?.lifecycle?.stateless).not.toBe(true)
} finally {
await controlApi.ensureHostDeleted(agentName)
if (contextName) await controlApi.ensureContextDeleted(contextName)
@@ -311,9 +312,9 @@ test.describe('Control UI — Stateless Agents', () => {
})
// Edit an UNRELATED field and save — the flag must survive the full replace
- await authedPage.getByRole('button', { name: 'Edit', exact: true }).first().click()
- await authedPage.getByLabel('Display ID').fill(`${agentName}-updated`)
- await authedPage.getByRole('button', { name: 'Save', exact: true }).click()
+ await authedPage.getByRole('button', { name: 'Edit agent name' }).first().click()
+ await authedPage.getByLabel('Agent name').fill(`${agentName}-updated`)
+ await authedPage.getByRole('button', { name: 'Save agent name' }).click()
const savedToast = authedPage.getByText('Agent configuration saved.')
try {
await expect(savedToast).toBeVisible({ timeout: 15_000 })
@@ -326,9 +327,9 @@ test.describe('Control UI — Stateless Agents', () => {
await expect(authedPage.getByText('Stateless (suspends when idle)')).toBeVisible({
timeout: 15_000,
})
- await authedPage.getByRole('button', { name: 'Edit', exact: true }).first().click()
- await authedPage.getByLabel('Display ID').fill(`${agentName}-updated`)
- await authedPage.getByRole('button', { name: 'Save', exact: true }).click()
+ await authedPage.getByRole('button', { name: 'Edit agent name' }).first().click()
+ await authedPage.getByLabel('Agent name').fill(`${agentName}-updated`)
+ await authedPage.getByRole('button', { name: 'Save agent name' }).click()
await expect(savedToast).toBeVisible({ timeout: 15_000 })
}
@@ -437,7 +438,7 @@ test.describe('Control UI — Concurrent edit protection (AP-6)', () => {
// (a) the facade retries the stale payload into the server: the business
// signal (controlApi.getHost) would see the out-of-band change
// overwritten by the stale form echo;
- // (b) the UI silently exits edit mode on 409: the Display ID input
+ // (b) the UI silently exits edit mode on 409: the Agent name input
// visibility + draft-value assertions fail;
// (c) the conflict banner never renders: the visible-UI assertion fails;
// (d) recovery-after-reload is broken: reload → edit → save no longer
@@ -477,8 +478,8 @@ test.describe('Control UI — Concurrent edit protection (AP-6)', () => {
await expect(authedPage.getByText('Stateless (suspends when idle)')).toBeVisible({
timeout: 15_000,
})
- await authedPage.getByRole('button', { name: 'Edit', exact: true }).first().click()
- const displayIdInput = authedPage.getByLabel('Display ID')
+ await authedPage.getByRole('button', { name: 'Edit agent name' }).first().click()
+ const displayIdInput = authedPage.getByLabel('Agent name')
await expect(displayIdInput).toBeVisible()
// OUT-OF-BAND CHANGE (labeled precondition of the collision, NOT a
@@ -494,7 +495,7 @@ test.describe('Control UI — Concurrent edit protection (AP-6)', () => {
// Back in the UI: change an UNRELATED field on the stale form and save.
await displayIdInput.fill(staleDraftDisplayId)
- await authedPage.getByRole('button', { name: 'Save', exact: true }).click()
+ await authedPage.getByRole('button', { name: 'Save agent name' }).click()
// ASSERT (a) visible UI — the conflict banner renders and the edit form
// stays open with the operator's draft intact.
@@ -517,9 +518,9 @@ test.describe('Control UI — Concurrent edit protection (AP-6)', () => {
await expect(authedPage.getByText(`Agent: ${agentName}`)).toBeVisible({ timeout: 15_000 })
// The out-of-band change is now visible in the form (flag removed).
await expect(authedPage.getByText('Stateful (always on)')).toBeVisible({ timeout: 15_000 })
- await authedPage.getByRole('button', { name: 'Edit', exact: true }).first().click()
- await authedPage.getByLabel('Display ID').fill(recoveredDisplayId)
- await authedPage.getByRole('button', { name: 'Save', exact: true }).click()
+ await authedPage.getByRole('button', { name: 'Edit agent name' }).first().click()
+ await authedPage.getByLabel('Agent name').fill(recoveredDisplayId)
+ await authedPage.getByRole('button', { name: 'Save agent name' }).click()
await expect(authedPage.getByText('Agent configuration saved.')).toBeVisible({
timeout: 15_000,
})
diff --git a/tests/e2e/playwright/control-ui/mcp-servers.spec.ts b/tests/e2e/playwright/control-ui/mcp-servers.spec.ts
index a04f0aa1b..88a4275a3 100644
--- a/tests/e2e/playwright/control-ui/mcp-servers.spec.ts
+++ b/tests/e2e/playwright/control-ui/mcp-servers.spec.ts
@@ -1,42 +1,51 @@
/**
- * Control UI — MCP Servers tab tests
+ * Control UI — Connectors tab tests
*
- * Validates the MCP Servers view (read-only ResourceTable).
+ * Validates the Connectors view (read-only ResourceTable). Strings follow
+ * components/McpServerTable.tsx: the "Connectors (N)" panel title, the
+ * "Install from Marketplace" action, creation behind the "Connector actions"
+ * kebab, and the per-row "Actions for connector <name>" kebab.
*/
import { expect, test } from '../helpers/auth-fixture'
import { CUI_DASHBOARD } from '../helpers/selectors'
-test.describe('Control UI — MCP Servers', () => {
+test.describe('Control UI — Connectors', () => {
test.beforeEach(async ({ authedPage }) => {
await expect(authedPage.locator(CUI_DASHBOARD.HEADING)).toBeVisible()
await authedPage.click(CUI_DASHBOARD.TAB_MCP_SERVERS)
})
- test('MCP Servers tab shows resource table heading', async ({ authedPage }) => {
+ test('Connectors tab shows resource table heading', async ({ authedPage }) => {
const heading = authedPage
.locator('main')
- .getByText(/^MCP Servers \(\d+\)$/)
+ .getByText(/^Connectors \(\d+\)$/)
.first()
await expect(heading.first()).toBeVisible({ timeout: 15_000 })
})
- test('MCP Servers tab shows install/create actions and row-level remove action', async ({
+ test('Connectors tab shows install/create actions and row-level actions', async ({
authedPage,
}) => {
- await expect(authedPage.getByRole('button', { name: 'Install from Registry' })).toBeVisible()
- await expect(authedPage.getByRole('button', { name: 'Create MCP Server' })).toBeVisible()
+ await expect(authedPage.getByRole('button', { name: 'Install from Marketplace' })).toBeVisible()
+ // Creation lives behind the "Connector actions" kebab (lowercase c menuitem).
+ const connectorActions = authedPage.getByRole('button', { name: 'Connector actions' })
+ await expect(connectorActions).toBeVisible()
+ await connectorActions.click()
+ await expect(
+ authedPage.getByRole('menuitem', { name: 'Create connector', exact: true })
+ ).toBeVisible()
await expect(authedPage.locator(CUI_DASHBOARD.CREATE_HOST_BUTTON)).toBeHidden()
await expect(
authedPage
.locator('tbody tr')
.first()
- .getByRole('button', { name: /Remove MCP server/i })
+ .getByRole('button', { name: /^Actions for connector / })
).toBeVisible()
})
- test('shows at least the chatllm MCP server entries', async ({ authedPage }) => {
+ test('shows at least the chatllm connector entries', async ({ authedPage }) => {
const tableOrEmpty = authedPage.locator('table, p, div').filter({
- hasText: /chatllm|mongodb|No MCP/i,
+ hasText: /chatllm|mongodb|No connectors/i,
})
await expect(tableOrEmpty.first()).toBeVisible({ timeout: 15_000 })
})
diff --git a/tests/e2e/playwright/control-ui/member-access-shared-label.spec.ts b/tests/e2e/playwright/control-ui/member-access-shared-label.spec.ts
new file mode 100644
index 000000000..9b7c90819
--- /dev/null
+++ b/tests/e2e/playwright/control-ui/member-access-shared-label.spec.ts
@@ -0,0 +1,118 @@
+/**
+ * Control UI — Member Access tab shared-scope label
+ *
+ * A single access scope (Context) may back multiple hosts. The member
+ * "Access" tab must render that shared scope as ONE row labelled with both
+ * agent display names joined by ", " (lib/accessScopeLabels sorts the owner
+ * names), never as two rows and never as the raw wire contextId. The remove
+ * flow's confirm dialog repeats the same joined label.
+ */
+import { controlApi } from '../helpers/api-client'
+import { expect, test } from '../helpers/auth-fixture'
+
+const RUN = Date.now()
+const CONTEXT_NAME = `e2e-member-shared-ctx-${RUN}`
+const CONTEXT_ID = `e2e-member-shared-scope-${RUN}`
+const HOST_NAME_A = `e2e-member-shared-host-a-${RUN}`
+const HOST_NAME_B = `e2e-member-shared-host-b-${RUN}`
+const HOST_DISPLAY_A = `e2e-member-shared-agent-a-${RUN}`
+const HOST_DISPLAY_B = `e2e-member-shared-agent-b-${RUN}`
+// accessScopeLabels joins the sorted owner names with ", " — the "a" agent
+// sorts before the "b" agent, so the joined label is deterministic.
+const JOINED_LABEL = `${HOST_DISPLAY_A}, ${HOST_DISPLAY_B}`
+
+let userId = ''
+let originalContextIds: string[] = []
+
+test.describe('Control UI — Member Access shared scope label', () => {
+ test.describe.configure({ mode: 'serial' })
+
+ test.beforeAll(async () => {
+ const { items } = await controlApi.getUsers('')
+ if (items.length === 0) {
+ test.skip(true, 'no users seeded — run: make minikube-seed-test-data')
+ return
+ }
+ userId = items[0].id
+ originalContextIds = (await controlApi.getUserContexts(userId)).contextIds ?? []
+
+ // One scope shared by two hosts.
+ await controlApi.createContext({
+ metadata: { name: CONTEXT_NAME },
+ spec: { contextId: CONTEXT_ID, description: 'E2E member shared access scope' },
+ })
+ for (const [hostName, hostDisplay] of [
+ [HOST_NAME_A, HOST_DISPLAY_A],
+ [HOST_NAME_B, HOST_DISPLAY_B],
+ ] as const) {
+ await controlApi.createHost({
+ metadata: { name: hostName },
+ spec: {
+ host: hostDisplay,
+ contextRef: CONTEXT_ID,
+ secretRef: '',
+ channels: [],
+ },
+ })
+ }
+ await controlApi.updateUserContexts(userId, [...originalContextIds, CONTEXT_ID])
+ })
+
+ test.afterAll(async () => {
+ if (userId) {
+ try {
+ await controlApi.updateUserContexts(userId, originalContextIds)
+ } catch {
+ // best effort restore — cluster may already be unreachable
+ }
+ }
+ await controlApi.ensureHostDeleted(HOST_NAME_A)
+ await controlApi.ensureHostDeleted(HOST_NAME_B)
+ await controlApi.ensureContextDeleted(CONTEXT_NAME)
+ })
+
+ test('renders one row with the joined agent names, not two rows or raw ids', async ({
+ authedPage,
+ }) => {
+ await authedPage.goto(`/users-and-teams/users/${encodeURIComponent(userId)}/access`)
+ await expect(
+ authedPage.getByText('Agents and connector scopes this member may access.')
+ ).toBeVisible({ timeout: 15_000 })
+
+ // Exactly one row carries the joined "A, B" label…
+ const row = authedPage
+ .getByRole('row')
+ .filter({ has: authedPage.getByRole('cell', { name: JOINED_LABEL, exact: true }) })
+ await expect(row).toHaveCount(1)
+ await expect(row).not.toContainText(CONTEXT_ID)
+
+ // …and neither agent appears as its own row (shared scope, not two scopes).
+ await expect(authedPage.getByRole('cell', { name: HOST_DISPLAY_A, exact: true })).toHaveCount(0)
+ await expect(authedPage.getByRole('cell', { name: HOST_DISPLAY_B, exact: true })).toHaveCount(0)
+ })
+
+ test('remove confirm dialog shows the joined label', async ({ authedPage }) => {
+ await authedPage.goto(`/users-and-teams/users/${encodeURIComponent(userId)}/access`)
+ const row = authedPage
+ .getByRole('row')
+ .filter({ has: authedPage.getByRole('cell', { name: JOINED_LABEL, exact: true }) })
+ await expect(row).toBeVisible({ timeout: 15_000 })
+
+ await row.getByLabel('Remove access').click()
+
+ const confirmDialog = authedPage.getByRole('alertdialog', { name: 'Remove Access' })
+ await expect(confirmDialog).toBeVisible()
+ await expect(confirmDialog).toContainText(JOINED_LABEL)
+ await expect(confirmDialog).not.toContainText(CONTEXT_ID)
+
+ await confirmDialog.getByRole('button', { name: 'Remove access', exact: true }).click()
+
+ await expect(authedPage.getByRole('status').filter({ hasText: 'Access updated.' })).toBeVisible(
+ { timeout: 15_000 }
+ )
+ await expect(row).toHaveCount(0)
+
+ const { contextIds } = await controlApi.getUserContexts(userId)
+ expect(contextIds ?? []).not.toContain(CONTEXT_ID)
+ })
+})
diff --git a/tests/e2e/playwright/control-ui/member-access-tab.spec.ts b/tests/e2e/playwright/control-ui/member-access-tab.spec.ts
index 7b67f5a98..200f158d9 100644
--- a/tests/e2e/playwright/control-ui/member-access-tab.spec.ts
+++ b/tests/e2e/playwright/control-ui/member-access-tab.spec.ts
@@ -40,7 +40,6 @@ test.describe('Control UI — Member Access tab', () => {
contextRef: CONTEXT_ID,
secretRef: '',
channels: [],
- model: { provider: 'openai', name: 'gpt-5.4-mini' },
},
})
await controlApi.updateUserContexts(userId, [...originalContextIds, CONTEXT_ID])
diff --git a/tests/e2e/playwright/control-ui/team-access-tab.spec.ts b/tests/e2e/playwright/control-ui/team-access-tab.spec.ts
index 50ba0363c..33d275b82 100644
--- a/tests/e2e/playwright/control-ui/team-access-tab.spec.ts
+++ b/tests/e2e/playwright/control-ui/team-access-tab.spec.ts
@@ -36,7 +36,6 @@ test.describe('Control UI — Team Access tab', () => {
contextRef: CONTEXT_ID,
secretRef: '',
channels: [],
- model: { provider: 'openai', name: 'gpt-5.4-mini' },
},
})
await controlApi.updateTeamContexts(teamId, [CONTEXT_ID])
@@ -57,9 +56,8 @@ test.describe('Control UI — Team Access tab', () => {
authedPage.getByText('Agents and connector scopes this team may access.')
).toBeVisible()
- const row = authedPage
- .getByRole('row')
- .filter({ has: authedPage.getByRole('cell', { name: HOST_DISPLAY_NAME, exact: true }) })
+ // Access rows are role="listitem" divs (.cu-access-row), not table rows.
+ const row = authedPage.getByRole('listitem').filter({ hasText: HOST_DISPLAY_NAME })
await expect(row).toHaveCount(1)
await expect(row).not.toContainText(CONTEXT_ID)
})
@@ -84,9 +82,7 @@ test.describe('Control UI — Team Access tab', () => {
authedPage,
}) => {
await authedPage.goto(`/users-and-teams/teams/${encodeURIComponent(teamId)}/access`)
- const row = authedPage
- .getByRole('row')
- .filter({ has: authedPage.getByRole('cell', { name: HOST_DISPLAY_NAME, exact: true }) })
+ const row = authedPage.getByRole('listitem').filter({ hasText: HOST_DISPLAY_NAME })
await expect(row).toBeVisible({ timeout: 15_000 })
await row.getByLabel('Remove access').click()
diff --git a/tests/e2e/playwright/control-ui/team-create-wizard.spec.ts b/tests/e2e/playwright/control-ui/team-create-wizard.spec.ts
index ce834831c..3bb4b0552 100644
--- a/tests/e2e/playwright/control-ui/team-create-wizard.spec.ts
+++ b/tests/e2e/playwright/control-ui/team-create-wizard.spec.ts
@@ -41,7 +41,6 @@ test.describe('Control UI — Team create wizard', () => {
contextRef: CONTEXT_ID,
secretRef: '',
channels: [],
- model: { provider: 'openai', name: 'gpt-5.4-mini' },
},
})
})
@@ -105,9 +104,8 @@ test.describe('Control UI — Team create wizard', () => {
expect(contextIds ?? []).toContain(CONTEXT_ID)
await authedPage.goto(`/users-and-teams/teams/${encodeURIComponent(teamId)}/access`)
- const row = authedPage
- .getByRole('row')
- .filter({ has: authedPage.getByRole('cell', { name: HOST_DISPLAY_NAME, exact: true }) })
+ // Access rows are role="listitem" divs (.cu-access-row), not table rows.
+ const row = authedPage.getByRole('listitem').filter({ hasText: HOST_DISPLAY_NAME })
await expect(row).toBeVisible({ timeout: 15_000 })
await expect(row).not.toContainText(CONTEXT_ID)
})
diff --git a/tests/e2e/playwright/control-ui/team-delete-warning-copy.spec.ts b/tests/e2e/playwright/control-ui/team-delete-warning-copy.spec.ts
new file mode 100644
index 000000000..0db81078c
--- /dev/null
+++ b/tests/e2e/playwright/control-ui/team-delete-warning-copy.spec.ts
@@ -0,0 +1,52 @@
+/**
+ * Control UI — Team delete warning copy
+ *
+ * Deleting a team removes its access scopes. The confirm dialog on
+ * /users-and-teams/teams must warn about "team access/agent mappings" and
+ * must not use the removed "context" vocabulary. The journey cancels out —
+ * the team is never deleted by this test.
+ */
+import { controlApi } from '../helpers/api-client'
+import { expect, test } from '../helpers/auth-fixture'
+
+const RUN = Date.now()
+const TEAM_NAME = `e2e-team-del-team-${RUN}`
+
+let teamId = ''
+
+test.describe('Control UI — Team delete warning copy', () => {
+ test.describe.configure({ mode: 'serial' })
+
+ test.beforeAll(async () => {
+ const team = await controlApi.createTeam(TEAM_NAME)
+ teamId = team.id
+ })
+
+ test.afterAll(async () => {
+ if (teamId) await controlApi.ensureTeamDeleted(teamId)
+ })
+
+ test('delete confirm warns about team access/agent mappings without "context", cancel keeps the team', async ({
+ authedPage,
+ }) => {
+ await authedPage.goto('/users-and-teams/teams')
+
+ const deleteButton = authedPage.getByLabel(`Delete team ${TEAM_NAME}`)
+ await expect(deleteButton).toBeVisible({ timeout: 15_000 })
+ await deleteButton.click()
+
+ const confirmDialog = authedPage.getByRole('alertdialog', { name: 'Delete team?' })
+ await expect(confirmDialog).toBeVisible()
+
+ const dialogText = await confirmDialog.innerText()
+ expect(dialogText).toContain('team access/agent mappings')
+ expect(dialogText.toLowerCase()).not.toContain('context')
+
+ // Cancel out — the team must survive.
+ await confirmDialog.getByRole('button', { name: 'Cancel', exact: true }).click()
+ await expect(confirmDialog).toHaveCount(0)
+
+ const { items } = await controlApi.getTeams()
+ expect(items.some(team => team.id === teamId)).toBe(true)
+ })
+})
diff --git a/tests/e2e/playwright/helpers/api-client.ts b/tests/e2e/playwright/helpers/api-client.ts
index 16a441638..85a91409e 100644
--- a/tests/e2e/playwright/helpers/api-client.ts
+++ b/tests/e2e/playwright/helpers/api-client.ts
@@ -71,7 +71,7 @@ export const controlApi = {
},
async getUsers(query = ''): Promise<{ items: AdminUser[] }> {
- const qs = query ? `?query=${encodeURIComponent(query)}` : ''
+ const qs = query ? `?q=${encodeURIComponent(query)}` : ''
return apiFetch<{ items: AdminUser[] }>('GET', `/api/v1/admin/users${qs}`)
},
diff --git a/tests/e2e/playwright/package-lock.json b/tests/e2e/playwright/package-lock.json
index 80b194f1c..d52deb104 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.23",
+ "version": "0.1.24",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-playwright-tests",
- "version": "0.1.23",
+ "version": "0.1.24",
"devDependencies": {
"@playwright/test": "^1.50.0",
"@types/node": "^22.0.0"
diff --git a/tests/e2e/playwright/package.json b/tests/e2e/playwright/package.json
index 1d24934b2..30debefd9 100644
--- a/tests/e2e/playwright/package.json
+++ b/tests/e2e/playwright/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-playwright-tests",
- "version": "0.1.23",
+ "version": "0.1.24",
"private": true,
"description": "Playwright E2E tests for Control UI and Desktop App",
"scripts": {