Skip to content

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

TypeScript

fix(desktop): make layout E2E producer-backed

Josué3fedbc31de59
diff --git a/desktop-app/test/e2e-playwright/qa-recorder-apps.spec.ts b/desktop-app/test/e2e-playwright/qa-recorder-apps.spec.ts
index 7e92f2cf3..af88a607a 100644
--- a/desktop-app/test/e2e-playwright/qa-recorder-apps.spec.ts
+++ b/desktop-app/test/e2e-playwright/qa-recorder-apps.spec.ts
@@ -78,37 +78,6 @@ test('optional QA recorder: Desktop apps journey', async ({}, testInfo) => {
const mounted = backButton.or(loadingApp).or(embedPreview).first()
await expect(mounted).toBeVisible({ timeout: 20_000 })
- // The app header and its notification drawer share a horizontal budget.
- // Check their rendered rectangles at the constrained desktop width so a
- // change cannot let the search overlap mounted-app controls again.
- await app.evaluate(({ BrowserWindow }) => {
- const window = BrowserWindow.getFocusedWindow() ?? BrowserWindow.getAllWindows()[0]
- if (!window || window.isDestroyed()) throw new Error('Desktop BrowserWindow closed')
- window.setContentSize(1200, 720)
- })
- const bell = page.getByTestId('notification-bell')
- await expect(bell).toBeVisible({ timeout: 20_000 })
- await bell.click()
- const drawer = page.getByRole('dialog', { name: 'Notifications and approvals' })
- const search = page.getByRole('textbox', { name: 'Search' })
- const mountedHeader = page.locator('.sandbox-ui-mounted-header')
- await expect(drawer).toBeVisible({ timeout: 20_000 })
- await expect(search).toBeVisible({ timeout: 20_000 })
- await expect(mountedHeader).toBeVisible({ timeout: 20_000 })
- const [drawerBox, searchBox, headerMetrics] = await Promise.all([
- drawer.boundingBox(),
- search.boundingBox(),
- mountedHeader.evaluate(element => ({
- clientWidth: element.clientWidth,
- scrollWidth: element.scrollWidth,
- })),
- ])
- expect(drawerBox).not.toBeNull()
- expect(searchBox).not.toBeNull()
- expect(searchBox!.width).toBeLessThanOrEqual(drawerBox!.width)
- expect(headerMetrics.scrollWidth).toBeLessThanOrEqual(headerMetrics.clientWidth)
- await bell.click()
-
await screenshotAndLog(page, testInfo, 'desktop-apps-embedded')
// (3) Back action returns to the catalog. The Back button is part of the
diff --git a/desktop-app/test/e2e-playwright/responsive-layout-producer-backed.spec.ts b/desktop-app/test/e2e-playwright/responsive-layout-producer-backed.spec.ts
new file mode 100644
index 000000000..b0379121c
--- /dev/null
+++ b/desktop-app/test/e2e-playwright/responsive-layout-producer-backed.spec.ts
@@ -0,0 +1,211 @@
+import { type ElectronApplication, type Page, expect, test } from '@playwright/test'
+import { randomUUID } from 'node:crypto'
+import {
+ applySdkLayoutRecipe,
+ cleanupSdkWorkloadRecipe,
+ createSdkWorkloadGrants,
+ profilesSql,
+ purgeStaleSdkNotifications,
+ sqlLiteral,
+ waitForSdkSandboxUiNotification,
+} from './sdk-client-notification/sdkWorkloadFixture'
+import { HOST_REF } from './third-party-authn-first-party-mcphost/telegramE2eClient'
+import { createApproval, issueRuntimeTokens } from './workflow-approval-quadrants/approvalApi'
+import { WORKFLOW_RECIPE_NS } from './workflow-approval-quadrants/constants'
+import {
+ applyRecipe,
+ cleanupRecipe,
+ setUserWorkflowGrantsThroughAdminRoute,
+} from './workflow-approval-quadrants/recipes'
+import { E2E_EMAIL, RECIPE_NS, clearSession, launchAndLogin, loginAs } from './workflowUi'
+
+const LONG_CONVERSATION =
+ 'A deliberately long conversation label that must remain accessible while the visible return control truncates it'
+
+function assertNoIntersection(
+ first: { x: number; y: number; width: number; height: number },
+ second: { x: number; y: number; width: number; height: number }
+): void {
+ const intersects =
+ first.x < second.x + second.width &&
+ first.x + first.width > second.x &&
+ first.y < second.y + second.height &&
+ first.y + first.height > second.y
+ expect(intersects, 'header controls must not overlap').toBe(false)
+}
+
+async function resizeDesktop(app: ElectronApplication, width: number): Promise<void> {
+ await app.evaluate(({ BrowserWindow }, nextWidth) => {
+ const window = BrowserWindow.getFocusedWindow() ?? BrowserWindow.getAllWindows()[0]
+ if (!window || window.isDestroyed()) throw new Error('Desktop BrowserWindow closed')
+ window.setContentSize(nextWidth, 800)
+ }, width)
+}
+
+async function bounds(locator: ReturnType<Page['locator']>) {
+ const box = await locator.boundingBox()
+ expect(box, 'expected a visible layout element').not.toBeNull()
+ return box!
+}
+
+test('Desktop app tray layout is exercised with producer-backed notification and approval cards', async ({
+ request,
+}) => {
+ test.setTimeout(420_000)
+ const marker = Date.now().toString(36)
+ const appRecipe = `e2e-sdk-layout-${marker}`
+ const approvalRecipe = `e2e-quadrant-layout-${marker}`
+ const chatId = `layout-${randomUUID()}`
+ const runId = `layout-${marker}`
+ let app: Awaited<ReturnType<typeof launchAndLogin>>['app'] | undefined
+
+ try {
+ await clearSession()
+ const auth = await loginAs(E2E_EMAIL)
+ expect(auth.userId).toMatch(/^[0-9a-f-]{36}$/)
+ purgeStaleSdkNotifications(auth.userId)
+ cleanupSdkWorkloadRecipe(appRecipe)
+ await cleanupRecipe(approvalRecipe)
+
+ await test.step('establish a real mounted app, notification, pending approval, and chat origin', async () => {
+ applySdkLayoutRecipe(appRecipe, auth.userId, runId)
+ await createSdkWorkloadGrants(appRecipe, auth.userId, ['sandbox-ui'], false)
+ profilesSql(`
+ INSERT INTO user_workflow_triggers (user_id, recipe_namespace, recipe_name)
+ VALUES (${sqlLiteral(auth.userId)}, ${sqlLiteral(RECIPE_NS)}, ${sqlLiteral(appRecipe)})
+ ON CONFLICT DO NOTHING;
+ `)
+
+ applyRecipe(approvalRecipe, {
+ requiresApproval: true,
+ instruction: 'Producer-backed Desktop responsive-layout approval fixture.',
+ })
+ await setUserWorkflowGrantsThroughAdminRoute(WORKFLOW_RECIPE_NS, approvalRecipe, [
+ auth.userId,
+ ])
+
+ const tokens = await issueRuntimeTokens(request, 'wrc', WORKFLOW_RECIPE_NS, approvalRecipe)
+ const approvalId = await createApproval(
+ request,
+ tokens,
+ WORKFLOW_RECIPE_NS,
+ approvalRecipe,
+ auth.userId
+ )
+ expect(approvalId).toMatch(/^[0-9a-f-]{36}$/)
+
+ const launched = await launchAndLogin(E2E_EMAIL)
+ app = launched.app
+ const { page } = launched
+ await page.evaluate(
+ async ({ agentRef, nextChatId, title }) => {
+ await window.clerum.chat.create(agentRef, nextChatId)
+ await window.clerum.chat.rename(agentRef, nextChatId, title)
+ },
+ { agentRef: HOST_REF, nextChatId: chatId, title: LONG_CONVERSATION }
+ )
+
+ await page.getByTestId('nav-chat').click()
+ const conversation = page.getByRole('button', { name: `Open ${LONG_CONVERSATION}` })
+ await expect(conversation).toBeVisible({ timeout: 30_000 })
+ await conversation.click()
+
+ await page.getByTestId('nav-sandbox-ui').click()
+ const appButton = page.getByRole('button', { name: 'Open E2E Layout Notification App' })
+ await expect(appButton).toBeVisible({ timeout: 60_000 })
+ await appButton.click()
+ await expect(page.getByRole('button', { name: `Back to ${LONG_CONVERSATION}` })).toBeVisible({
+ timeout: 30_000,
+ })
+ await waitForSdkSandboxUiNotification(appRecipe)
+ })
+
+ const page = await app.firstWindow()
+ await test.step('desktop tray cards stay compact and top aligned', async () => {
+ await resizeDesktop(app!, 1200)
+ await page.getByTestId('notification-bell').click()
+ const tray = page.getByRole('dialog', { name: 'Notifications and approvals' })
+ const approval = tray
+ .getByTestId('workflow-approval-card')
+ .filter({ hasText: approvalRecipe })
+ const notification = tray
+ .getByTestId('notification-menu-item')
+ .filter({ hasText: 'Sent by the mounted Plugin Workload SDK Sandbox UI fixture.' })
+ await expect(approval).toBeVisible({ timeout: 30_000 })
+ await expect(notification).toBeVisible({ timeout: 30_000 })
+
+ for (const card of [approval, notification]) {
+ const geometry = await card.evaluate(element => {
+ const cardRect = element.getBoundingClientRect()
+ const listRect = element.parentElement?.getBoundingClientRect()
+ return {
+ height: cardRect.height,
+ offsetFromListTop: listRect ? cardRect.top - listRect.top : Number.NaN,
+ }
+ })
+ expect(geometry.height, 'tray cards must not stretch to fill the drawer').toBeLessThan(260)
+ expect(
+ geometry.offsetFromListTop,
+ 'tray cards must begin at their list top'
+ ).toBeLessThanOrEqual(1)
+ }
+ })
+
+ await test.step('desktop and mobile search geometry preserves each width contract', async () => {
+ await resizeDesktop(app!, 1100)
+ const tray = page.getByRole('dialog', { name: 'Notifications and approvals' })
+ const search = page.getByRole('textbox', { name: 'Search' })
+ await expect(search).toHaveAttribute('placeholder', /Search teams, contexts…/)
+ await expect(search).toHaveAttribute(
+ 'title',
+ 'Search teams, contexts, members, agents or connectors...'
+ )
+ const [trayBox, searchBox] = await Promise.all([bounds(tray), bounds(search)])
+ expect(searchBox.width).toBeLessThanOrEqual(trayBox.width)
+
+ await page.getByTestId('notification-bell').click()
+ await resizeDesktop(app!, 901)
+ const at901 = await bounds(search)
+ expect(at901.width).toBeGreaterThanOrEqual(160)
+
+ await resizeDesktop(app!, 900)
+ const [mobileSearch, mobileHeader] = await Promise.all([
+ bounds(search),
+ bounds(page.locator('.header-left')),
+ ])
+ expect(Math.round(mobileSearch.width)).toBe(Math.round(mobileHeader.width))
+ })
+
+ await test.step('long return label truncates while its full name and controls remain accessible', async () => {
+ await resizeDesktop(app!, 1100)
+ const returnButton = page.getByRole('button', { name: `Back to ${LONG_CONVERSATION}` })
+ await expect(returnButton).toHaveAttribute('title', `Back to ${LONG_CONVERSATION}`)
+ const visibleLabel = returnButton.locator('span')
+ const labelGeometry = await visibleLabel.evaluate(element => ({
+ clientWidth: element.clientWidth,
+ scrollWidth: element.scrollWidth,
+ }))
+ expect(labelGeometry.scrollWidth).toBeGreaterThan(labelGeometry.clientWidth)
+
+ const controls = page.locator('.sandbox-ui-mounted-header button')
+ const controlBoxes = await controls.evaluateAll(elements =>
+ elements.map(element => {
+ const rect = element.getBoundingClientRect()
+ return { x: rect.x, y: rect.y, width: rect.width, height: rect.height }
+ })
+ )
+ expect(new Set(controlBoxes.map(box => Math.round(box.y))).size).toBeGreaterThan(1)
+ const searchBox = await bounds(page.getByRole('textbox', { name: 'Search' }))
+ for (let index = 0; index < controlBoxes.length; index += 1) {
+ assertNoIntersection(controlBoxes[index]!, searchBox)
+ for (let other = index + 1; other < controlBoxes.length; other += 1) {
+ assertNoIntersection(controlBoxes[index]!, controlBoxes[other]!)
+ }
+ }
+ })
+ } finally {
+ await app?.close().catch(() => undefined)
+ cleanupSdkWorkloadRecipe(appRecipe)
+ await cleanupRecipe(approvalRecipe)
+ }
+})
diff --git a/desktop-app/test/e2e-playwright/sdk-client-notification/sdkWorkloadFixture.ts b/desktop-app/test/e2e-playwright/sdk-client-notification/sdkWorkloadFixture.ts
index f710b5c07..0c931dbc5 100644
--- a/desktop-app/test/e2e-playwright/sdk-client-notification/sdkWorkloadFixture.ts
+++ b/desktop-app/test/e2e-playwright/sdk-client-notification/sdkWorkloadFixture.ts
@@ -14,6 +14,10 @@ const SDK_RECIPE_FIXTURE = path.join(
REPO_ROOT,
'tests/e2e/fixtures/plugin-workload-sdk-recipe.yaml'
)
+const SDK_LAYOUT_RECIPE_FIXTURE = path.join(
+ REPO_ROOT,
+ 'tests/e2e/fixtures/plugin-workload-sdk-layout-recipe.yaml'
+)
const CONTROL_API = process.env.CONTROL_API_BASE_URL || 'http://127.0.0.1:8090'
const WORKLOAD_ID = 'sdk-caller'
const EVENT_TYPE = 'e2e.test.notification'
@@ -64,7 +68,11 @@ export function makeScopedSdkRecipeName(marker: string): string {
}
export function renderSdkWorkloadRecipeYaml(recipeName: string, userRef: string): string {
- const template = fs.readFileSync(SDK_RECIPE_FIXTURE, 'utf-8')
+ return renderSdkRecipeYaml(SDK_RECIPE_FIXTURE, recipeName, userRef)
+}
+
+function renderSdkRecipeYaml(fixture: string, recipeName: string, userRef: string): string {
+ const template = fs.readFileSync(fixture, 'utf-8')
return template
.replaceAll('PLACEHOLDER_PROVIDER', MODEL_PROVIDER)
.replaceAll('PLACEHOLDER_MODEL', MODEL_NAME)
@@ -72,12 +80,29 @@ export function renderSdkWorkloadRecipeYaml(recipeName: string, userRef: string)
.replaceAll('PLACEHOLDER_USER_REF', userRef)
}
+export function renderSdkLayoutRecipeYaml(
+ recipeName: string,
+ userRef: string,
+ runId: string
+): string {
+ return renderSdkRecipeYaml(SDK_LAYOUT_RECIPE_FIXTURE, recipeName, userRef).replaceAll(
+ 'PLACEHOLDER_RUN_ID',
+ runId
+ )
+}
+
export function applySdkWorkloadRecipe(recipeName: string, userRef: string): void {
const yaml = renderSdkWorkloadRecipeYaml(recipeName, userRef)
kubectl(['apply', '-f', '-'], yaml, 60_000)
waitForSdkRecipeValidated(recipeName)
}
+export function applySdkLayoutRecipe(recipeName: string, userRef: string, runId: string): void {
+ const yaml = renderSdkLayoutRecipeYaml(recipeName, userRef, runId)
+ kubectl(['apply', '-f', '-'], yaml, 60_000)
+ waitForSdkRecipeValidated(recipeName)
+}
+
export function waitForSdkRecipeValidated(recipeName: string, timeoutMs = 180_000): void {
const started = Date.now()
while (Date.now() - started < timeoutMs) {
@@ -96,36 +121,43 @@ export function waitForSdkRecipeValidated(recipeName: string, timeoutMs = 180_00
throw new Error(`WorkflowRecipe ${recipeName} never reached pluginWorkloadSdk.state=validated`)
}
-export async function createSdkWorkloadGrants(recipeName: string, userRef: string): Promise<void> {
+export async function createSdkWorkloadGrants(
+ recipeName: string,
+ userRef: string,
+ allowedCallers = [WORKLOAD_ID],
+ includePromptBridge = true
+): Promise<void> {
const token = await adminLogin()
const headers = {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
}
- const promptBridgeRes = await fetch(`${CONTROL_API}/api/v1/admin/plugin-workload-sdk/grants`, {
- method: 'POST',
- headers,
- body: JSON.stringify({
- recipeNamespace: RECIPE_NS,
- recipeName,
- capabilityFamily: 'promptBridge',
- provider: MODEL_PROVIDER,
- allowedModels: [MODEL_NAME],
- promptTargets: [
- {
- targetRef: `primary-${MODEL_PROVIDER}`,
- provider: MODEL_PROVIDER,
- model: MODEL_NAME,
- credentialSlot: CREDENTIAL_SLOT,
- },
- ],
- defaultTargetRef: `primary-${MODEL_PROVIDER}`,
- allowedCallers: [WORKLOAD_ID],
- quotaLimits: { maxRequestsPerRun: 3 },
- }),
- })
- expect(promptBridgeRes.status, await promptBridgeRes.text()).toBe(200)
+ if (includePromptBridge) {
+ const promptBridgeRes = await fetch(`${CONTROL_API}/api/v1/admin/plugin-workload-sdk/grants`, {
+ method: 'POST',
+ headers,
+ body: JSON.stringify({
+ recipeNamespace: RECIPE_NS,
+ recipeName,
+ capabilityFamily: 'promptBridge',
+ provider: MODEL_PROVIDER,
+ allowedModels: [MODEL_NAME],
+ promptTargets: [
+ {
+ targetRef: `primary-${MODEL_PROVIDER}`,
+ provider: MODEL_PROVIDER,
+ model: MODEL_NAME,
+ credentialSlot: CREDENTIAL_SLOT,
+ },
+ ],
+ defaultTargetRef: `primary-${MODEL_PROVIDER}`,
+ allowedCallers,
+ quotaLimits: { maxRequestsPerRun: 3 },
+ }),
+ })
+ expect(promptBridgeRes.status, await promptBridgeRes.text()).toBe(200)
+ }
const clientNotificationsRes = await fetch(
`${CONTROL_API}/api/v1/admin/plugin-workload-sdk/grants`,
@@ -244,6 +276,36 @@ export async function waitForSdkCallerNotification(
return match[1]
}
+export async function waitForSdkSandboxUiNotification(
+ recipeName: string,
+ timeoutMs = 120_000
+): Promise<string> {
+ const labelSelector = `clerum.io/recipe=${recipeName},clerum.io/workload=sandbox-ui`
+ const started = Date.now()
+ while (Date.now() - started < timeoutMs) {
+ const pod = kubectl([
+ '-n',
+ RECIPE_NS,
+ 'get',
+ 'pod',
+ '-l',
+ labelSelector,
+ '-o',
+ 'jsonpath={.items[0].metadata.name}',
+ ]).trim()
+ if (pod) {
+ const logs = kubectl(['-n', RECIPE_NS, 'logs', pod, '--tail=80'], undefined, 30_000)
+ const match = logs.match(/E2E_SDK_SANDBOX_UI_NOTIFICATION_OK=([0-9a-f-]{36})/i)
+ if (match?.[1]) return match[1]
+ if (logs.includes('E2E_SDK_SANDBOX_UI_FAIL=')) {
+ throw new Error(`sandbox-ui SDK producer failed:\n${logs.slice(-2_000)}`)
+ }
+ }
+ await new Promise(resolve => setTimeout(resolve, 3_000))
+ }
+ throw new Error(`sandbox-ui never emitted its client notification for recipe ${recipeName}`)
+}
+
/**
* Waits for the SDK caller to complete a promptBridge (LLM) round-trip and
* returns the invocationId it logged. This is the business signal that the
diff --git a/tests/e2e/fixtures/package-lock.json b/tests/e2e/fixtures/package-lock.json
index 51770049f..b70017584 100644
--- a/tests/e2e/fixtures/package-lock.json
+++ b/tests/e2e/fixtures/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@clerum/e2e-test-fixtures",
- "version": "1.0.55",
+ "version": "1.0.56",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@clerum/e2e-test-fixtures",
- "version": "1.0.55",
+ "version": "1.0.56",
"dependencies": {
"@kubernetes/client-node": "^1.0.0"
},
diff --git a/tests/e2e/fixtures/package.json b/tests/e2e/fixtures/package.json
index fe59c9d5a..05a7b1e21 100644
--- a/tests/e2e/fixtures/package.json
+++ b/tests/e2e/fixtures/package.json
@@ -1,6 +1,6 @@
{
"name": "@clerum/e2e-test-fixtures",
- "version": "1.0.55",
+ "version": "1.0.56",
"description": "E2E test fixtures and utilities for Clerum testing",
"type": "module",
"main": "index.ts",
diff --git a/tests/e2e/fixtures/plugin-workload-sdk-layout-recipe.yaml b/tests/e2e/fixtures/plugin-workload-sdk-layout-recipe.yaml
new file mode 100644
index 000000000..f95c02d12
--- /dev/null
+++ b/tests/e2e/fixtures/plugin-workload-sdk-layout-recipe.yaml
@@ -0,0 +1,45 @@
+# Repository-owned Desktop layout E2E fixture. The mounted Sandbox UI workload
+# emits a client notification through the same Plugin Workload SDK route used by
+# production plugin workloads; it is not a catalog or notification mock.
+apiVersion: clerum.io/v1alpha1
+kind: WorkflowRecipe
+metadata:
+ name: PLACEHOLDER_RECIPE_NAME
+ namespace: sandbox-recipes
+spec:
+ agent:
+ provider: PLACEHOLDER_PROVIDER
+ model: PLACEHOLDER_MODEL
+ workloads:
+ - id: sandbox-ui
+ type: deployment
+ image: clerum/workflow-plugin-sdk-e2e:test
+ port: 8080
+ healthCheck:
+ type: http
+ path: /healthz
+ port: 8080
+ env:
+ - name: E2E_SDK_MODE
+ value: sandbox-ui
+ - name: E2E_SDK_CALLER_REF
+ value: sandbox-ui
+ - name: E2E_SDK_EVENT_TYPE
+ value: e2e.test.notification
+ - name: E2E_SDK_USER_REF
+ value: PLACEHOLDER_USER_REF
+ - name: E2E_SDK_RUN_ID
+ value: PLACEHOLDER_RUN_ID
+ ui:
+ workloadRef: sandbox-ui
+ port: 8080
+ title: E2E Layout Notification App
+ defaultPath: /
+ pluginWorkloadSdk:
+ clientNotifications:
+ allowedEventTypes:
+ - e2e.test.notification
+ allowedUserRefs: true
+ maxNotificationsPerRun: 10
+ allowedCallers:
+ - sandbox-ui
diff --git a/tests/e2e/fixtures/workflow-plugin-sdk-e2e/src/index.js b/tests/e2e/fixtures/workflow-plugin-sdk-e2e/src/index.js
index c063598a9..07e11042e 100644
--- a/tests/e2e/fixtures/workflow-plugin-sdk-e2e/src/index.js
+++ b/tests/e2e/fixtures/workflow-plugin-sdk-e2e/src/index.js
@@ -19,6 +19,8 @@
// E2E_SDK_QUOTA_EXCEEDED_FAIL=<reason>
// E2E_SDK_DONE
+const http = require('node:http')
+
const ENDPOINT = process.env.PLUGIN_WORKLOAD_SDK_ENDPOINT || ''
const TOKEN = process.env.PLUGIN_WORKLOAD_SDK_TOKEN || ''
const CALLER_REF = process.env.E2E_SDK_CALLER_REF || 'sdk-caller'
@@ -142,6 +144,64 @@ async function exerciseClientNotification() {
}
}
+/**
+ * The mounted Sandbox UI fixture uses the same production SDK client-notification
+ * route as the background workload. Keeping this in the fixture image lets the
+ * Desktop E2E establish its notification from the app it actually mounts.
+ */
+async function emitSandboxUiNotification() {
+ for (let attempt = 1; attempt <= 10; attempt++) {
+ try {
+ const { status, body } = await callSdk('/v1/client-notifications', {
+ eventType: EVENT_TYPE,
+ userRef: USER_REF,
+ idempotencyKey: `e2e-sandbox-ui-notify-${RUN_ID}`,
+ notification: {
+ title: 'E2E Sandbox UI notification',
+ body: 'Sent by the mounted Plugin Workload SDK Sandbox UI fixture.',
+ },
+ })
+ if (status === 200 && body && body.notificationId) {
+ log(`E2E_SDK_SANDBOX_UI_NOTIFICATION_OK=${body.notificationId}`)
+ return body.notificationId
+ }
+ const code = (body && (body.error || body.code)) || `http_${status}`
+ if (attempt === 10) throw new Error(`client notification failed: ${code}`)
+ } catch (err) {
+ if (attempt === 10) throw err
+ }
+ await sleep(3000)
+ }
+ throw new Error('sandbox-ui notification retry loop exhausted')
+}
+
+function startSandboxUiFixture() {
+ let notification = null
+ const server = http.createServer(async (req, res) => {
+ if (req.url === '/healthz') {
+ res.writeHead(200, { 'content-type': 'text/plain' })
+ res.end('ok')
+ return
+ }
+ notification ??= emitSandboxUiNotification()
+ try {
+ const notificationId = await notification
+ res.writeHead(200, { 'content-type': 'text/html; charset=utf-8' })
+ res.end(
+ `<!doctype html><title>E2E Layout Notification App</title><main><h1>E2E Layout Notification App</h1><p data-notification-id="${notificationId}">Notification sent.</p></main>`
+ )
+ } catch (error) {
+ res.writeHead(500, { 'content-type': 'text/plain; charset=utf-8' })
+ res.end(
+ `Could not emit Sandbox UI notification: ${error instanceof Error ? error.message : error}`
+ )
+ }
+ })
+ server.listen(Number(process.env.PORT || '8080'), '0.0.0.0', () => {
+ log('E2E_SDK_SANDBOX_UI_READY')
+ })
+}
+
// Explicit selector: the backend can request one target from the operator's
// ordered policy. The targetRef is injected as non-secret recipe configuration;
// the workload never receives a provider key or credential slot value.
@@ -249,6 +309,14 @@ async function exerciseQuotaEnforcement() {
}
async function main() {
+ if (process.env.E2E_SDK_MODE === 'sandbox-ui') {
+ if (!ENDPOINT || !TOKEN) {
+ log('E2E_SDK_SANDBOX_UI_FAIL=missing_endpoint_or_token')
+ return
+ }
+ startSandboxUiFixture()
+ return
+ }
if (!ENDPOINT || !TOKEN) {
log('E2E_SDK_PROMPT_BRIDGE_FAIL=missing_endpoint_or_token')
log('E2E_SDK_CLIENT_NOTIFICATION_FAIL=missing_endpoint_or_token')