Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(test): sync dev and use UI session in snippet E2E
Alfredo Lopez92a06037317b
diff --cc control-ui/package-lock.jsonindex 3a394d317,3a394d317..ace5d18fc--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@@ -1,12 -1,12 +1,12 @@@{"name": "clerum-control-ui",-- "version": "0.1.703",++ "version": "0.1.704","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",-- "version": "0.1.703",++ "version": "0.1.704","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/frontend-components": "file:../packages/frontend-components",diff --cc control-ui/package.jsonindex 17049afb2,17049afb2..7b4f7e30a--- a/control-ui/package.json+++ b/control-ui/package.json@@@ -1,6 -1,6 +1,6 @@@{"name": "clerum-control-ui",-- "version": "0.1.703",++ "version": "0.1.704","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",diff --cc desktop-app/test/e2e-playwright/workflow-snippet-runtime-happy-path.test.tsindex 39170b802,217c55796..b54e22dfd--- a/desktop-app/test/e2e-playwright/workflow-snippet-runtime-happy-path.test.ts+++ b/desktop-app/test/e2e-playwright/workflow-snippet-runtime-happy-path.test.ts@@@ -33,6 -33,6 +33,8 @@@ importconst CONTROL_API = process.env.CONTROL_API_BASE_URL || 'http://127.0.0.1:8090'const CONTROL_UI =process.env.CONTROL_UI_BASE_URL || process.env.CONTROL_UI_URL || 'http://127.0.0.1:3000'++const CONTROL_UI_ORIGIN = new URL(CONTROL_UI).origin++const CONTROL_UI_API = `${CONTROL_UI_ORIGIN}/control-api`const ADMIN_USERNAME = process.env.E2E_ADMIN_USERNAME || process.env.ADMIN_USER || 'admin'const ADMIN_PASSWORD =process.env.E2E_ADMIN_PASSWORD || process.env.ADMIN_PASSWORD || process.env.ADMIN_PASS@@@ -48,10 -48,6 +50,9 @@@ const WORKLOAD_SECRET_ENV = 'CONFIG_TOKconst WORKLOAD_SECRET_VALUE = 'workflow-config-token-e2e'const RUN_MAX_DURATION_SECONDS = 600const RUN_TTL_SECONDS_AFTER_FINISHED = 7200+const REGISTRY_ENTRY_VERSION = '1.0.0'+- let controlAdminToken = ''+let publishedRegistryEntryName = ''type K8sWorkflowRecipe = {status?: { workflowExecution?: { phase?: string; message?: string } }@@@ -257,9 -249,9 +258,10 @@@ function buildSnippetRecipeManifest(nam}}--async function controlUiLogin(page: Page): Promise<string> {++async function controlUiLogin(page: Page): Promise<void> {const password = requireAdminPassword()-- await page.goto(CONTROL_UI)++ // E2E_GUARDIAN_ENTRY_POINT: enter the public Control UI root before UI login.++ await page.goto('/')const usernameInput = page.getByLabel('Username')const passwordInput = page.getByLabel('Password')await expect(usernameInput).toBeVisible({ timeout: 20_000 })@@@ -269,238 -261,57 +271,239 @@@const signInButton = page.getByRole('button', { name: /^Sign in$/ })await expect(signInButton).toBeEnabled({ timeout: 10_000 })await signInButton.click()- await expect(page.getByText('Workflow Recipes', { exact: false })).toBeVisible({+ await expect(page).toHaveURL(/\/agents$/, { timeout: 25_000 })+ await expect(page.getByRole('link', { name: 'Installed Plugins', exact: true })).toBeVisible({timeout: 25_000,})-- const token = await page.evaluate(() => localStorage.getItem('controlUiAdminToken') ?? '')-- expect(token, 'Control UI should persist admin token after login').toBeTruthy()-- return token++ const session = await page.request.get(`${CONTROL_UI_API}/api/v1/admin/auth/me`)++ expect(session.status(), 'Control UI login should establish an authenticated session').toBe(200)++ const authenticated = (await session.json()) as { me?: { id?: string } }++ expect(++ authenticated.me?.id,++ 'Control UI session should identify the signed-in admin'++ ).toBeTruthy()+}++async function openInstalledPluginsFromSidebar(page: Page): Promise<void> {+ const pluginsLink = page.getByRole('link', { name: 'Installed Plugins', exact: true })+ await pluginsLink.click()+ await expect(page).toHaveURL(/\/plugins$/, { timeout: 30_000 })+ await expect(page.getByRole('button', { name: 'Install Plugin', exact: true })).toBeVisible({+ timeout: 30_000,+ })+ await expect(+ page.getByText('Select a plugin to view status, run history, and actions.')+ ).toBeVisible({ timeout: 30_000 })+}++async function openInstalledPluginFromSidebar(page: Page, recipeName: string): Promise<void> {+ await openInstalledPluginsFromSidebar(page)+ const search = page.getByLabel('Search plugins', { exact: true })+ await expect(search).toBeEnabled({ timeout: 30_000 })+ await search.fill(recipeName)+ const openPlugin = page.getByRole('link', { name: `Open ${recipeName}`, exact: true })+ await expect(openPlugin).toBeVisible({ timeout: 30_000 })+ await openPlugin.click()+ await expect(page).toHaveURL(+ new RegExp(`/plugins/${RECIPE_NS}/${escapeRegExp(recipeName)}/workloads$`),+ { timeout: 30_000 }+ )+ await expect(page.getByRole('heading', { name: recipeName, exact: true })).toBeVisible({+ timeout: 30_000,+ })+}++async function grantPluginUserFromDetail(page: Page, userEmail: string): Promise<void> {+ await page.getByRole('tab', { name: /^Members/ }).click()+ await expect(page).toHaveURL(/\/members$/, { timeout: 30_000 })+ const triggerUsers = page.getByTestId('workflow-access-trigger-users')+ await expect(triggerUsers).toBeVisible({ timeout: 30_000 })+ await page.getByRole('button', { name: 'Add member', exact: true }).click()+ const dialog = page.getByRole('dialog', { name: 'Add member', exact: true })+ await expect(dialog).toBeVisible({ timeout: 10_000 })+ const search = dialog.getByRole('textbox', { name: 'Search members...' })+ await expect(search).toBeVisible({ timeout: 20_000 })+ await search.fill(userEmail)+ const option = dialog.getByRole('option').filter({ hasText: userEmail })+ await expect(option).toBeVisible({ timeout: 20_000 })+ const optionAccessibleName = await option.getAttribute('aria-label')+ expect(optionAccessibleName, `${userEmail} option should expose its member identity`).toContain(+ userEmail+ )+ const selectedMemberLabel = optionAccessibleName!.replace(+ new RegExp(`,\\s*${escapeRegExp(userEmail)}$`),+ ''+ )+ await option.click()+ await expect(option).toHaveAttribute('aria-selected', 'true', { timeout: 10_000 })+ await dialog.getByRole('button', { name: 'Add member', exact: true }).click()+ await expect(triggerUsers.getByText(userEmail)).toBeVisible({ timeout: 20_000 })+ const memberActions = triggerUsers.getByRole('button', {+ name: `Actions for member trigger access: ${selectedMemberLabel}`,+ exact: true,+ })+ await expect(memberActions).toBeVisible({ timeout: 20_000 })+ await memberActions.click()+ const removeMemberAccess = page.getByRole('menuitem', {+ name: 'Remove member trigger access',+ exact: true,+ })+ await expect(removeMemberAccess).toBeVisible({ timeout: 10_000 })+ await page.keyboard.press('Escape')+ await expect(removeMemberAccess).toBeHidden({ timeout: 10_000 })+}+- async function publishSnippetRegistryEntry(adminToken: string, recipeName: string): Promise<void> {++async function publishSnippetRegistryEntry(page: Page, recipeName: string): Promise<void> {+ // Plugin publishing is intentionally absent from ControlUI. This package- // fixture is setup only; installation itself remains a visible user journey.- const response = await apiRequest(- 'POST',- `${CONTROL_API}/api/v1/admin/registry/entries`,- JSON.stringify({++ // fixture reuses the browser's UI-created session; installation itself++ // remains a visible user journey.++ const response = await page.request.post(`${CONTROL_UI_API}/api/v1/admin/registry/entries`, {++ headers: { Origin: CONTROL_UI_ORIGIN },++ data: {+ name: recipeName,+ version: REGISTRY_ENTRY_VERSION,+ entryType: 'recipe',+ description: `Layer 3A snippet runtime journey for ${recipeName}`,+ author: 'e2e-test',+ origin: 'human-authored',+ category: 'workflow',+ tags: ['e2e', 'snippet', 'layer3a'],+ contentCreatorTag: 'community',+ configCreatorTag: 'community',+ visibility: 'private',+ recipe: JSON.stringify(buildSnippetRecipeManifest(recipeName)),- }),- { Authorization: `Bearer ${adminToken}`, 'Content-Type': 'application/json' }- )- expect(response.status, `publish snippet plugin package: ${response.body}`).toBe(201)- const published = JSON.parse(response.body) as { name?: unknown }++ },++ })++ expect(response.status(), 'publish snippet plugin package').toBe(201)++ const published = (await response.json()) as { name?: unknown }+ expect(published.name, 'published plugin package should return its scoped name').toContain(+ recipeName+ )+ publishedRegistryEntryName = String(published.name)+}++async function provisionSnippetSecretsThroughControlUi(+ page: Page,+ recipeName: string+): Promise<void> {+ const secretName = `${recipeName}-coingecko-api`+ await page.getByRole('tab', { name: 'Secrets', exact: true }).click()+ await expect(page).toHaveURL(/\/secrets$/, { timeout: 30_000 })+ const addSecret = page.getByRole('button', { name: `Add recipe secret ${secretName}` })+ await expect(addSecret).toBeVisible({ timeout: 30_000 })+ await addSecret.click()+ await expect(page).toHaveURL(/\/secrets\/new\?/, { timeout: 30_000 })+ await expect(page.getByRole('heading', { name: 'Create recipe secret' })).toBeVisible({+ timeout: 30_000,+ })+ await expect(page.locator('#recipe-secret-name')).toHaveValue(secretName)+ await expect(page.getByLabel('Owner recipe')).toHaveValue(recipeName)+ await page.getByRole('button', { name: 'Continue', exact: true }).click()++ const keyInputs = page.getByPlaceholder('API_KEY')+ const valueInputs = page.getByPlaceholder('secret value')+ await expect(keyInputs).toHaveCount(2, { timeout: 30_000 })+ await expect(valueInputs).toHaveCount(2, { timeout: 30_000 })++ const expectedSecretKeys = [SNIPPET_SECRET_KEY, WORKLOAD_SECRET_KEY].sort()+ await expect+ .poll(+ async () => {+ const currentKeys = await Promise.all((await keyInputs.all()).map(key => key.inputValue()))+ return [...currentKeys].sort()+ },+ {+ timeout: 30_000,+ message: 'Secrets form should expose exactly the two recipe key inputs',+ }+ )+ .toEqual(expectedSecretKeys)++ // The public Secrets form contract pairs key/value rows by array order. A+ // non-assertion inputValue snapshot binds each value through its matching+ // key rather than choosing a row by fixed position.+ const keyLocators = await keyInputs.all()+ const valueLocators = await valueInputs.all()+ const keyValues = await Promise.all(keyLocators.map(key => key.inputValue()))+ expect([...keyValues].sort()).toEqual(expectedSecretKeys)+ const secretInputRowByKey = new Map<string, { keyInput: Locator; valueInput: Locator }>()+ keyValues.forEach((keyValue, index) => {+ const keyInput = keyLocators[index]+ const valueInput = valueLocators[index]+ if (keyInput && valueInput) secretInputRowByKey.set(keyValue, { keyInput, valueInput })+ })+ for (const [keyValue, { keyInput, valueInput }] of secretInputRowByKey) {+ await expect(keyInput).toBeVisible()+ await expect(valueInput).toBeVisible()+ if (keyValue === SNIPPET_SECRET_KEY) await valueInput.fill(SNIPPET_SECRET_VALUE)+ if (keyValue === WORKLOAD_SECRET_KEY) await valueInput.fill(WORKLOAD_SECRET_VALUE)+ }++ const createResponse = page.waitForResponse(+ response => {+ if (!response.url().includes('/admin/recipe-secrets')) return false+ if (response.request().method() !== 'POST') return false+ return response.request().postDataJSON()?.name === secretName+ },+ { timeout: 30_000 }+ )+ await page.getByRole('button', { name: 'Create secret', exact: true }).click()+ const created = await createResponse+ expect(created.status()).toBe(201)+ await expect(page).toHaveURL(/\/secrets\/recipe$/, { timeout: 30_000 })++ await openInstalledPluginFromSidebar(page, recipeName)}async function installRecipeFromControlUi(page: Page,recipeName: string,userEmail: string--): Promise<string> {-- const adminToken = await controlUiLogin(page)- controlAdminToken = adminToken- await publishSnippetRegistryEntry(adminToken, recipeName)- await page.goto(`${CONTROL_UI}/workflow-recipes`)- await page.getByRole('button', { name: 'Install Recipe' }).click()-- const editor = page.locator('textarea').first()- await expect(editor).toBeVisible({ timeout: 15_000 })- await editor.fill(JSON.stringify(buildSnippetRecipeManifest(recipeName), null, 2))- await page.getByRole('button', { name: 'Validate' }).click()- await expect(page.getByText(/Configuration & Secrets/i)).toBeVisible({ timeout: 15_000 })- const secretInput = page.getByPlaceholder(`Enter value for ${SNIPPET_SECRET_ALIAS}`)- await expect(secretInput).toBeVisible({ timeout: 15_000 })- await secretInput.fill(SNIPPET_SECRET_VALUE)- const workloadSecretInput = page.getByPlaceholder(`Enter value for ${WORKLOAD_SECRET_ENV}`)- await expect(workloadSecretInput).toBeVisible({ timeout: 15_000 })- await workloadSecretInput.fill(WORKLOAD_SECRET_VALUE)-- const userPicker = page.getByLabel('Pick a user to grant trigger access')- await expect(userPicker).toBeVisible({ timeout: 20_000 })- const optionValue = await userPicker- .locator('option')- .filter({ hasText: userEmail })- .first()- .getAttribute('value')- expect(optionValue, `${userEmail} should be selectable in Control UI grants panel`).toBeTruthy()- await userPicker.selectOption(optionValue!)- await page.getByRole('button', { name: 'Grant user' }).click()- await expect(page.getByTestId('workflow-access-trigger-users')).toContainText(userEmail, {- timeout: 10_000,++): Promise<void> {++ await controlUiLogin(page)++ await publishSnippetRegistryEntry(page, recipeName)++ await openInstalledPluginsFromSidebar(page)+ await page.getByRole('button', { name: 'Install Plugin', exact: true }).click()+ await expect(page).toHaveURL(/\/marketplace\/org\/entries$/, { timeout: 30_000 })+ const entrySearch = page.getByLabel('Search entries', { exact: true })+ await expect(entrySearch).toBeEnabled({ timeout: 30_000 })+ await entrySearch.fill(recipeName)+ const entryActions = page.getByRole('button', {+ name: `Actions for ${publishedRegistryEntryName} v${REGISTRY_ENTRY_VERSION}`,})+ await expect(entryActions).toBeVisible({ timeout: 30_000 })+ await entryActions.click()+ await page.getByRole('menuitem', { name: 'Install', exact: true }).click()+ await expect(page).toHaveURL(/\/marketplace\/install\?/, { timeout: 30_000 })+ await expect(+ page+ .getByRole('heading', { name: 'Install a private plugin', exact: true })+ .or(page.getByRole('heading', { name: 'Install from Marketplace', exact: true }))+ ).toBeVisible({ timeout: 30_000 })- await page.getByRole('button', { name: 'Deploy Recipe' }).click()- await expect(page.locator('textarea')).toHaveCount(0, { timeout: 45_000 })- await expect(page.getByRole('link', { name: `Open ${recipeName}` })).toBeVisible({- timeout: 45_000,+ await page.getByRole('button', { name: 'Continue', exact: true }).click()+ await expect(page.getByText('No external egress declarations were found.')).toBeVisible({+ timeout: 30_000,})+ await page.getByRole('button', { name: 'Continue', exact: true }).click()+ await expect(+ page.getByText(+ `Recipe ${publishedRegistryEntryName} v${REGISTRY_ENTRY_VERSION} will be installed`+ )+ ).toBeVisible({ timeout: 30_000 })+ await page.getByRole('button', { name: 'Install plugin', exact: true }).click()+ await expect(page).toHaveURL(new RegExp(`/plugins/${RECIPE_NS}/${escapeRegExp(recipeName)}$`), {+ timeout: 60_000,+ })+ await expect(page.getByRole('heading', { name: recipeName, exact: true })).toBeVisible({+ timeout: 30_000,+ })++ await provisionSnippetSecretsThroughControlUi(page, recipeName)+ await grantPluginUserFromDetail(page, userEmail)assertWorkflowRecipeSecretMaterialized(recipeName)assertInstalledRecipeDoesNotContainSecretValues(recipeName)-- return adminToken}function assertWorkflowRecipeSecretMaterialized(recipeName: string): void {@@@ -575,18 -403,18 +578,15 @@@ async function waitForRecipeWorkflowPhareturn last}--async function waitForAdminRecipeActive(adminToken: string, name: string): Promise<void> {++async function waitForAdminRecipeActive(page: Page, name: string): Promise<void> {await expect.poll(async () => {-- const res = await apiRequest(-- 'GET',-- `${CONTROL_API}/api/v1/admin/workflows/${RECIPE_NS}/${name}`,-- undefined,-- { Authorization: `Bearer ${adminToken}` }++ const res = await page.request.get(++ `${CONTROL_UI_API}/api/v1/admin/workflows/${RECIPE_NS}/${name}`)-- if (res.status !== 200) return `http-${res.status}`-- const parsed = JSON.parse(res.body) as { status?: { phase?: string } }++ if (res.status() !== 200) return `http-${res.status()}`++ const parsed = (await res.json()) as { status?: { phase?: string } }return parsed.status?.phase ?? ''},{@@@ -1023,31 -817,17 +1023,37 @@@ function cleanupRecipe(name: string): v}}- async function cleanupPublishedRegistryEntry(): Promise<void> {- if (!publishedRegistryEntryName || !controlAdminToken) return- const response = await apiRequest(- 'DELETE',- `${CONTROL_API}/api/v1/admin/registry/entries/${encodeURIComponent(++async function cleanupPublishedRegistryEntry(page: Page): Promise<void> {++ if (!publishedRegistryEntryName) return++ const response = await page.request.delete(++ `${CONTROL_UI_API}/api/v1/admin/registry/entries/${encodeURIComponent(+ publishedRegistryEntryName+ )}/versions/${encodeURIComponent(REGISTRY_ENTRY_VERSION)}`,- undefined,- { Authorization: `Bearer ${controlAdminToken}` }++ { headers: { Origin: CONTROL_UI_ORIGIN } }+ )- expect([200, 204, 404]).toContain(response.status)++ expect([200, 204, 404]).toContain(response.status())++ publishedRegistryEntryName = ''+}+test.describe('Layer 3A snippet runtime user flow', () => {test.slow()test.describe.configure({ timeout: 900_000 })++ test.use({ baseURL: CONTROL_UI })test.beforeAll(async () => {ensureWorkflowTriggerFixturesSeeded()await clearSession()})-- test.afterAll(async () => {++ test.afterEach(async ({ page }) => {++ // Clean up through the shared UI session before its browser context is disposed.++ cleanupRecipe(RECIPE_NAME)++ await cleanupPublishedRegistryEntry(page)++ })++++ test.afterAll(() => {++ // Keep this idempotent second pass for failures during beforeAll or fixture setup.cleanupRecipe(RECIPE_NAME)- await cleanupPublishedRegistryEntry()})test('installs in Control UI, triggers in Desktop App, and downloads run-scoped snippet artifact', async ({@@@ -1058,9 -838,9 +1064,9 @@@apiRequest('GET', `${EXT_API}/health`).then(res => expect(res.status).toBe(200)),])-- const adminToken = await installRecipeFromControlUi(page, RECIPE_NAME, E2E_EMAIL)++ await installRecipeFromControlUi(page, RECIPE_NAME, E2E_EMAIL)await waitForRecipeWorkflowPhase(RECIPE_NAME, 'completed', 300_000)-- await waitForAdminRecipeActive(adminToken, RECIPE_NAME)++ await waitForAdminRecipeActive(page, RECIPE_NAME)const { userId, userToken } = await loginAs(E2E_EMAIL)const { app, page: desktopPage } = await launchAndLogin(E2E_EMAIL)