The open-source agent harness - the runtime layer that turns an LLM into a working agent.
feat [FRONTEN-2500] Allow edit in Connectors (#642)
Govinda Vashishtha1ec19f0f84f0
diff --git a/.changeset/edit-configured-connectors.md b/.changeset/edit-configured-connectors.mdnew file mode 100644index 000000000..fd9076f9e--- /dev/null+++ b/.changeset/edit-configured-connectors.md@@ -0,0 +1,5 @@+---+'@truefoundry/trueforge-ui': patch+---++Replace API key replacement with connector configuration editing from the connector list and details view.diff --git a/packages/trueforge-ui/src/containers/SettingsBuilder/AddMcpServerForm.tsx b/packages/trueforge-ui/src/containers/SettingsBuilder/AddMcpServerForm.tsxindex e7d38a256..0bb099a28 100644--- a/packages/trueforge-ui/src/containers/SettingsBuilder/AddMcpServerForm.tsx+++ b/packages/trueforge-ui/src/containers/SettingsBuilder/AddMcpServerForm.tsx@@ -1,12 +1,12 @@'use client';-import { useState, type FormEvent } from 'react';+import { useEffect, useState, type FormEvent } from 'react';import { auiInputClass } from '../../atoms/lib/inputClasses.js';import { Button } from '../../atoms/primitives/Button.js';import { CenteredModal } from '../../atoms/primitives/CenteredModal.js';import { Icon } from '../../icons/Icon.js';-import type { ConnectorAuth, ConnectorAuthType } from '../../server/types.js';+import type { ConnectorAuth, ConnectorAuthType, ConnectorBase } from '../../server/types.js';export type McpAuthType = ConnectorAuthType;@@ -20,15 +20,16 @@ export type AddMcpServerDraft = {type AddMcpServerFormProps = {open: boolean;onOpenChange: (open: boolean) => void;- onAdd: (draft: AddMcpServerDraft) => void | Promise<void>;+ onSubmit: (draft: AddMcpServerDraft) => void | Promise<void>;+ connector?: ConnectorBase;busy?: boolean;error?: string | null;};const AUTH_OPTIONS: Array<{ value: McpAuthType; label: string }> = [- { value: 'dcr', label: 'OAuth' },{ value: 'none', label: 'None' },{ value: 'header', label: 'API Key' },+ { value: 'dcr', label: 'OAuth' },];const inputClassName = auiInputClass('h-11 shadow-sm');@@ -39,13 +40,17 @@ const RequiredMark = () => (</span>);-const AddMcpServerForm = ({ open, onOpenChange, onAdd, busy = false, error }: AddMcpServerFormProps) => {+const AddMcpServerForm = ({ open, onOpenChange, onSubmit, connector, busy = false, error }: AddMcpServerFormProps) => {const [name, setName] = useState('');const [url, setUrl] = useState('');const [description, setDescription] = useState('');const [authType, setAuthType] = useState<McpAuthType>('dcr');const [apiKey, setApiKey] = useState('');const [headerName, setHeaderName] = useState('');+ const isEditing = connector !== undefined;+ const nameInputClassName = auiInputClass(+ `h-11 shadow-sm ${isEditing ? 'cursor-not-allowed bg-secondary-bg/60 text-text-secondary opacity-40' : ''}`,+ );const resetForm = () => {setName('');@@ -56,12 +61,23 @@ const AddMcpServerForm = ({ open, onOpenChange, onAdd, busy = false, error }: AdsetHeaderName('');};+ useEffect(() => {+ if (!open) return;+ setName(connector?.name ?? '');+ setUrl(connector?.url ?? '');+ setDescription(connector?.description ?? '');+ setAuthType(connector?.auth.type ?? 'dcr');+ setApiKey('');+ setHeaderName(connector?.auth.type === 'header' ? (connector.auth.headerName ?? '') : '');+ }, [connector, open]);+const handleOpenChange = (nextOpen: boolean) => {if (!nextOpen) resetForm();onOpenChange(nextOpen);};- const isValid = !!name.trim() && !!description.trim() && !!url.trim() && (authType !== 'header' || !!apiKey.trim());+ const hasApiKey = !!apiKey.trim() || connector?.auth.type === 'header';+ const isValid = !!name.trim() && !!description.trim() && !!url.trim() && (authType !== 'header' || hasApiKey);const handleSubmit = async (event: FormEvent<HTMLFormElement>) => {event.preventDefault();@@ -77,7 +93,7 @@ const AddMcpServerForm = ({ open, onOpenChange, onAdd, busy = false, error }: Ad: { type: authType };try {- await onAdd({+ await onSubmit({name: name.trim(),url: url.trim(),description: description.trim(),@@ -94,8 +110,12 @@ const AddMcpServerForm = ({ open, onOpenChange, onAdd, busy = false, error }: Ad<CenteredModalopen={open}onOpenChange={handleOpenChange}- title="Add MCP server"- description="Point at a remote MCP endpoint. It then behaves like any other connector."+ title={isEditing ? 'Edit MCP server' : 'Add MCP server'}+ description={+ isEditing+ ? 'Update how this connector authenticates.'+ : 'Point at a remote MCP endpoint. It then behaves like any other connector.'+ }contentSizedheaderIcon={<span@@ -118,12 +138,14 @@ const AddMcpServerForm = ({ open, onOpenChange, onAdd, busy = false, error }: Adtype="text"requiredvalue={name}+ readOnly={isEditing}+ aria-disabled={isEditing}onChange={event => {setName(event.target.value);}}placeholder="analytics-postgres-mcp"- autoFocus- className={inputClassName}+ autoFocus={!isEditing}+ className={nameInputClassName}/></div>@@ -209,12 +231,16 @@ const AddMcpServerForm = ({ open, onOpenChange, onAdd, busy = false, error }: Ad<div><label htmlFor="mcp-server-api-key" className="mb-1.5 block text-sm font-medium text-text-primary">API key- <RequiredMark />+ {connector?.auth.type === 'header' ? (+ <span className="font-normal text-text-secondary"> (leave blank to keep current)</span>+ ) : (+ <RequiredMark />+ )}</label><inputid="mcp-server-api-key"type="password"- required+ required={connector?.auth.type !== 'header'}value={apiKey}onChange={event => {setApiKey(event.target.value);@@ -246,7 +272,7 @@ const AddMcpServerForm = ({ open, onOpenChange, onAdd, busy = false, error }: Ad<div className="mt-6 space-y-3">{error ? <p className="text-failure-bg text-sm">{error}</p> : null}<Button.Primary type="submit" size="large" disabled={!isValid || busy} className="w-full shrink-0">- Add+ {isEditing ? 'Save' : 'Add'}</Button.Primary></div></form>diff --git a/packages/trueforge-ui/src/containers/SettingsBuilder/ConnectorDetails.tsx b/packages/trueforge-ui/src/containers/SettingsBuilder/ConnectorDetails.tsxindex 4cbc8cd24..94ba3c6d0 100644--- a/packages/trueforge-ui/src/containers/SettingsBuilder/ConnectorDetails.tsx+++ b/packages/trueforge-ui/src/containers/SettingsBuilder/ConnectorDetails.tsx@@ -15,6 +15,7 @@ type ConnectorDetailsProps = {connector: ConnectorBase;onBack: () => void;onConnectorRefreshed: (connector: ConnectorBase) => void;+ onEdit: () => void;onDisconnect: () => void;busy?: boolean;};@@ -98,6 +99,7 @@ const ConnectorDetails = ({connector,onBack,onConnectorRefreshed,+ onEdit,onDisconnect,busy = false,}: ConnectorDetailsProps) => {@@ -170,8 +172,11 @@ const ConnectorDetails = ({</span><div className="min-w-0 flex-1">- <h4 className="text-lg font-semibold text-text-primary">{connector.name}</h4>- <div className="mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm">+ <div className="flex items-center gap-2">+ <h4 className="text-lg font-semibold text-text-primary">{connector.name}</h4>+ <span className="inline-flex items-center rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium text-text-secondary">+ {AUTH_TYPE_LABELS[connector.auth.type] ?? AUTH_TYPE_LABELS.none}+ </span><spanclassName={cn('flex items-center gap-1.5 text-xs font-medium',@@ -186,31 +191,36 @@ const ConnectorDetails = ({></span>{connector.authenticated ? 'Connected' : 'Not authenticated'}</span>- <span className="text-text-secondary">· {connector.description}</span></div>- <span className="mt-2 inline-flex items-center rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium text-text-secondary">- {AUTH_TYPE_LABELS[connector.auth.type] ?? AUTH_TYPE_LABELS.none}- </span>+ <div className="flex flex-wrap items-center gap-x-2 gap-y-1 text-sm">+ <span className="text-text-secondary">{connector.description}</span>+ </div></div>- {connector.auth.type === 'dcr' && !connector.authenticated ? (- <Button.Secondary- size="small"- type="button"- disabled={busy || connecting}- onClick={() => {- void handleAuthorize(connector.id, isSuccess => {- if (isSuccess) void refreshAfterAuthentication();- });- }}- >- {connecting ? 'Connecting…' : 'Connect'}+ <div className="flex items-center gap-2">+ <Button.Secondary size="small" type="button" disabled={busy} onClick={onEdit}>+ <Icon name="pencil" className="size-3" />+ Edit</Button.Secondary>- ) : connector.auth.type === 'dcr' && !connector.requiresAuth ? (- <Button.Secondary size="small" type="button" disabled={busy} onClick={onDisconnect}>- Disconnect- </Button.Secondary>- ) : null}+ {connector.auth.type === 'dcr' && !connector.authenticated ? (+ <Button.Secondary+ size="small"+ type="button"+ disabled={busy || connecting}+ onClick={() => {+ void handleAuthorize(connector.id, isSuccess => {+ if (isSuccess) void refreshAfterAuthentication();+ });+ }}+ >+ {connecting ? 'Connecting…' : 'Connect'}+ </Button.Secondary>+ ) : connector.auth.type === 'dcr' && !connector.requiresAuth ? (+ <Button.Secondary size="small" type="button" disabled={busy} onClick={onDisconnect}>+ Disconnect+ </Button.Secondary>+ ) : null}+ </div></header><section className="mt-6" aria-labelledby="connector-tools-heading">diff --git a/packages/trueforge-ui/src/containers/SettingsBuilder/ConnectorSettings.tsx b/packages/trueforge-ui/src/containers/SettingsBuilder/ConnectorSettings.tsxindex 8050d622b..8715f8c91 100644--- a/packages/trueforge-ui/src/containers/SettingsBuilder/ConnectorSettings.tsx+++ b/packages/trueforge-ui/src/containers/SettingsBuilder/ConnectorSettings.tsx@@ -41,6 +41,7 @@ const ConnectorSettings = () => {const [catalog, setCatalog] = useState<ConnectorCatalogEntry[]>([]);const [addMcpServerFormOpen, setAddMcpServerFormOpen] = useState(false);+ const [editingConnector, setEditingConnector] = useState<ConnectorBase | null>(null);const [connectorAwaitingKey, setConnectorAwaitingKey] = useState<ConnectorCatalogEntry | null>(null);const [selectedConnector, setSelectedConnector] = useState<ConnectorBase | null>(null);const [apiKey, setApiKey] = useState('');@@ -188,35 +189,27 @@ const ConnectorSettings = () => {apiKey: apiKey.trim(),...(entry.auth.type === 'header' && entry.auth.headerName ? { headerName: entry.auth.headerName } : {}),};- const existing = connectors.ordered.find(({ connector }) => connector.id === entry.id);- const existingConnector = existing?.isConfigured ? existing.connector : undefined;- if (existingConnector) {- await connectorCatalog.updateConnector({- id: existingConnector.id,- name: existingConnector.name,- description: existingConnector.description,- url: existingConnector.url,- auth,- });- } else {- await createFromCatalog(entry, auth);- }+ await createFromCatalog(entry, auth);closeApiKeyModal();setTimeout(() => {toaster?.showSuccess({- title: `${entry.name} ${existingConnector ? 'updated' : 'connected'}`,+ title: `${entry.name} connected`,});}, 100);}, setFormError).catch(() => {});};- const handleAddMcpServer = async (draft: AddMcpServerDraft) => {+ const handleMcpServerSubmit = async (draft: AddMcpServerDraft) => {setFormError(null);await runMutation(async () => {- await connectorCatalog.createConnector({ ...draft });+ if (editingConnector) {+ await connectorCatalog.updateConnector({ id: editingConnector.id, ...draft });+ } else {+ await connectorCatalog.createConnector({ ...draft });+ }}, setFormError);setTimeout(() => {- toaster?.showSuccess({ title: `${draft.name} added` });+ toaster?.showSuccess({ title: `${draft.name} ${editingConnector ? 'updated' : 'added'}` });}, 0);};@@ -260,7 +253,25 @@ const ConnectorSettings = () => {</span><div className="min-w-0 flex-1">- <h5 className="truncate text-sm font-medium text-text-primary">{connector.name}</h5>+ <div className="flex items-center gap-2">+ <h5 className="truncate text-sm font-medium text-text-primary">{connector.name}</h5>+ <div className="flex items-center gap-2">+ <span+ className={cn(+ 'flex items-center gap-1.5 rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium',+ connector.authenticated ? 'text-success-bg' : 'text-text-primary',+ )}+ >+ <span+ className={cn(+ 'h-1.5 w-1.5 rounded-full',+ connector.authenticated ? 'bg-success-bg' : 'bg-primary-button-bg',+ )}+ ></span>+ {connector.authenticated ? 'Connected' : 'Added'}+ </span>+ </div>+ </div><p className="mt-0.5 line-clamp-2 text-sm text-text-secondary sm:truncate">{connector.description}</p></div></>@@ -280,37 +291,20 @@ const ConnectorSettings = () => {<div className="flex min-w-0 flex-1 items-center gap-3">{content}</div><div className="flex items-center gap-2">- <div className="flex items-center gap-2">- <span- className={cn(- 'flex items-center gap-1.5 rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium',- connector.authenticated ? 'text-success-bg' : 'text-text-primary',- )}- >- <span- className={cn(- 'h-1.5 w-1.5 rounded-full',- connector.authenticated ? 'bg-success-bg' : 'bg-primary-button-bg',- )}- ></span>- {connector.authenticated ? 'Connected' : 'Added'}- </span>- </div>- {connector.auth.type === 'header' ? (- <Button.Secondary- size="small"- type="button"- disabled={busy}- onClick={event => {- event.stopPropagation();- setApiKey('');- setConnectorAwaitingKey(connector);- }}- >- <Icon name="wrench" className="size-3" />- Replace Key- </Button.Secondary>- ) : null}+ <Button.Secondary+ size="small"+ type="button"+ disabled={busy}+ onClick={event => {+ event.stopPropagation();+ setFormError(null);+ setEditingConnector(connector);+ setAddMcpServerFormOpen(true);+ }}+ >+ <Icon name="pencil" className="size-3" />+ Edit+ </Button.Secondary><Icon name="chevron-right" className="size-4" /></div></article>@@ -368,28 +362,40 @@ const ConnectorSettings = () => {);};- const isReplacingKey = useMemo(() => {- return (- connectorAwaitingKey !== null &&- connectors.ordered.some(- (item: ConnectorListItem) => item.isConfigured && item.connector.id === connectorAwaitingKey.id,- )- );- }, [connectorAwaitingKey, connectors.ordered]);-if (selectedConnector) {return (- <ConnectorDetails- connector={selectedConnector}- busy={busy}- onBack={() => {- setSelectedConnector(null);- }}- onConnectorRefreshed={handleConnectorRefreshed}- onDisconnect={() => {- handleDisconnect(selectedConnector);- }}- />+ <>+ <ConnectorDetails+ connector={selectedConnector}+ busy={busy}+ onBack={() => {+ setSelectedConnector(null);+ }}+ onConnectorRefreshed={handleConnectorRefreshed}+ onEdit={() => {+ setFormError(null);+ setEditingConnector(selectedConnector);+ setAddMcpServerFormOpen(true);+ }}+ onDisconnect={() => {+ handleDisconnect(selectedConnector);+ }}+ />+ <AddMcpServerForm+ open={addMcpServerFormOpen}+ onOpenChange={open => {+ setAddMcpServerFormOpen(open);+ if (!open) {+ setEditingConnector(null);+ setFormError(null);+ }+ }}+ onSubmit={handleMcpServerSubmit}+ connector={editingConnector ?? undefined}+ busy={busy}+ error={formError}+ />+ </>);}@@ -416,6 +422,7 @@ const ConnectorSettings = () => {type="button"onClick={() => {setFormError(null);+ setEditingConnector(null);setAddMcpServerFormOpen(true);}}>@@ -467,7 +474,7 @@ const ConnectorSettings = () => {onOpenChange={open => {if (!open) closeApiKeyModal();}}- title={`${isReplacingKey ? 'Replace key for' : 'Connect'} ${connectorAwaitingKey?.name ?? 'connector'}`}+ title={`Connect ${connectorAwaitingKey?.name ?? 'connector'}`}description={connectorAwaitingKey?.url}contentSizedclassName="md:max-w-xl"@@ -515,7 +522,7 @@ const ConnectorSettings = () => {Cancel</Button.Ghost><Button.Primary type="submit" disabled={!apiKey.trim() || busy}>- {isReplacingKey ? 'Replace Key' : 'Connect'}+ Connect</Button.Primary></footer></form>@@ -525,9 +532,13 @@ const ConnectorSettings = () => {open={addMcpServerFormOpen}onOpenChange={open => {setAddMcpServerFormOpen(open);- if (!open) setFormError(null);+ if (!open) {+ setEditingConnector(null);+ setFormError(null);+ }}}- onAdd={handleAddMcpServer}+ onSubmit={handleMcpServerSubmit}+ connector={editingConnector ?? undefined}busy={busy}error={formError}/>diff --git a/packages/trueforge-ui/test/containers/SettingsBuilder/AddMcpServerForm.test.tsx b/packages/trueforge-ui/test/containers/SettingsBuilder/AddMcpServerForm.test.tsxindex 8b9440051..a4152a2fa 100644--- a/packages/trueforge-ui/test/containers/SettingsBuilder/AddMcpServerForm.test.tsx+++ b/packages/trueforge-ui/test/containers/SettingsBuilder/AddMcpServerForm.test.tsx@@ -3,6 +3,7 @@ import { fireEvent, render, screen, waitFor } from '@testing-library/react';import { beforeAll, describe, expect, it, vi } from 'vitest';import AddMcpServerForm from '@/containers/SettingsBuilder/AddMcpServerForm.js';+import type { ConnectorBase } from '@/server/types.js';beforeAll(() => {HTMLDialogElement.prototype.showModal = function showModal() {@@ -16,9 +17,9 @@ beforeAll(() => {describe('AddMcpServerForm', () => {it('submits name, url, auth, and trimmed description', async () => {- const onAdd = vi.fn(async () => undefined);+ const onSubmit = vi.fn(async () => undefined);- render(<AddMcpServerForm open onOpenChange={() => undefined} onAdd={onAdd} />);+ render(<AddMcpServerForm open onOpenChange={() => undefined} onSubmit={onSubmit} />);fireEvent.change(screen.getByPlaceholderText('analytics-postgres-mcp'), {target: { value: ' analytics-postgres-mcp ' },@@ -32,7 +33,7 @@ describe('AddMcpServerForm', () => {fireEvent.click(screen.getByRole('button', { name: 'Add' }));await waitFor(() => {- expect(onAdd).toHaveBeenCalledWith({+ expect(onSubmit).toHaveBeenCalledWith({name: 'analytics-postgres-mcp',url: 'https://mcp.example.com/mcp',description: 'Query analytics from Postgres',@@ -42,9 +43,9 @@ describe('AddMcpServerForm', () => {});it('disables submit until description is filled', () => {- const onAdd = vi.fn(async () => undefined);+ const onSubmit = vi.fn(async () => undefined);- render(<AddMcpServerForm open onOpenChange={() => undefined} onAdd={onAdd} />);+ render(<AddMcpServerForm open onOpenChange={() => undefined} onSubmit={onSubmit} />);fireEvent.change(screen.getByPlaceholderText('analytics-postgres-mcp'), {target: { value: 'custom-mcp' },@@ -54,7 +55,7 @@ describe('AddMcpServerForm', () => {});expect(screen.getByRole('button', { name: 'Add' })).toBeDisabled();- expect(onAdd).not.toHaveBeenCalled();+ expect(onSubmit).not.toHaveBeenCalled();fireEvent.change(screen.getByPlaceholderText('Query analytics from Postgres'), {target: { value: 'Custom MCP tools' },@@ -62,4 +63,64 @@ describe('AddMcpServerForm', () => {expect(screen.getByRole('button', { name: 'Add' })).toBeEnabled();});++ it('prefills connector details and preserves an existing API key when left blank', async () => {+ const onSubmit = vi.fn(async () => undefined);+ const connector: ConnectorBase = {+ id: 'custom-mcp',+ name: 'Custom MCP',+ description: 'Custom tools',+ url: 'https://mcp.example.com/mcp',+ authenticated: true,+ requiresAuth: false,+ auth: { type: 'header', headerName: 'X-API-Key' },+ };++ render(<AddMcpServerForm open connector={connector} onOpenChange={() => undefined} onSubmit={onSubmit} />);++ expect(screen.getByLabelText(/Name/)).toHaveValue(connector.name);+ expect(screen.getByLabelText(/Name/)).toHaveAttribute('readonly');+ expect(screen.getByLabelText(/Name/)).toHaveAttribute('aria-disabled', 'true');+ expect(screen.getByLabelText(/Name/)).toHaveClass('cursor-not-allowed', 'opacity-40');+ expect(screen.getByLabelText(/Name/)).not.toHaveClass('cursor-text');+ expect(screen.getByLabelText(/Description/)).not.toHaveAttribute('readonly');+ expect(screen.getByLabelText(/URL/)).not.toHaveAttribute('readonly');+ expect(screen.getByLabelText(/URL/)).toHaveClass('cursor-text');+ expect(screen.getByRole('radio', { name: 'API Key' })).toBeChecked();+ expect(screen.getByLabelText(/Header name/)).toHaveValue('X-API-Key');+ expect(screen.getByRole('button', { name: 'Save' })).toBeEnabled();++ fireEvent.change(screen.getByLabelText(/Description/), { target: { value: 'Updated tools' } });+ fireEvent.change(screen.getByLabelText(/URL/), { target: { value: 'https://new.example.com/mcp' } });+ fireEvent.click(screen.getByRole('button', { name: 'Save' }));++ await waitFor(() => {+ expect(onSubmit).toHaveBeenCalledWith({+ name: connector.name,+ url: 'https://new.example.com/mcp',+ description: 'Updated tools',+ auth: { type: 'header', apiKey: '', headerName: 'X-API-Key' },+ });+ });+ });++ it('requires a key when changing a connector to API Key auth', () => {+ const connector: ConnectorBase = {+ id: 'custom-mcp',+ name: 'Custom MCP',+ description: 'Custom tools',+ url: 'https://mcp.example.com/mcp',+ authenticated: true,+ requiresAuth: false,+ auth: { type: 'none' },+ };++ render(<AddMcpServerForm open connector={connector} onOpenChange={() => undefined} onSubmit={() => undefined} />);++ fireEvent.click(screen.getByRole('radio', { name: 'API Key' }));+ expect(screen.getByRole('button', { name: 'Save' })).toBeDisabled();++ fireEvent.change(screen.getByLabelText(/^API key/), { target: { value: 'new-secret' } });+ expect(screen.getByRole('button', { name: 'Save' })).toBeEnabled();+ });});diff --git a/packages/trueforge-ui/test/containers/SettingsBuilder/ConnectorDetails.test.tsx b/packages/trueforge-ui/test/containers/SettingsBuilder/ConnectorDetails.test.tsxindex 2ff0877be..adad0e894 100644--- a/packages/trueforge-ui/test/containers/SettingsBuilder/ConnectorDetails.test.tsx+++ b/packages/trueforge-ui/test/containers/SettingsBuilder/ConnectorDetails.test.tsx@@ -48,6 +48,7 @@ function wrapperFor(tools: ToolBase[]) {describe('ConnectorDetails tool descriptions', () => {it('clamps long tool descriptions to one line and expands on Read more', async () => {+ const onEdit = vi.fn();const longDescription ='First line of the tool description that should wrap. Second line continues with more detail. Third line must stay hidden until the reader expands the description fully.';@@ -63,6 +64,7 @@ describe('ConnectorDetails tool descriptions', () => {connector={connector}onBack={() => {}}onConnectorRefreshed={() => {}}+ onEdit={onEdit}onDisconnect={() => {}}/></Wrapper>,@@ -75,6 +77,9 @@ describe('ConnectorDetails tool descriptions', () => {const description = screen.getByText(longDescription);expect(description).toHaveClass('whitespace-nowrap');+ fireEvent.click(screen.getByRole('button', { name: 'Edit' }));+ expect(onEdit).toHaveBeenCalledOnce();+const readMore = await screen.findByRole('button', { name: 'Read more' });expect(readMore).toHaveAttribute('aria-expanded', 'false');expect(readMore).toHaveClass('absolute', 'right-0');@@ -99,6 +104,7 @@ describe('ConnectorDetails tool descriptions', () => {connector={connector}onBack={() => {}}onConnectorRefreshed={() => {}}+ onEdit={() => {}}onDisconnect={() => {}}/></Wrapper>,@@ -132,6 +138,7 @@ describe('ConnectorDetails OAuth connection', () => {connector={unauthenticatedConnector}onBack={() => {}}onConnectorRefreshed={() => {}}+ onEdit={() => {}}onDisconnect={() => {}}/></Wrapper>,@@ -146,6 +153,7 @@ describe('ConnectorDetails OAuth connection', () => {connector={headerConnector}onBack={() => {}}onConnectorRefreshed={() => {}}+ onEdit={() => {}}onDisconnect={() => {}}/></Wrapper>,@@ -181,6 +189,7 @@ describe('ConnectorDetails OAuth connection', () => {connector={unauthenticatedConnector}onBack={() => {}}onConnectorRefreshed={() => {}}+ onEdit={() => {}}onDisconnect={() => {}}/></ServerProvider>,@@ -237,6 +246,7 @@ describe('ConnectorDetails OAuth connection', () => {connector={currentConnector}onBack={() => {}}onConnectorRefreshed={setCurrentConnector}+ onEdit={() => {}}onDisconnect={() => {}}/>);diff --git a/packages/trueforge-ui/test/containers/SettingsBuilder/ConnectorSettings.test.tsx b/packages/trueforge-ui/test/containers/SettingsBuilder/ConnectorSettings.test.tsxnew file mode 100644index 000000000..5bbed7e3e--- /dev/null+++ b/packages/trueforge-ui/test/containers/SettingsBuilder/ConnectorSettings.test.tsx@@ -0,0 +1,71 @@+// @vitest-environment jsdom+import { fireEvent, render, screen, waitFor } from '@testing-library/react';+import { beforeAll, describe, expect, it, vi } from 'vitest';++import ConnectorSettings from '@/containers/SettingsBuilder/ConnectorSettings.js';+import { ServerProvider } from '@/server/ServerContext.js';+import type { ConnectorBase } from '@/server/types.js';+import { createMockAgentUIServer, createMockCatalog } from '../../server/mockServer.js';++beforeAll(() => {+ HTMLDialogElement.prototype.showModal = function showModal() {+ this.setAttribute('open', '');+ };+ HTMLDialogElement.prototype.close = function close() {+ this.removeAttribute('open');+ this.dispatchEvent(new Event('close'));+ };+});++describe('ConnectorSettings edit flow', () => {+ it('opens the shared form for every configured connector and updates its auth', async () => {+ const connector: ConnectorBase = {+ id: 'custom-mcp',+ name: 'Custom MCP',+ description: 'Custom tools',+ url: 'https://mcp.example.com/mcp',+ authenticated: true,+ requiresAuth: false,+ auth: { type: 'header', headerName: 'X-API-Key' },+ };+ const updateConnector = vi.fn(async () => ({ ...connector, auth: { type: 'none' } }) satisfies ConnectorBase);+ const connectorCatalog = {+ getConnectorCatalog: async () => [],+ listConnectors: async () => [connector],+ getConnector: async () => connector,+ getToolsByConnectorId: async () => [],+ createConnector: async () => connector,+ updateConnector,+ authenticateConnector: async () => ({ authorization_endpoint: '' }),+ disconnectConnector: async () => connector,+ };+ const server = createMockAgentUIServer({+ catalog: createMockCatalog({ connectorCatalog }),+ });++ render(+ <ServerProvider server={server}>+ <ConnectorSettings />+ </ServerProvider>,+ );++ fireEvent.click(await screen.findByRole('button', { name: 'Edit' }));++ expect(screen.queryByRole('button', { name: 'Replace Key' })).not.toBeInTheDocument();+ expect(screen.getByRole('heading', { name: 'Edit MCP server' })).toBeInTheDocument();+ expect(screen.getByLabelText(/Name/)).toHaveValue(connector.name);++ fireEvent.click(screen.getByRole('radio', { name: 'None' }));+ fireEvent.click(screen.getByRole('button', { name: 'Save' }));++ await waitFor(() => {+ expect(updateConnector).toHaveBeenCalledWith({+ id: connector.id,+ name: connector.name,+ description: connector.description,+ url: connector.url,+ auth: { type: 'none' },+ });+ });+ });+});