Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
test(web): exercise real initialization and retrieval form owners (#44656)
Stephen Zhou03a92c902af2
diff --git a/web/app/components/rag-pipeline/__tests__/index.spec.tsx b/web/app/components/rag-pipeline/__tests__/index.spec.tsxindex 7d713805ba4..50186e4771e 100644--- a/web/app/components/rag-pipeline/__tests__/index.spec.tsx+++ b/web/app/components/rag-pipeline/__tests__/index.spec.tsx@@ -1,90 +1,139 @@-import { render, screen } from '@testing-library/react'-import { createNode } from '@/app/components/workflow/__tests__/fixtures'+import type { Viewport } from 'reactflow'+import type { FetchWorkflowDraftResponse } from '@/types/workflow'+import { act, screen } from '@testing-library/react'+import { createEdge, createNode } from '@/app/components/workflow/__tests__/fixtures'+import { WorkflowInitializationProbe } from '@/app/components/workflow/__tests__/workflow-initialization-probe'+import knowledgeBaseDefault from '@/app/components/workflow/nodes/knowledge-base/default'import { BlockEnum } from '@/app/components/workflow/types'+import DatasetDetailContext from '@/context/dataset-detail'+import { renderWithConsoleQuery } from '@/test/console/query-data'+import { createDeferred } from '@/test/deferred'+import { createDatasetFixture } from '@/test/fixtures/dataset'+import { createFileUploadConfigFixture } from '@/test/fixtures/file-upload-config'import RagPipelineWrapper from '../index'-let pipelineId: string | undefined-let pipelineInit: { data?: Record<string, unknown>; isLoading: boolean }--vi.mock('@/context/dataset-detail', () => ({- useDatasetDetailContextWithSelector: (selector: (state: Record<string, unknown>) => unknown) =>- selector({ dataset: pipelineId ? { pipeline_id: pipelineId } : undefined }),-}))--vi.mock('../hooks/use-pipeline-init', () => ({- usePipelineInit: () => pipelineInit,+const requests = vi.hoisted(() => ({+ draft: vi.fn<typeof import('@/service/workflow').fetchWorkflowDraft>(),}))--vi.mock('../store', () => ({- createRagPipelineSliceSlice: vi.fn(),+vi.mock('@/next/navigation', async (importOriginal) => ({+ ...(await importOriginal<typeof import('@/next/navigation')>()),+ useParams: () => ({ datasetId: 'dataset-1' }),}))--vi.mock('../components/conversion', () => ({- default: () => <div>Conversion</div>,+vi.mock('@/service/workflow', async (importOriginal) => ({+ ...(await importOriginal<typeof import('@/service/workflow')>()),+ fetchWorkflowDraft: requests.draft,}))+vi.mock('@/service/console', async (importOriginal) => {+ const actual = await importOriginal<typeof import('@/service/console')>()+ const { withConsoleResponses } = await import('@/test/console/service-responses')+ return {+ ...actual,+ consoleQuery: withConsoleResponses(actual.consoleQuery, {+ 'rag.pipelines.byPipelineId.workflows.defaultWorkflowBlockConfigs.get': async () => [],+ 'rag.pipelines.byPipelineId.workflows.publish.get': async () => null,+ 'files.upload.get': async () => createFileUploadConfigFixture(),+ 'rag.pipelines.datasourcePlugins.get': async () => [],+ }),+ }+})+// Full pipeline editing has its own suite; retain the real initialization/provider boundary.vi.mock('../components/rag-pipeline-main', () => ({- default: ({- nodes,- edges,- viewport,- }: {- nodes: unknown[]- edges: unknown[]- viewport: { zoom: number }- }) => (- <div>- Pipeline {nodes.length}/{edges.length}/{viewport.zoom}- </div>+ default: ({ viewport }: { viewport: Viewport }) => (+ <>+ <WorkflowInitializationProbe />+ <output aria-label="Initial viewport">{JSON.stringify(viewport)}</output>+ </>),}))-vi.mock('@/app/components/workflow', () => ({- default: ({ children }: { children: React.ReactNode }) => (- <div data-testid="workflow-default-context">{children}</div>- ),-}))+const draft = (): FetchWorkflowDraftResponse => ({+ id: 'draft-1',+ graph: {+ nodes: [+ createNode({+ id: 'source',+ data: {+ type: BlockEnum.DataSource,+ title: 'Local files',+ plugin_id: 'langgenius/file',+ provider_type: 'local_file',+ provider_name: 'file',+ datasource_name: 'local-file',+ datasource_label: 'Local files',+ datasource_parameters: {},+ datasource_configurations: {},+ },+ }),+ createNode({+ id: 'knowledge',+ data: {+ ...knowledgeBaseDefault.defaultValue,+ type: BlockEnum.KnowledgeBase,+ title: 'Knowledge',+ },+ }),+ ],+ edges: [createEdge({ source: 'source', target: 'knowledge' })],+ viewport: { x: 80, y: 40, zoom: 1.5 },+ },+ hash: 'draft-hash',+ created_at: 1_712_300_000,+ updated_at: 1_712_345_678,+ created_by: { id: 'user-1', name: 'User', email: '[email protected]' },+ updated_by: { id: 'user-1', name: 'User', email: '[email protected]' },+ tool_published: false,+ version: 'draft',+ marked_name: '',+ marked_comment: '',+})-vi.mock('@/app/components/workflow/context', () => ({- WorkflowContextProvider: ({ children }: { children: React.ReactNode }) => children,-}))+const renderPipeline = (pipelineId: string | null = 'pipeline-1') => {+ const DatasetProvider = DatasetDetailContext.Provider+ return renderWithConsoleQuery(+ <DatasetProvider value={{ dataset: createDatasetFixture({ pipeline_id: pipelineId }) }}>+ <RagPipelineWrapper />+ </DatasetProvider>,+ )+}++beforeEach(() => requests.draft.mockReset().mockResolvedValue(draft()))++const expectGraph = async () => {+ expect(await screen.findByRole('status', { name: 'Initialized nodes' })).toHaveTextContent(+ 'source:Local files,knowledge:Knowledge',+ )+ expect(screen.getByRole('status', { name: 'Initialized edges' })).toHaveTextContent(+ 'source->knowledge',+ )+ expect(screen.getByRole('status', { name: 'Initial viewport' })).toHaveTextContent(+ JSON.stringify({ x: 80, y: 40, zoom: 1.5 }),+ )+ expect(screen.queryByRole('progressbar')).not.toBeInTheDocument()+}describe('RagPipeline', () => {- beforeEach(() => {- pipelineId = undefined- pipelineInit = { data: undefined, isLoading: false }- })-it('offers conversion when the dataset has no pipeline', () => {- render(<RagPipelineWrapper />)-- expect(screen.getByText('Conversion')).toBeInTheDocument()+ renderPipeline(null)+ expect(+ screen.getByRole('button', { name: 'datasetPipeline.operations.convert' }),+ ).toBeInTheDocument()+ expect(requests.draft).not.toHaveBeenCalled()})-- it('shows loading while an existing pipeline initializes', () => {- pipelineId = 'pipeline-1'- pipelineInit = { data: undefined, isLoading: true }-- render(<RagPipelineWrapper />)-+ it('keeps the editor gated until the pipeline draft arrives', async () => {+ const pending = createDeferred<FetchWorkflowDraftResponse>()+ requests.draft.mockReturnValue(pending.promise)+ renderPipeline()expect(screen.getByRole('progressbar')).toBeInTheDocument()+ expect(screen.queryByRole('status', { name: 'Initialized nodes' })).not.toBeInTheDocument()+ await act(async () => pending.resolve(draft()))+ await expectGraph()})-- it('passes initialized graph data to the pipeline', () => {- pipelineId = 'pipeline-1'- pipelineInit = {- data: {- graph: {- nodes: [createNode({ id: 'source', data: { type: BlockEnum.DataSource } })],- edges: [],- viewport: { x: 0, y: 0, zoom: 1.5 },- },- },- isLoading: false,- }-- render(<RagPipelineWrapper />)-- expect(screen.getByText('Pipeline 1/0/1.5')).toBeInTheDocument()+ it('loads the dataset pipeline into the real workflow provider', async () => {+ renderPipeline()+ await expectGraph()+ expect(requests.draft).toHaveBeenCalledExactlyOnceWith(+ '/rag/pipelines/pipeline-1/workflows/draft',+ )})})diff --git a/web/app/components/snippets/__tests__/index.spec.tsx b/web/app/components/snippets/__tests__/index.spec.tsxindex ca4e612607b..522a285dafd 100644--- a/web/app/components/snippets/__tests__/index.spec.tsx+++ b/web/app/components/snippets/__tests__/index.spec.tsx@@ -1,170 +1,157 @@-import type { SnippetDetailPayload } from '@/models/snippet'-import { render, screen } from '@testing-library/react'+import type { SnippetWorkflow } from '@/types/snippet'+import { act, screen, waitFor } from '@testing-library/react'+import { createEdge, createNode } from '@/app/components/workflow/__tests__/fixtures'+import { WorkflowInitializationProbe } from '@/app/components/workflow/__tests__/workflow-initialization-probe'+import codeNodeDefault from '@/app/components/workflow/nodes/code/default'+import { consoleQuery } from '@/service/console'+import { createHttpError } from '@/service/http-error'+import { renderWithConsoleQuery } from '@/test/console/query-data'+import { createDeferred } from '@/test/deferred'import SnippetPage from '..'-const mockUseSnippetInit = vi.fn()-let capturedWorkflowDefaultContextProps:- | {- nodes: unknown[]- edges: unknown[]- }- | undefined--vi.mock('../hooks/use-snippet-init', () => ({- useSnippetInit: (snippetId: string) => mockUseSnippetInit(snippetId),+const requests = vi.hoisted(() => ({+ detail: vi.fn(),+ draft: vi.fn(),+ defaults: vi.fn(),+ published: vi.fn(),}))+vi.mock('@/service/console', async (importOriginal) => {+ const actual = await importOriginal<typeof import('@/service/console')>()+ const { withConsoleResponses, withConsoleClientResponses } =+ await import('@/test/console/service-responses')+ return {+ ...actual,+ consoleClient: withConsoleClientResponses(actual.consoleClient, {+ 'snippets.bySnippetId.workflows.draft.get': requests.draft,+ }),+ consoleQuery: withConsoleResponses(actual.consoleQuery, {+ 'workspaces.current.customizedSnippets.bySnippetId.get': requests.detail,+ 'snippets.bySnippetId.workflows.defaultWorkflowBlockConfigs.get': requests.defaults,+ 'snippets.bySnippetId.workflows.publish.get': requests.published,+ }),+ }+})++// SnippetMain owns editing and publishing; this page owns fetching and choosing the initial graph.vi.mock('../components/snippet-main', () => ({default: ({ hasPublishedWorkflow }: { hasPublishedWorkflow: boolean }) => (- <div data-testid="snippet-main">{String(hasPublishedWorkflow)}</div>+ <>+ <WorkflowInitializationProbe />+ <output aria-label="Published workflow">{String(hasPublishedWorkflow)}</output>+ </>),}))-vi.mock('@/hooks/use-document-title', () => ({- default: vi.fn(),-}))--vi.mock('@/app/components/workflow', () => ({- default: ({- children,- nodes,- edges,- }: {- children: React.ReactNode- nodes: unknown[]- edges: unknown[]- }) => {- capturedWorkflowDefaultContextProps = {- nodes,- edges,- }-- return <div data-testid="workflow-default-context">{children}</div>+const workflow = (version: string): SnippetWorkflow => ({+ id: version,+ graph: {+ nodes: [+ createNode({+ id: `${version}-source`,+ data: {+ ...codeNodeDefault.defaultValue,+ code: 'def main(): return {}',+ title: `${version} source`,+ },+ }),+ createNode({+ id: `${version}-target`,+ data: {+ ...codeNodeDefault.defaultValue,+ code: 'def main(): return {}',+ title: `${version} target`,+ },+ }),+ ],+ edges: [createEdge({ source: `${version}-source`, target: `${version}-target` })],+ viewport: { x: 0, y: 0, zoom: 1 },},-}))--vi.mock('@/app/components/workflow/context', () => ({- WorkflowContextProvider: ({ children }: { children: React.ReactNode }) => children,-}))+ features: {},+ input_fields: [],+ hash: `${version}-hash`,+ created_at: 1_712_300_000,+ updated_at: 1_712_345_678,+})-const createSnippetDetailPayload = (nodeId: string, edgeId: string): SnippetDetailPayload => ({- snippet: {+beforeEach(() => {+ requests.detail.mockReset().mockResolvedValue({id: 'snippet-1',name: 'Tone Rewriter',- description: 'A static snippet mock.',- updatedAt: 'Updated 2h ago',- usage: 'Used 19 times',+ description: 'Rewrites a draft.',+ type: 'node',+ is_published: true,+ version: '1',+ use_count: 0,tags: [],- status: 'Draft',- },- graph: {- viewport: { x: 0, y: 0, zoom: 1 },- nodes: [- {- id: nodeId,- position: { x: 0, y: 0 },- data: { title: nodeId, type: 'code' },- },- ] as SnippetDetailPayload['graph']['nodes'],- edges: [- {- id: edgeId,- source: nodeId,- target: `${nodeId}-target`,- },- ] as SnippetDetailPayload['graph']['edges'],- },- inputFields: [],- uiMeta: {- inputFieldCount: 0,- checklistCount: 0,- autoSavedAt: 'Auto-saved · a few seconds ago',- },+ created_at: 1_712_300_000,+ created_by: 'user-1',+ updated_at: 1_712_300_000,+ updated_by: 'user-1',+ })+ requests.defaults.mockReset().mockResolvedValue({})+ requests.draft.mockReset().mockResolvedValue(workflow('draft'))+ requests.published.mockReset().mockResolvedValue(workflow('published'))})-const mockPublishedSnippetDetail = createSnippetDetailPayload('published-node', 'published-edge')-const mockDraftSnippetDetail = createSnippetDetailPayload('draft-node', 'draft-edge')+const expectGraph = async (version: string) => {+ expect(await screen.findByRole('status', { name: 'Initialized nodes' })).toHaveTextContent(+ `${version}-source:${version} source,${version}-target:${version} target`,+ )+ expect(screen.getByRole('status', { name: 'Initialized edges' })).toHaveTextContent(+ `${version}-source->${version}-target`,+ )+ expect(screen.queryByRole('progressbar')).not.toBeInTheDocument()+}describe('SnippetPage', () => {- beforeEach(() => {- vi.clearAllMocks()- capturedWorkflowDefaultContextProps = undefined- mockUseSnippetInit.mockReturnValue({- data: {- snippet: mockDraftSnippetDetail.snippet,- published: mockPublishedSnippetDetail,- draft: mockDraftSnippetDetail,- draftWorkflow: {- hash: 'draft-hash',- },- publishedWorkflow: {- hash: 'published-hash',- },- hasDraftChanges: true,- },- isLoading: false,- })- })-- it('should initialize workflow context with published graph data when the published workflow exists', () => {- render(<SnippetPage snippetId="snippet-1" />)-- expect(capturedWorkflowDefaultContextProps?.nodes).toMatchObject(- mockPublishedSnippetDetail.graph.nodes,+ it.each([+ { published: true, version: 'published' },+ { published: false, version: 'draft' },+ ])(+ 'initializes the $version graph in the real workflow provider',+ async ({ published, version }) => {+ if (!published) requests.published.mockResolvedValue(null)+ renderWithConsoleQuery(<SnippetPage snippetId="snippet-1" />)++ await expectGraph(version)+ expect(screen.getByRole('status', { name: 'Published workflow' })).toHaveTextContent(+ String(published),+ )+ expect(requests.draft).toHaveBeenCalledWith(+ { params: { snippet_id: 'snippet-1' } },+ expect.anything(),+ )+ },+ )++ it('keeps the loading fallback when the snippet is unavailable', async () => {+ requests.detail.mockRejectedValue(+ createHttpError(new Response(null, { status: 404 }), { message: 'Not found' }),)- expect(capturedWorkflowDefaultContextProps?.edges).toMatchObject(- mockPublishedSnippetDetail.graph.edges,+ const { queryClient } = renderWithConsoleQuery(<SnippetPage snippetId="missing-snippet" />)++ await waitFor(() =>+ expect(+ queryClient.getQueryState(+ consoleQuery.workspaces.current.customizedSnippets.bySnippetId.get.queryKey({+ input: { params: { snippet_id: 'missing-snippet' } },+ }),+ )?.status,+ ).toBe('error'),)- expect(screen.getByTestId('snippet-main')).toHaveTextContent('true')- })-- it('should initialize workflow context with draft graph data when the published workflow is empty', () => {- mockUseSnippetInit.mockReturnValue({- data: {- snippet: mockDraftSnippetDetail.snippet,- published: mockPublishedSnippetDetail,- draft: mockDraftSnippetDetail,- draftWorkflow: {- hash: 'draft-hash',- },- publishedWorkflow: undefined,- hasDraftChanges: true,- },- isLoading: false,- })-- render(<SnippetPage snippetId="snippet-1" />)-- expect(capturedWorkflowDefaultContextProps?.nodes).toMatchObject(- mockDraftSnippetDetail.graph.nodes,- )- expect(capturedWorkflowDefaultContextProps?.edges).toMatchObject(- mockDraftSnippetDetail.graph.edges,- )- expect(screen.getByTestId('snippet-main')).toHaveTextContent('false')- })-- it('should render loading fallback when orchestrate data is unavailable', () => {- mockUseSnippetInit.mockReturnValue({- data: null,- isLoading: false,- })-- render(<SnippetPage snippetId="missing-snippet" />)-expect(screen.getByRole('progressbar')).toBeInTheDocument()- expect(screen.queryByTestId('snippet-main')).not.toBeInTheDocument()+ expect(screen.queryByRole('status', { name: 'Initialized nodes' })).not.toBeInTheDocument()})- it('should keep the detail route shell while orchestrate data is loading', () => {- mockUseSnippetInit.mockReturnValue({- data: undefined,- isLoading: true,- })-- render(<SnippetPage snippetId="snippet-1" />)+ it('keeps the route shell gated until the draft arrives', async () => {+ const pending = createDeferred<SnippetWorkflow>()+ requests.draft.mockReturnValue(pending.promise)+ renderWithConsoleQuery(<SnippetPage snippetId="snippet-1" />)expect(screen.getByRole('progressbar')).toBeInTheDocument()- expect(screen.queryByTestId('snippet-main')).not.toBeInTheDocument()+ expect(screen.queryByRole('status', { name: 'Initialized nodes' })).not.toBeInTheDocument()+ await act(async () => pending.resolve(workflow('draft')))+ await expectGraph('published')})})diff --git a/web/app/components/workflow/__tests__/workflow-initialization-probe.tsx b/web/app/components/workflow/__tests__/workflow-initialization-probe.tsxnew file mode 100644index 00000000000..0beda26f0f6--- /dev/null+++ b/web/app/components/workflow/__tests__/workflow-initialization-probe.tsx@@ -0,0 +1,17 @@+import { useStore } from '../store'++// The full editors have their own interaction suites. At the page boundary, read the+// graph initialized by the real provider instead of capturing provider props in a mock.+export function WorkflowInitializationProbe() {+ const graph = useStore((state) => state.workflowHistory)+ return (+ <>+ <output aria-label="Initialized nodes">+ {graph.nodes.map((node) => `${node.id}:${node.data.title}`).join(',')}+ </output>+ <output aria-label="Initialized edges">+ {graph.edges.map((edge) => `${edge.source}->${edge.target}`).join(',')}+ </output>+ </>+ )+}diff --git a/web/app/components/workflow/nodes/knowledge-retrieval-v2/__tests__/use-single-run-form-params.spec.ts b/web/app/components/workflow/nodes/knowledge-retrieval-v2/__tests__/use-single-run-form-params.spec.tsindex fafa69f1b24..c8319a1aa5f 100644--- a/web/app/components/workflow/nodes/knowledge-retrieval-v2/__tests__/use-single-run-form-params.spec.ts+++ b/web/app/components/workflow/nodes/knowledge-retrieval-v2/__tests__/use-single-run-form-params.spec.ts@@ -1,19 +1,20 @@import type { KnowledgeRetrievalV2NodeType } from '../types'-import { renderHook } from '@testing-library/react'-import useAvailableVarList from '@/app/components/workflow/nodes/_base/hooks/use-available-var-list'+import { act } from '@testing-library/react'+import { useLayoutEffect, useRef, useState } from 'react'+import { createEdge, createNode } from '@/app/components/workflow/__tests__/fixtures'+import { renderWorkflowCanvasHook } from '@/app/components/workflow/__tests__/workflow-test-env'import {ComparisonOperator,LogicalOperator,+ MetadataFilteringModeEnum,} from '@/app/components/workflow/nodes/knowledge-retrieval/types'-import { BlockEnum, InputVarType, VarType } from '@/app/components/workflow/types'+import { BlockEnum, InputVarType } from '@/app/components/workflow/types'+import { consoleQuery } from '@/service/console'+import { seedModelProviderQueries } from '@/test/console/model-provider'+import { createConsoleQueryWrapper } from '@/test/console/query-data'+import { seedToolProviders } from '@/test/console/tool-providers'import useSingleRunFormParams from '../use-single-run-form-params'-vi.mock('@/app/components/workflow/nodes/_base/hooks/use-available-var-list', () => ({- default: vi.fn(),-}))--const mockUseAvailableVarList = vi.mocked(useAvailableVarList)-const createData = (overrides: Partial<KnowledgeRetrievalV2NodeType> = {},): KnowledgeRetrievalV2NodeType => ({@@ -27,36 +28,75 @@ const createData = (...overrides,})-describe('knowledge-retrieval-v2/use-single-run-form-params', () => {- beforeEach(() => {- vi.clearAllMocks()- mockUseAvailableVarList.mockReturnValue({- availableNodes: [],- availableNodesWithParent: [],- availableVars: [- {- nodeId: 'start',- title: 'Start',- vars: [{ variable: 'images', type: VarType.arrayFile }],- },- ],- })+const setup = (+ payload = createData(),+ initialValues: Record<string, unknown> = {},+ getInputVars: Parameters<typeof useSingleRunFormParams>[0]['getInputVars'] = () => [],+) => {+ const { queryClient } = createConsoleQueryWrapper()+ seedModelProviderQueries(queryClient)+ seedToolProviders(queryClient, {+ builtInTools: [],+ customTools: [],+ workflowTools: [],+ mcpTools: [],})-- it('builds an image form whenever an attachment selector is configured', () => {- const setRunInputData = vi.fn()- const current = { query: 'find this diagram', queryAttachment: ['file-1'] }- const { result } = renderHook(() =>- useSingleRunFormParams({+ queryClient.setQueryData(consoleQuery.spec.schemaDefinitions.get.queryKey(), [])+ return renderWorkflowCanvasHook(+ () => {+ const [runInputData, setRunInputData] = useState(initialValues)+ const runInputDataRef = useRef(runInputData)+ useLayoutEffect(() => {+ runInputDataRef.current = runInputData+ }, [runInputData])+ return useSingleRunFormParams({id: 'retrieval-1',- payload: createData(),- runInputData: current,- runInputDataRef: { current },- getInputVars: () => [],+ payload,+ runInputData,+ runInputDataRef,setRunInputData,+ getInputVars,toVarInputs: () => [],- }),- )+ })+ },+ {+ queryClient,+ nodes: [+ createNode({+ id: 'start',+ data: {+ type: BlockEnum.Start,+ title: 'Start',+ variables: [+ { variable: 'query', label: 'Query', type: InputVarType.textInput, required: false },+ {+ variable: 'department',+ label: 'Department',+ type: InputVarType.textInput,+ required: false,+ },+ {+ variable: 'images',+ label: 'Images',+ type: InputVarType.multiFiles,+ required: false,+ },+ ],+ },+ }),+ createNode({ id: 'retrieval-1', data: payload }),+ ],+ edges: [createEdge({ source: 'start', target: 'retrieval-1' })],+ },+ )+}++describe('knowledge-retrieval-v2/use-single-run-form-params', () => {+ it('builds an image form whenever an attachment selector is configured', () => {+ const { result } = setup(createData(), {+ query: 'find this diagram',+ queryAttachment: ['file-1'],+ })expect(result.current.forms).toHaveLength(2)expect(result.current.forms[1]!.inputs).toEqual([@@ -67,11 +107,9 @@ describe('knowledge-retrieval-v2/use-single-run-form-params', () => {}),])- result.current.forms[1]!.onChange({ queryAttachment: ['file-2'] })- expect(setRunInputData).toHaveBeenCalledWith({- query: 'find this diagram',- queryAttachment: ['file-2'],- })+ act(() => result.current.forms[1]!.onChange({ queryAttachment: ['file-2'] }))+ expect(result.current.forms[1]!.values).toEqual({ queryAttachment: ['file-2'] })+ expect(result.current.forms[0]!.values).toEqual({ query: 'find this diagram' })expect(result.current.getDependentVars()).toEqual([['start', 'query'],['start', 'images'],@@ -80,25 +118,14 @@ describe('knowledge-retrieval-v2/use-single-run-form-params', () => {})it('omits the image form when the node has no attachment selector', () => {- const { result } = renderHook(() =>- useSingleRunFormParams({- id: 'retrieval-1',- payload: createData({ query_attachment_selector: [] }),- runInputData: {},- runInputDataRef: { current: {} },- getInputVars: () => [],- setRunInputData: vi.fn(),- toVarInputs: () => [],- }),- )+ const { result } = setup(createData({ query_attachment_selector: [] }))expect(result.current.forms).toHaveLength(1)})it('exposes metadata filter variables as single-run inputs and dependencies', () => {- const setRunInputData = vi.fn()const current = { query: 'policy', '#start.department#': 'sales' }- const getInputVars = vi.fn((texts: string[]) =>+ const getInputVars = (texts: string[]) =>texts.includes('{{#start.department#}}')? [{@@ -108,31 +135,25 @@ describe('knowledge-retrieval-v2/use-single-run-form-params', () => {required: true,},]- : [],- )- const { result } = renderHook(() =>- useSingleRunFormParams({- id: 'retrieval-1',- payload: createData({- query_attachment_selector: [],- metadata_filtering_conditions: {- logical_operator: LogicalOperator.and,- conditions: [- {- id: 'condition-1',- name: 'department',- comparison_operator: ComparisonOperator.is,- value: '{{#start.department#}}',- },- ],- },- }),- runInputData: current,- runInputDataRef: { current },- getInputVars,- setRunInputData,- toVarInputs: () => [],+ : []+ const { result } = setup(+ createData({+ query_attachment_selector: [],+ metadata_filtering_mode: MetadataFilteringModeEnum.manual,+ metadata_filtering_conditions: {+ logical_operator: LogicalOperator.and,+ conditions: [+ {+ id: 'condition-1',+ name: 'department',+ comparison_operator: ComparisonOperator.is,+ value: '{{#start.department#}}',+ },+ ],+ },}),+ current,+ getInputVars,)expect(result.current.forms).toHaveLength(2)@@ -142,11 +163,8 @@ describe('knowledge-retrieval-v2/use-single-run-form-params', () => {expect(result.current.forms[1]!.values).toEqual({ '#start.department#': 'sales' })expect(result.current.getDependentVars()).toContainEqual(['start', 'department'])- result.current.forms[1]!.onChange({ '#start.department#': 'support' })- expect(setRunInputData).toHaveBeenCalledWith({- '#start.department#': 'support',- query: 'policy',- queryAttachment: undefined,- })+ act(() => result.current.forms[1]!.onChange({ '#start.department#': 'support' }))+ expect(result.current.forms[1]!.values).toEqual({ '#start.department#': 'support' })+ expect(result.current.forms[0]!.values).toEqual({ query: 'policy' })})})