Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(control-ui): pin the Slack manifest lists and the relative-URL guard
Jose Ramirezce4ea45df70c
diff --git a/control-ui/components/__tests__/EditCommunicationChannelPage.test.tsx b/control-ui/components/__tests__/EditCommunicationChannelPage.test.tsxindex cefa0e001..6b381c84d 100644--- a/control-ui/components/__tests__/EditCommunicationChannelPage.test.tsx+++ b/control-ui/components/__tests__/EditCommunicationChannelPage.test.tsx@@ -1,6 +1,6 @@import React from 'react'import { afterEach, describe, expect, it, vi } from 'vitest'-import { cleanup, render, screen, waitFor } from '@testing-library/react'+import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'import { ToastProvider } from '@components/Toast'import EditCommunicationChannelPage from '../../app/communication-channels/[name]/edit/page'import * as api from '../../lib/api'@@ -37,8 +37,46 @@ vi.mock('../../lib/api', async () => {afterEach(() => {cleanup()vi.clearAllMocks()+ vi.unstubAllEnvs()+ navigation.params = { name: 'teams-channel' }})+type ChannelSpec = Record<string, unknown>++function mockChannel(name: string, spec: ChannelSpec) {+ navigation.params = { name }+ vi.mocked(api.apiGet).mockImplementation(async path => {+ if (path === '/api/v1/admin/hosts') {+ return { items: [{ metadata: { name: 'agent-a' } }] }+ }+ if (path === `/api/v1/admin/communication-channels/${name}`) {+ return {+ item: {+ metadata: { name, namespace: 'channels' },+ spec: { access: { users: [], teams: [] }, hostRef: 'agent-a', ...spec },+ },+ }+ }+ return { items: [] }+ })+}++async function renderLoadedPage() {+ render(+ <ToastProvider>+ <EditCommunicationChannelPage />+ </ToastProvider>+ )+ await waitFor(() => {+ expect(screen.queryByText('Loading communication channel...')).not.toBeInTheDocument()+ })+}++const SLACK_CHANNEL_SPEC: ChannelSpec = {+ credentialsSecretRef: { name: 'cc-slack-channel-credentials' },+ slackSettings: { botHandle: 'Evenfire', replyOnlyWhenMentioned: true },+}+describe('EditCommunicationChannelPage', () => {it('renders Teams setup details and confirmed conversation metadata', async () => {vi.mocked(api.apiGet).mockImplementation(async path => {@@ -90,3 +128,47 @@ describe('EditCommunicationChannelPage', () => {expect(screen.getByText('Channel')).toBeInTheDocument()})})++describe('EditCommunicationChannelPage Slack app manifest', () => {+ it('renders the manifest with both request URLs when the webhook is publicly reachable', async () => {+ vi.stubEnv('NEXT_PUBLIC_WORKFLOW_APPROVAL_READER_BASE_URL', 'https://webhook.example.com')+ mockChannel('slack-channel', SLACK_CHANNEL_SPEC)+ await renderLoadedPage()++ expect(screen.getByText('Slack App Manifest')).toBeInTheDocument()++ const manifest = screen.getByText(/display_information:/).textContent ?? ''+ const requestUrlLines = manifest+ .split('\n')+ .filter(line => line.trim().startsWith('request_url:'))+ expect(requestUrlLines).toHaveLength(2)+ expect(new Set(requestUrlLines).size).toBe(1)+ expect(requestUrlLines[0]).toContain('https://webhook.example.com/webhooks/slack/')+ expect(manifest).toContain('name: Evenfire')+ })++ it('warns instead of emitting a manifest when the Request URL is only a path', async () => {+ // No NEXT_PUBLIC_WORKFLOW_APPROVAL_READER_BASE_URL and a non-app.* hostname, which is the+ // minikube case. Slack rejects a relative request_url, so a manifest here would be a broken+ // artifact and would send the operator to debug Slack's generic error.+ mockChannel('slack-channel', SLACK_CHANNEL_SPEC)+ await renderLoadedPage()++ expect(screen.getByText(/^\/webhooks\/slack\//)).toBeInTheDocument()+ expect(screen.getByText(/no public webhook address/)).toBeInTheDocument()+ expect(screen.queryByText('Slack App Manifest')).not.toBeInTheDocument()+ expect(screen.queryByText(/display_information:/)).not.toBeInTheDocument()+ })++ it('renders no manifest and no warning on a channel with no Slack provider', async () => {+ vi.stubEnv('NEXT_PUBLIC_WORKFLOW_APPROVAL_READER_BASE_URL', 'https://webhook.example.com')+ mockChannel('teams-channel', { teamsSettings: { appName: 'evenfire' } })+ await renderLoadedPage()+ fireEvent.click(screen.getByRole('radio', { name: 'Slack' }))++ expect(screen.getByText('Slack Request URL')).toBeInTheDocument()+ expect(screen.queryByText('Slack App Manifest')).not.toBeInTheDocument()+ expect(screen.queryByText(/display_information:/)).not.toBeInTheDocument()+ expect(screen.queryByText(/no public webhook address/)).not.toBeInTheDocument()+ })+})diff --git a/control-ui/lib/__tests__/slackAppManifest.test.ts b/control-ui/lib/__tests__/slackAppManifest.test.tsindex 74ec971b8..2dca199d5 100644--- a/control-ui/lib/__tests__/slackAppManifest.test.ts+++ b/control-ui/lib/__tests__/slackAppManifest.test.ts@@ -3,6 +3,25 @@ import { canGenerateSlackAppManifest, slackAppManifest } from '../slackAppManifeconst URL = 'https://webhook.example.com/webhooks/slack/slack%3AeyJ4IjoxfQ'+/**+ * The emitted ` - <value>` items under a list header. Matching values against the whole+ * document instead lets one entry stand in for another: `app_mentions:read` (a scope) satisfies+ * a search for `app_mention` (the event), and `mpim:read` satisfies `im:read`. Three of the+ * seventeen required values were unpinned that way.+ */+function listItemsUnder(yaml: string, header: string): string[] {+ const lines = yaml.split('\n')+ const start = lines.findIndex(line => line.trim() === header)+ expect(start).toBeGreaterThanOrEqual(0)+ const items: string[] = []+ for (const line of lines.slice(start + 1)) {+ const item = /^\s+- (.+)$/.exec(line)+ if (!item) break+ items.push(item[1])+ }+ return items+}+describe('slackAppManifest', () => {const yaml = slackAppManifest('Evenfire', URL)@@ -19,6 +38,7 @@ describe('slackAppManifest', () => {})it('subscribes to every bot event the reader handles', () => {+ const events = listItemsUnder(yaml, 'bot_events:')for (const event of ['app_mention','message.channels',@@ -26,11 +46,13 @@ describe('slackAppManifest', () => {'message.im','message.mpim',]) {- expect(yaml).toContain(event)+ expect(events).toContain(event)}+ expect(events).toHaveLength(5)})it('requests every scope the platform calls', () => {+ const scopes = listItemsUnder(yaml, 'bot:')for (const scope of ['app_mentions:read','channels:history',@@ -45,8 +67,9 @@ describe('slackAppManifest', () => {'files:write','users:read',]) {- expect(yaml).toContain(scope)+ expect(scopes).toContain(scope)}+ expect(scopes).toHaveLength(12)})it('disables socket mode, which this platform does not use', () => {diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex 9acef6613..32c06008e 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.398",+ "version": "0.1.399","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.398",+ "version": "0.1.399","dependencies": {"@clerum/llm-providers": "file:../packages/llm-providers","@clerum/workflow-recipe-capability-policy": "file:../packages/workflow-recipe-capability-policy",diff --git a/control-ui/package.json b/control-ui/package.jsonindex ffeb17067..a50e7501e 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.398",+ "version": "0.1.399","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",