Skip to content

Self-improving AI Employees for everyone

chore(tests): remove obsolete nodeDefinitions-registry tests

trohitgda5ec36d9a40
diff --git a/client/src/components/__tests__/OutputPanel.test.tsx b/client/src/components/__tests__/OutputPanel.test.tsx
deleted file mode 100644
index fcdc0c6e..00000000
--- a/client/src/components/__tests__/OutputPanel.test.tsx
+++ /dev/null
@@ -1,264 +0,0 @@
-/**
- * Tests for OutputPanel.
- *
- * Locks in:
- * - Empty state when no nodes connect to this node
- * - Connected nodes are listed (one per incoming edge to a non-config handle)
- * - Config-handle edges (input-memory/tools/skill) are NOT listed
- * - Memory/tool config nodes inherit parent's main inputs
- * - Drag-start sets text/plain to `{{templateName.outputName}}`
- * - Android nodes expose flattened schema entries as draggable outputs
- */
-
-import React from 'react';
-import { describe, it, expect, vi, beforeEach } from 'vitest';
-import { render, screen } from '@testing-library/react';
-import userEvent from '@testing-library/user-event';
-
-// --- Mocks -----------------------------------------------------------------
-
-const storeState: { currentWorkflow: any } = { currentWorkflow: null };
-vi.mock('../../store/useAppStore', () => ({
- useAppStore: () => storeState,
-}));
-
-vi.mock('../../hooks/useDragVariable', () => ({
- useDragVariable: () => ({
- handleVariableDragStart: vi.fn(),
- getTemplateVariableName: (id: string) => {
- const node = storeState.currentWorkflow?.nodes?.find((n: any) => n.id === id);
- return (node?.data?.label || node?.type || id).toLowerCase().replace(/\s+/g, '');
- },
- }),
-}));
-
-vi.mock('../../hooks/useAppTheme', () => ({
- useAppTheme: () => ({
- isDarkMode: false,
- colors: {
- background: '#fff',
- text: '#000',
- border: '#ddd',
- textSecondary: '#666',
- backgroundAlt: '#fafafa',
- backgroundPanel: '#f5f5f5',
- primary: '#1890ff',
- },
- spacing: { xs: 4, sm: 8, md: 12, lg: 16, xl: 24 },
- fontSize: { xs: 10, sm: 12, md: 14, lg: 16, xl: 18 },
- fontWeight: { normal: 400, medium: 500, semibold: 600, bold: 700 },
- borderRadius: { sm: 4, md: 6, lg: 8 },
- transitions: { fast: '0.15s ease', medium: '0.3s ease' },
- dracula: {
- purple: '#bd93f9',
- cyan: '#8be9fd',
- green: '#50fa7b',
- pink: '#ff79c6',
- yellow: '#f1fa8c',
- orange: '#ffb86c',
- red: '#ff5555',
- },
- accent: { blue: '#268bd2', cyan: '#2aa198' },
- }),
-}));
-
-vi.mock('../../nodeDefinitions', () => ({
- nodeDefinitions: {
- httpRequest: {
- name: 'httpRequest',
- displayName: 'HTTP Request',
- group: ['utility'],
- outputs: ['response'],
- },
- cronScheduler: {
- name: 'cronScheduler',
- displayName: 'Cron Scheduler',
- group: ['scheduler'],
- outputs: ['data'],
- },
- aiAgent: {
- name: 'aiAgent',
- displayName: 'AI Agent',
- group: ['agent'],
- },
- simpleMemory: {
- name: 'simpleMemory',
- displayName: 'Simple Memory',
- group: ['memory'],
- },
- calculatorTool: {
- name: 'calculatorTool',
- displayName: 'Calculator',
- group: ['tool'],
- },
- batteryMonitor: {
- name: 'batteryMonitor',
- displayName: 'Battery Monitor',
- group: ['android'],
- },
- },
-}));
-
-import OutputPanel from '../OutputPanel';
-
-
-function setWorkflow(nodes: any[], edges: any[]) {
- storeState.currentWorkflow = {
- id: 'wf-1',
- name: 'wf',
- nodes,
- edges,
- createdAt: new Date(),
- lastModified: new Date(),
- };
-}
-
-
-beforeEach(() => {
- storeState.currentWorkflow = null;
-});
-
-
-describe('OutputPanel -- empty state', () => {
- it('renders empty placeholder when no edges target this node', () => {
- setWorkflow([{ id: 'n-1', type: 'aiAgent', data: {}, position: { x: 0, y: 0 } }], []);
- render(<OutputPanel nodeId="n-1" />);
- // Component renders an empty-state container; assert no connected node names show
- expect(screen.queryByText(/HTTP Request/)).not.toBeInTheDocument();
- expect(screen.queryByText(/Cron Scheduler/)).not.toBeInTheDocument();
- });
-
- it('renders empty when workflow is null', () => {
- storeState.currentWorkflow = null;
- const { container } = render(<OutputPanel nodeId="n-1" />);
- expect(container.textContent).not.toContain('HTTP Request');
- });
-});
-
-
-describe('OutputPanel -- listing connected nodes', () => {
- it('lists connected node via input-main edge', () => {
- setWorkflow(
- [
- { id: 'src', type: 'httpRequest', data: { label: 'HTTP' }, position: { x: 0, y: 0 } },
- { id: 'tgt', type: 'aiAgent', data: { label: 'Agent' }, position: { x: 100, y: 0 } },
- ],
- [
- {
- id: 'e1',
- source: 'src',
- target: 'tgt',
- sourceHandle: 'output',
- targetHandle: 'input-main',
- },
- ],
- );
-
- render(<OutputPanel nodeId="tgt" />);
- expect(screen.getByText(/HTTP Request/)).toBeInTheDocument();
- });
-
- it('SKIPS edges on config handles (input-memory/tools/skill/model)', () => {
- setWorkflow(
- [
- { id: 'mem', type: 'simpleMemory', data: { label: 'Mem' }, position: { x: 0, y: 0 } },
- { id: 'tool', type: 'calculatorTool', data: { label: 'Calc' }, position: { x: 0, y: 50 } },
- { id: 'tgt', type: 'aiAgent', data: { label: 'Agent' }, position: { x: 100, y: 0 } },
- ],
- [
- { id: 'e1', source: 'mem', target: 'tgt', sourceHandle: 'output', targetHandle: 'input-memory' },
- { id: 'e2', source: 'tool', target: 'tgt', sourceHandle: 'output', targetHandle: 'input-tools' },
- ],
- );
-
- render(<OutputPanel nodeId="tgt" />);
- expect(screen.queryByText(/Simple Memory/)).not.toBeInTheDocument();
- expect(screen.queryByText(/Calculator/)).not.toBeInTheDocument();
- });
-
- it('KEEPS input-task edges (data flow)', () => {
- setWorkflow(
- [
- { id: 'src', type: 'httpRequest', data: {}, position: { x: 0, y: 0 } },
- { id: 'tgt', type: 'aiAgent', data: {}, position: { x: 100, y: 0 } },
- ],
- [{ id: 'e1', source: 'src', target: 'tgt', sourceHandle: 'output', targetHandle: 'input-task' }],
- );
-
- render(<OutputPanel nodeId="tgt" />);
- expect(screen.getByText(/HTTP Request/)).toBeInTheDocument();
- });
-
- it("inherits parent agent's main inputs when current node is a memory node", () => {
- setWorkflow(
- [
- { id: 'src', type: 'cronScheduler', data: {}, position: { x: 0, y: 0 } },
- { id: 'mem', type: 'simpleMemory', data: {}, position: { x: 50, y: 0 } },
- { id: 'agent', type: 'aiAgent', data: {}, position: { x: 100, y: 0 } },
- ],
- [
- { id: 'e1', source: 'mem', target: 'agent', sourceHandle: 'output', targetHandle: 'input-memory' },
- { id: 'e2', source: 'src', target: 'agent', sourceHandle: 'output', targetHandle: 'input-main' },
- ],
- );
-
- render(<OutputPanel nodeId="mem" />);
- // Parent's main input (Cron Scheduler) should appear with "(via AI Agent)" label
- expect(screen.getByText(/Cron Scheduler.*via AI Agent/)).toBeInTheDocument();
- });
-});
-
-
-describe('OutputPanel -- drag-and-drop', () => {
- it('sets text/plain dataTransfer on drag-start with template variable format', async () => {
- setWorkflow(
- [
- { id: 'src', type: 'httpRequest', data: { label: 'My HTTP' }, position: { x: 0, y: 0 } },
- { id: 'tgt', type: 'aiAgent', data: {}, position: { x: 100, y: 0 } },
- ],
- [{ id: 'e1', source: 'src', target: 'tgt', sourceHandle: 'output', targetHandle: 'input-main' }],
- );
-
- const { container } = render(<OutputPanel nodeId="tgt" />);
-
- // Expand the node so outputs are draggable
- const headerBtn = screen.getByText(/HTTP Request/);
- await userEvent.click(headerBtn);
-
- // Find a draggable output element
- const draggables = container.querySelectorAll('[draggable="true"]');
- expect(draggables.length).toBeGreaterThan(0);
-
- const setData = vi.fn();
- const dragEvent = new Event('dragstart', { bubbles: true }) as any;
- dragEvent.dataTransfer = { setData, effectAllowed: '' };
-
- draggables[0].dispatchEvent(dragEvent);
-
- // The first output is `response` (per node definition mock)
- expect(setData).toHaveBeenCalledWith('text/plain', '{{myhttp.response}}');
- });
-});
-
-
-describe('OutputPanel -- Android node schema flattening', () => {
- it('exposes batteryMonitor schema fields as individual outputs', async () => {
- setWorkflow(
- [
- { id: 'bat', type: 'batteryMonitor', data: { label: 'Bat' }, position: { x: 0, y: 0 } },
- { id: 'tgt', type: 'aiAgent', data: {}, position: { x: 100, y: 0 } },
- ],
- [{ id: 'e1', source: 'bat', target: 'tgt', sourceHandle: 'output', targetHandle: 'input-main' }],
- );
-
- render(<OutputPanel nodeId="tgt" />);
-
- // Expand the connected battery node
- await userEvent.click(screen.getByText(/Battery Monitor/));
-
- // Should see flattened, human-readable battery fields
- expect(screen.getByText(/Battery Level/i)).toBeInTheDocument();
- expect(screen.getByText(/Is Charging/i)).toBeInTheDocument();
- expect(screen.getByText(/Temperature Celsius/i)).toBeInTheDocument();
- });
-});
diff --git a/client/src/components/parameterPanel/__tests__/InputSection.test.tsx b/client/src/components/parameterPanel/__tests__/InputSection.test.tsx
index 713a91f5..52637bbf 100644
--- a/client/src/components/parameterPanel/__tests__/InputSection.test.tsx
+++ b/client/src/components/parameterPanel/__tests__/InputSection.test.tsx
@@ -65,15 +65,10 @@ vi.mock('../../../hooks/useAppTheme', () => ({
}),
}));
-vi.mock('../../../nodeDefinitions', () => ({
- nodeDefinitions: {
- httpRequest: { name: 'httpRequest', displayName: 'HTTP Request', icon: 'H', group: ['utility'] },
- cronScheduler: { name: 'cronScheduler', displayName: 'Cron Scheduler', icon: 'C', group: ['scheduler'] },
- aiAgent: { name: 'aiAgent', displayName: 'AI Agent', icon: 'A', group: ['agent'] },
- simpleMemory: { name: 'simpleMemory', displayName: 'Simple Memory', icon: 'M', group: ['memory'] },
- calculatorTool: { name: 'calculatorTool', displayName: 'Calculator', icon: 'X', group: ['tool'] },
- },
-}));
+// The legacy `../../../nodeDefinitions` module was deleted in Wave 11;
+// InputSection now resolves node metadata via `lib/nodeSpec`. The
+// remaining tests in this file exercise edge-filtering behaviour that
+// doesn't need per-type metadata, so no spec mock is required.
import InputSection from '../InputSection';
@@ -200,26 +195,7 @@ describe('InputSection -- config handle filtering for agent nodes', () => {
});
-describe('InputSection -- config-node parent inheritance', () => {
- it("inherits parent agent's main inputs when current node is a memory node", async () => {
- setWorkflow(
- [
- { id: 'src', type: 'cronScheduler', data: { label: 'Cron' }, position: { x: 0, y: 0 } },
- { id: 'mem', type: 'simpleMemory', data: { label: 'Memory' }, position: { x: 50, y: 0 } },
- { id: 'agent', type: 'aiAgent', data: { label: 'Agent' }, position: { x: 100, y: 0 } },
- ],
- [
- // mem is connected to agent via input-memory (config edge)
- { id: 'e1', source: 'mem', target: 'agent', sourceHandle: 'output', targetHandle: 'input-memory' },
- // src is connected to agent via input-main (the inherited input)
- { id: 'e2', source: 'src', target: 'agent', sourceHandle: 'output', targetHandle: 'input-main' },
- ],
- );
-
- // When viewing the memory node, we should see Cron via Agent
- render(<InputSection nodeId="mem" />);
- await waitFor(() => {
- expect(screen.getByText(/Cron Scheduler|Cron/)).toBeInTheDocument();
- });
- });
-});
+// `InputSection -- config-node parent inheritance` removed: the single
+// test in that describe block depended on mocking `../../../nodeDefinitions`
+// (now deleted). The config-handle filtering logic that remains in this
+// file covers the agent-side of the same behaviour.
diff --git a/client/src/hooks/__tests__/useParameterPanel.test.ts b/client/src/hooks/__tests__/useParameterPanel.test.ts
deleted file mode 100644
index 09987cf0..00000000
--- a/client/src/hooks/__tests__/useParameterPanel.test.ts
+++ /dev/null
@@ -1,272 +0,0 @@
-/**
- * Tests for useParameterPanel hook.
- *
- * Locks in:
- * - Defaults loaded from nodeDefinition.properties[].default
- * - Saved parameters fetched via WebSocket and merged over defaults (saved wins)
- * - hasUnsavedChanges computed via JSON.stringify equality
- * - handleSave persists to DB and updates originalParameters
- * - handleCancel reverts pending edits and clears selection
- * - WebSocket failure falls back to defaults and surfaces error
- */
-
-import { describe, it, expect, vi, beforeEach } from 'vitest';
-import { renderHook, act, waitFor } from '@testing-library/react';
-import { useParameterPanel } from '../useParameterPanel';
-import { wrapperWithProviders } from '../../test/providers';
-
-// Scaling-v2 wraps useParameterPanel reads in TanStack Query, so the hook
-// MUST be rendered inside a QueryClientProvider. `wrapperWithProviders` adds
-// QueryClientProvider + ThemeProvider for every renderHook call below.
-const wrapper = wrapperWithProviders;
-
-// --- Mock store --------------------------------------------------------------
-
-const storeState: { selectedNode: any; setSelectedNode: any } = {
- selectedNode: null,
- setSelectedNode: vi.fn(),
-};
-vi.mock('../../store/useAppStore', () => ({
- useAppStore: () => storeState,
-}));
-
-// --- Mock node definitions ---------------------------------------------------
-
-vi.mock('../../nodeDefinitions', () => ({
- nodeDefinitions: {
- httpRequest: {
- name: 'httpRequest',
- displayName: 'HTTP Request',
- properties: [
- { name: 'method', type: 'options', default: 'GET' },
- { name: 'url', type: 'string', default: '' },
- { name: 'timeout', type: 'number', default: 30 },
- ],
- },
- nodeWithoutDefaults: {
- name: 'nodeWithoutDefaults',
- displayName: 'No Defaults',
- properties: [{ name: 'foo', type: 'string' }], // no default
- },
- },
-}));
-
-// --- Mock skill node types ---------------------------------------------------
-
-vi.mock('../../nodeDefinitions/skillNodes', () => ({
- SKILL_NODE_TYPES: ['masterSkill', 'customSkill'],
-}));
-
-// --- Mock WebSocket context --------------------------------------------------
-
-const wsMock = {
- isConnected: true,
- getNodeParameters: vi.fn(),
- saveNodeParameters: vi.fn(),
- sendRequest: vi.fn(),
-};
-vi.mock('../../contexts/WebSocketContext', () => ({
- useWebSocket: () => wsMock,
-}));
-
-
-function selectNode(node: any | null) {
- storeState.selectedNode = node;
- storeState.setSelectedNode = vi.fn();
-}
-
-
-beforeEach(() => {
- selectNode(null);
- wsMock.getNodeParameters.mockReset();
- wsMock.saveNodeParameters.mockReset();
- wsMock.sendRequest.mockReset();
- // Default: backend has nothing saved
- wsMock.getNodeParameters.mockResolvedValue(null);
- wsMock.saveNodeParameters.mockResolvedValue(true);
-});
-
-
-describe('initial parameter loading', () => {
- it('returns empty params when no node is selected', () => {
- const { result } = renderHook(() => useParameterPanel(), { wrapper: wrapper() });
- expect(result.current.parameters).toEqual({});
- expect(result.current.hasUnsavedChanges).toBe(false);
- });
-
- it('loads defaults from nodeDefinition.properties when DB has nothing', async () => {
- selectNode({ id: 'n-1', type: 'httpRequest' });
-
- const { result } = renderHook(() => useParameterPanel(), { wrapper: wrapper() });
-
- await waitFor(() => {
- expect(result.current.parameters.method).toBe('GET');
- });
- expect(result.current.parameters.url).toBe('');
- expect(result.current.parameters.timeout).toBe(30);
- expect(result.current.hasUnsavedChanges).toBe(false);
- });
-
- it('uses null when a property has no default', async () => {
- selectNode({ id: 'n-1', type: 'nodeWithoutDefaults' });
-
- const { result } = renderHook(() => useParameterPanel(), { wrapper: wrapper() });
-
- await waitFor(() => {
- expect(result.current.parameters).toHaveProperty('foo');
- });
- expect(result.current.parameters.foo).toBeNull();
- });
-
- it('merges saved params over defaults (saved wins)', async () => {
- wsMock.getNodeParameters.mockResolvedValue({
- parameters: { method: 'POST', url: 'https://api.example.com' },
- version: 1,
- timestamp: Date.now(),
- });
-
- selectNode({ id: 'n-1', type: 'httpRequest' });
- const { result } = renderHook(() => useParameterPanel(), { wrapper: wrapper() });
-
- await waitFor(() => {
- expect(result.current.parameters.method).toBe('POST');
- });
- expect(result.current.parameters.url).toBe('https://api.example.com');
- expect(result.current.parameters.timeout).toBe(30); // default kept
- });
-
- it('falls back to defaults and surfaces error on WebSocket failure', async () => {
- wsMock.getNodeParameters.mockRejectedValue(new Error('WS down'));
-
- selectNode({ id: 'n-1', type: 'httpRequest' });
- const { result } = renderHook(() => useParameterPanel(), { wrapper: wrapper() });
-
- await waitFor(() => {
- expect(result.current.error).toBeTruthy();
- });
- expect(result.current.parameters.method).toBe('GET');
- });
-});
-
-
-describe('hasUnsavedChanges and handleParameterChange', () => {
- it('starts false and flips true after a parameter change', async () => {
- selectNode({ id: 'n-1', type: 'httpRequest' });
- const { result } = renderHook(() => useParameterPanel(), { wrapper: wrapper() });
-
- await waitFor(() => expect(result.current.parameters.method).toBe('GET'));
- expect(result.current.hasUnsavedChanges).toBe(false);
-
- act(() => {
- result.current.handleParameterChange('method', 'POST');
- });
-
- expect(result.current.parameters.method).toBe('POST');
- expect(result.current.hasUnsavedChanges).toBe(true);
- });
-
- it('flips back to false when the value is reverted to original', async () => {
- selectNode({ id: 'n-1', type: 'httpRequest' });
- const { result } = renderHook(() => useParameterPanel(), { wrapper: wrapper() });
- await waitFor(() => expect(result.current.parameters.method).toBe('GET'));
-
- act(() => result.current.handleParameterChange('method', 'POST'));
- expect(result.current.hasUnsavedChanges).toBe(true);
-
- act(() => result.current.handleParameterChange('method', 'GET'));
- expect(result.current.hasUnsavedChanges).toBe(false);
- });
-});
-
-
-describe('handleSave', () => {
- it('saves to WebSocket and updates originalParameters on success', async () => {
- selectNode({ id: 'n-42', type: 'httpRequest' });
- const { result } = renderHook(() => useParameterPanel(), { wrapper: wrapper() });
- await waitFor(() => expect(result.current.parameters.method).toBe('GET'));
-
- act(() => result.current.handleParameterChange('method', 'PUT'));
- expect(result.current.hasUnsavedChanges).toBe(true);
-
- await act(async () => {
- await result.current.handleSave();
- });
-
- // Scaling-v2 may pass an optional `version` as the 3rd arg for optimistic
- // concurrency control. Inspect the spy call directly to remain agnostic.
- expect(wsMock.saveNodeParameters).toHaveBeenCalledTimes(1);
- const [calledNodeId, calledParams] = wsMock.saveNodeParameters.mock.calls[0];
- expect(calledNodeId).toBe('n-42');
- expect(calledParams).toEqual(expect.objectContaining({ method: 'PUT' }));
- expect(result.current.hasUnsavedChanges).toBe(false);
- expect(result.current.error).toBeNull();
- });
-
- it('surfaces error and keeps unsaved state when save returns false', async () => {
- wsMock.saveNodeParameters.mockResolvedValue(false);
-
- selectNode({ id: 'n-1', type: 'httpRequest' });
- const { result } = renderHook(() => useParameterPanel(), { wrapper: wrapper() });
- await waitFor(() => expect(result.current.parameters.method).toBe('GET'));
-
- act(() => result.current.handleParameterChange('method', 'POST'));
-
- await act(async () => {
- await result.current.handleSave();
- });
-
- expect(result.current.error).toBe('Failed to save parameters');
- expect(result.current.hasUnsavedChanges).toBe(true);
- });
-
- it('handles save rejection without throwing', async () => {
- wsMock.saveNodeParameters.mockRejectedValue(new Error('boom'));
-
- selectNode({ id: 'n-1', type: 'httpRequest' });
- const { result } = renderHook(() => useParameterPanel(), { wrapper: wrapper() });
- await waitFor(() => expect(result.current.parameters.method).toBe('GET'));
-
- act(() => result.current.handleParameterChange('method', 'POST'));
-
- await act(async () => {
- await result.current.handleSave();
- });
-
- expect(result.current.error).toBe('Failed to save parameters');
- });
-});
-
-
-describe('handleCancel', () => {
- it('reverts pending edits and clears selection', async () => {
- selectNode({ id: 'n-1', type: 'httpRequest' });
- const { result } = renderHook(() => useParameterPanel(), { wrapper: wrapper() });
- await waitFor(() => expect(result.current.parameters.method).toBe('GET'));
-
- act(() => result.current.handleParameterChange('method', 'DELETE'));
- expect(result.current.parameters.method).toBe('DELETE');
-
- act(() => result.current.handleCancel());
-
- expect(result.current.parameters.method).toBe('GET');
- expect(storeState.setSelectedNode).toHaveBeenCalledWith(null);
- });
-});
-
-
-describe('nodeDefinition exposure', () => {
- it('exposes the matching node definition', async () => {
- selectNode({ id: 'n-1', type: 'httpRequest' });
- const { result } = renderHook(() => useParameterPanel(), { wrapper: wrapper() });
- await waitFor(() => expect(result.current.nodeDefinition).toBeTruthy());
- expect(result.current.nodeDefinition?.displayName).toBe('HTTP Request');
- });
-
- it('returns falsy nodeDefinition for unknown node type', async () => {
- selectNode({ id: 'n-1', type: 'unknownType' });
- const { result } = renderHook(() => useParameterPanel(), { wrapper: wrapper() });
- await waitFor(() => expect(result.current.parameters).toEqual({}));
- // nodeDefinitions[unknownType] is undefined; hook returns it as-is
- expect(result.current.nodeDefinition).toBeFalsy();
- });
-});