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): migrate HITL panel and controls to Browser Mode (#45481)
Stephen Zhou6f0ee4bd1e74
diff --git a/web/app/components/workflow/nodes/__tests__/index.hitl-v2.browser.spec.tsx b/web/app/components/workflow/nodes/__tests__/index.hitl-v2.browser.spec.tsxnew file mode 100644index 00000000000..6ac45a736f4--- /dev/null+++ b/web/app/components/workflow/nodes/__tests__/index.hitl-v2.browser.spec.tsx@@ -0,0 +1,165 @@+import type { HumanInputV2NodeType } from '../human-input-v2/types'+import type { HumanInputNodeType } from '../human-input/types'+import { ORPCError } from '@orpc/client'+import { NuqsTestingAdapter } from 'nuqs/adapters/testing'+import ReactFlow, { useNodes } from 'reactflow'+import { page } from 'vite-plus/test/browser'+import { render } from 'vitest-browser-react'+import { consoleQuery } from '@/service/console'+import { seedAccountProfileQuery } from '@/test/console/account-profile'+import { seedModelProviderQueries } from '@/test/console/model-provider'+import { createConsoleQueryWrapper } from '@/test/console/query-data'+import { seedToolProviders } from '@/test/console/tool-providers'+import { guardUnexpectedFetch } from '@/test/unexpected-fetch'+import { createNode } from '../../__tests__/fixtures'+import {+ createStoresFromOptions,+ createWorkflowWrapper,+} from '../../__tests__/workflow-test-providers'+import { CUSTOM_NODE } from '../../constants'+import DatasetsDetailProvider from '../../datasets-detail-store/provider'+import { BlockEnum } from '../../types'+import { createChannelsQueryClient } from '../human-input-v2/__tests__/channel-fixtures'+import Panel from '../panel'++vi.mock('@/config', async (importOriginal) => ({+ ...(await importOriginal<typeof import('@/config')>()),+ ENABLE_HITL_IM: true,+}))+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, {+ 'workspaces.current.humanInput.v2.contacts.get': async () => ({+ data: [],+ total: 0,+ page: 1,+ limit: 1,+ }),+ 'workspaces.current.humanInput.v2.contactOptions.get': async () => ({+ data: [],+ total: 0,+ page: 1,+ limit: 20,+ }),+ 'snippets.bySnippetId.workflows.draft.nodes.byNodeId.lastRun.get': async () => {+ throw new ORPCError('NOT_FOUND', { status: 404 })+ },+ }),+ }+})++const legacy: HumanInputNodeType = {+ title: 'Approval',+ desc: '',+ type: BlockEnum.HumanInput,+ delivery_methods: [],+ form_content: 'Legacy approval instructions',+ inputs: [],+ user_actions: [],+ timeout: 3,+ timeout_unit: 'day',+}+const migrated: HumanInputV2NodeType = {+ title: 'Approval',+ desc: '',+ type: BlockEnum.HumanInput,+ version: '2',+ recipients_spec: [],+ message_template: { subject: 'Converted approval', body: 'Review {{#url#}}' },+ debug_mode: { enabled: false, channels: [] },+ form_content: 'Converted approval instructions',+ inputs: [],+ user_actions: [],+ timeout: 36,+ timeout_unit: 'hour',+}+function SelectedPanel() {+ const node = useNodes<HumanInputNodeType | HumanInputV2NodeType>().find(+ (node) => node.id === 'approval',+ )+ return node && <Panel id={node.id} type={CUSTOM_NODE} data={node.data} />+}++it('replaces the visible panel configuration on migration and undo without closing the selected node', async () => {+ await page.viewport(1400, 1000)+ onTestFinished(guardUnexpectedFetch())+ const { queryClient } = createConsoleQueryWrapper({+ queryClient: createChannelsQueryClient([]),+ appDslVersion: '0.6.0',+ systemFeatures: { enable_collaboration_mode: false },+ })+ onTestFinished(() => queryClient.clear())+ seedAccountProfileQuery(queryClient)+ seedModelProviderQueries(queryClient)+ queryClient.setQueryData(consoleQuery.workspaces.current.triggers.get.queryKey({ input: {} }), [])+ queryClient.setQueryData(consoleQuery.workspaces.current.agentProviders.get.queryKey(), [])+ seedToolProviders(queryClient, {+ builtInTools: [],+ customTools: [],+ workflowTools: [],+ mcpTools: [],+ })+ queryClient.setQueryData(consoleQuery.spec.schemaDefinitions.get.queryKey(), [])+ const stores = createStoresFromOptions({+ initialStoreState: { workflowCanvasWidth: 1400, nodePanelWidth: 520 },+ })+ const Wrapper = createWorkflowWrapper(stores, undefined, queryClient, {+ kind: 'snippet',+ snippetId: 'approval-test',+ })+ const owner = (data: HumanInputNodeType | HumanInputV2NodeType) => (+ <NuqsTestingAdapter>+ <Wrapper>+ <div style={{ width: 1400, height: 950 }}>+ <ReactFlow nodes={[createNode({ id: 'approval', data })]}>+ <DatasetsDetailProvider nodes={[]}>+ <SelectedPanel />+ </DatasetsDetailProvider>+ </ReactFlow>+ </div>+ </Wrapper>+ </NuqsTestingAdapter>+ )+ const view = await render(owner(legacy))+ const panel = page.getByRole('region', { name: 'Approval workflow.panel.nodePanel' })+ const settings = page.getByRole('tab', { name: 'WORKFLOWDEBUG.DEBUG.SETTINGSTAB' })+ const lastRun = page.getByRole('tab', { name: 'WORKFLOWDEBUG.DEBUG.LASTRUNTAB' })+ await expect.element(panel).toBeVisible()+ await expect+ .element(panel.getByRole('textbox', { name: 'workflow.nodes.humanInput.timeout.title' }))+ .toHaveValue('3')+ await lastRun.click()+ await expect.element(lastRun).toHaveAttribute('aria-selected', 'true')++ // Document replacement is a public prop transition, keeping the owner and selection mounted.+ await view.rerender(owner(migrated))+ await expect.element(settings).toHaveAttribute('aria-selected', 'true')+ await expect+ .element(panel.getByRole('textbox', { name: 'workflow.nodes.humanInput.timeout.title' }))+ .toHaveValue('36')+ await panel.getByRole('button', { name: 'workflow.common.configure' }).click()+ await expect+ .element(page.getByRole('textbox', { name: 'workflow.nodes.humanInputV2.template.subject' }))+ .toHaveValue('Converted approval')+ await page.getByRole('button', { name: 'common.operation.cancel' }).click()+ await expect+ .element(page.getByRole('textbox', { name: 'workflow.nodes.humanInputV2.template.subject' }))+ .not.toBeInTheDocument()+ await lastRun.click()+ await expect.element(lastRun).toHaveAttribute('aria-selected', 'true')++ await view.rerender(owner(legacy))+ await expect.element(settings).toHaveAttribute('aria-selected', 'true')+ await expect+ .element(panel.getByRole('textbox', { name: 'workflow.nodes.humanInput.timeout.title' }))+ .toHaveValue('3')+ await expect+ .element(panel.getByRole('button', { name: 'workflow.common.configure' }))+ .not.toBeInTheDocument()+ await expect+ .element(panel.getByText('workflow.nodes.humanInputMigration.oldVersion'))+ .toBeVisible()+})diff --git a/web/app/components/workflow/nodes/__tests__/index.hitl-v2.spec.tsx b/web/app/components/workflow/nodes/__tests__/index.hitl-v2.spec.tsxdeleted file mode 100644index fc3cabd5f7d..00000000000--- a/web/app/components/workflow/nodes/__tests__/index.hitl-v2.spec.tsx+++ /dev/null@@ -1,91 +0,0 @@-import type { ReactElement } from 'react'-import type { Node as WorkflowNode } from '../../types'-import { render, screen } from '@testing-library/react'-import { CUSTOM_NODE } from '../../constants'-import { BlockEnum } from '../../types'-import Panel from '../panel'--vi.mock('../components', () => ({- NodeComponentMap: {- [BlockEnum.Start]: () => <div>start-node-component</div>,- [BlockEnum.StartPlaceholder]: () => <div>start-placeholder-node-component</div>,- },-}))--vi.mock('../panel-components', () => ({- PanelComponentMap: {- [BlockEnum.Start]: () => <div>start-panel-component</div>,- [BlockEnum.StartPlaceholder]: () => <div>start-placeholder-panel-component</div>,- [BlockEnum.HumanInput]: () => <div>human-input-panel-component</div>,- },-}))--vi.mock('../_base/node', () => ({- __esModule: true,- default: ({- id,- data,- children,- }: {- id: string- data: { type: BlockEnum }- children: ReactElement- }) => (- <div>- <div>{`base-node:${id}:${data.type}`}</div>- {children}- </div>- ),-}))--vi.mock('../_base/components/workflow-panel', async () => {- const React = await vi.importActual<typeof import('react')>('react')-- const MockWorkflowPanel = ({- id,- data,- children,- }: {- id: string- data: { type: BlockEnum; version?: string }- children: ReactElement- }) => {- const [initialType] = React.useState(data.type)- const [initialVersion] = React.useState(data.version ?? '1')-- return (- <div>- <div>{`base-panel:${id}:${data.type}`}</div>- <div>{`base-panel-initial:${initialType}`}</div>- <div>{`base-panel-initial-version:${initialVersion}`}</div>- {children}- </div>- )- }-- return {- __esModule: true,- default: MockWorkflowPanel,- }-})--const createNodeData = (): WorkflowNode['data'] => ({- title: 'Start',- desc: '',- type: BlockEnum.Start,-})--describe('workflow nodes index', () => {- it('remounts the open panel when HITL migration or undo changes only the version', () => {- const legacy = { ...createNodeData(), type: BlockEnum.HumanInput }- const migrated = { ...legacy, version: '2' }- const { rerender } = render(<Panel type={CUSTOM_NODE} id="hitl" data={legacy} />)- expect(screen.getByText('base-panel-initial-version:1')).toBeInTheDocument()-- rerender(<Panel type={CUSTOM_NODE} id="hitl" data={migrated} />)- expect(screen.getByText('base-panel-initial-version:2')).toBeInTheDocument()-- rerender(<Panel type={CUSTOM_NODE} id="hitl" data={legacy} />)- expect(screen.getByText('base-panel-initial-version:1')).toBeInTheDocument()- })-})diff --git a/web/app/components/workflow/nodes/human-input-v2/__tests__/debug-mode.browser.spec.tsx b/web/app/components/workflow/nodes/human-input-v2/__tests__/debug-mode.browser.spec.tsxnew file mode 100644index 00000000000..bccc16c233f--- /dev/null+++ b/web/app/components/workflow/nodes/human-input-v2/__tests__/debug-mode.browser.spec.tsx@@ -0,0 +1,224 @@+import type { ChannelSummary } from '@dify/contracts/api/console/workspaces/types.gen'+import type { HumanInputV2DebugMode } from '../types'+import { QueryClient, QueryClientProvider } from '@tanstack/react-query'+import { useState } from 'react'+import { page, userEvent } from 'vite-plus/test/browser'+import { render } from 'vitest-browser-react'+import { consoleQuery } from '@/service/console'+import { guardUnexpectedFetch } from '@/test/unexpected-fetch'+import DebugMode from '../components/debug-mode'+import { createChannelsQueryClient } from './channel-fixtures'++const api = vi.hoisted(() => ({ channels: vi.fn() }))+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, {+ 'workspaces.current.humanInput.v2.channels.get': api.channels,+ }),+ }+})++vi.mock('react-i18next', async () => {+ const { createReactI18nextMock } = await import('@/test/i18n-mock')+ return createReactI18nextMock({+ 'workflow.nodes.humanInputV2.debug.channel.email': 'Email',+ 'workflow.nodes.humanInputV2.debug.channel.slack': 'Slack',+ 'workflow.nodes.humanInputV2.debug.channel.lark': 'Lark',+ 'workflow.nodes.humanInputV2.debug.channel.feishu': 'Feishu',+ })+})++function DebugOwner({+ initial = { enabled: false, channels: [] },+ readonly = false,+ email,+}: {+ initial?: HumanInputV2DebugMode+ readonly?: boolean+ email?: string+}) {+ const [value, setValue] = useState(initial)+ return (+ <>+ <DebugMode value={value} onChange={setValue} readonly={readonly} email={email} />+ <output aria-label="Debug settings">{JSON.stringify(value)}</output>+ </>+ )+}+async function renderOwner(+ props: Parameters<typeof DebugOwner>[0] = {},+ providers?: ChannelSummary['provider'][],+ suppliedClient?: QueryClient,+) {+ const queryClient = suppliedClient ?? createChannelsQueryClient(providers)+ onTestFinished(() => queryClient.clear())+ return render(+ <QueryClientProvider client={queryClient}>+ <DebugOwner {...props} />+ </QueryClientProvider>,+ )+}+const label = (channel: string) =>+ ({ email: 'Email', slack: 'Slack', lark: 'Lark', feishu: 'Feishu' })[channel] ?? channel+const channel = (name: string) => page.getByRole('checkbox', { name: label(name) })+const configure = () =>+ page.getByRole('button', { name: 'workflow.nodes.humanInputV2.debug.configure' })+const toggle = () => page.getByRole('switch', { name: 'workflow.nodes.humanInputV2.debug.toggle' })+const settings = () => page.getByRole('status', { name: 'Debug settings' })++beforeEach(async () => {+ await page.viewport(1100, 700)+ onTestFinished(guardUnexpectedFetch())+ api.channels.mockReset()+})++it('only offers channels configured in the current workspace', async () => {+ await renderOwner()+ await configure().click()+ await expect.element(channel('email')).toBeVisible()+ await expect.element(channel('slack')).toBeVisible()+ await expect.element(channel('feishu')).not.toBeInTheDocument()+ expect(page.getByRole('checkbox').all()).toHaveLength(2)+})++it('explains the final channel guard and keeps its selection after pointer and keyboard activation', async () => {+ await renderOwner({+ initial: { enabled: true, channels: ['email'] },+ email: '[email protected]',+ })+ await configure().click()+ await expect.element(page.getByText('[email protected]')).toBeVisible()+ await expect.element(channel('email')).toBeChecked()+ await expect.element(channel('email')).toHaveAttribute('aria-disabled', 'true')+ await expect+ .element(channel('email'))+ .toHaveAccessibleDescription('workflow.nodes.humanInputV2.debug.keepOneChannel')+ // Its label is clickable and the checkbox intentionally remains focusable to explain the guard.+ await page.getByRole('dialog').getByText(label('email'), { exact: true }).click()+ await expect.element(channel('email')).toBeChecked()+ await expect.element(channel('email')).toHaveFocus()+ await userEvent.keyboard(' ')+ await expect.element(channel('email')).toBeChecked()+ await expect.element(settings()).toHaveTextContent('{"enabled":true,"channels":["email"]}')+ await channel('slack').click()+ await expect.element(channel('slack')).toBeChecked()+ await expect+ .element(settings())+ .toHaveTextContent('{"enabled":true,"channels":["email","slack"]}')+})++it('protects the last configured selection when imported data retains an unconfigured channel', async () => {+ await renderOwner({ initial: { enabled: true, channels: ['email', 'feishu'] } })+ await configure().click()+ await expect.element(channel('email')).toHaveAttribute('aria-disabled', 'true')+ await expect.element(channel('feishu')).not.toBeInTheDocument()+ await expect.element(configure()).toHaveAccessibleDescription(label('email'))+ await page.getByRole('dialog').getByText(label('email'), { exact: true }).click()+ await expect.element(channel('email')).toBeChecked()+ await expect+ .element(settings())+ .toHaveTextContent('{"enabled":true,"channels":["email","feishu"]}')+})++it('keeps empty workspace configuration unavailable without changing the node', async () => {+ await renderOwner({}, [])+ await configure().click()+ await expect.element(page.getByRole('checkbox')).not.toBeInTheDocument()+ await expect+ .element(page.getByText('workflow.nodes.humanInputV2.template.notConfigured'))+ .toBeVisible()+ await expect.element(toggle()).toHaveAttribute('aria-disabled', 'true')+ await expect.element(settings()).toHaveTextContent('{"enabled":false,"channels":[]}')+})++it('does not fall back to all channels after a load failure and can retry', async () => {+ const seeded = createChannelsQueryClient()+ const response = seeded.getQueryData(+ consoleQuery.workspaces.current.humanInput.v2.channels.get.queryKey(),+ )+ seeded.clear()+ api.channels.mockRejectedValueOnce(new Error('Service unavailable')).mockResolvedValue(response)+ await renderOwner(+ {},+ undefined,+ new QueryClient({ defaultOptions: { queries: { retry: false } } }),+ )+ await configure().click()+ const error = page.getByRole('alert')+ await expect.element(error).toBeVisible()+ expect(error.element().textContent).toContain('contacts.imPlatform.loadError.title')+ await expect.element(page.getByRole('checkbox')).not.toBeInTheDocument()+ await page.getByRole('button', { name: 'common.operation.retry' }).click()+ await expect.element(channel('slack')).toBeVisible()+ expect(page.getByRole('checkbox').all()).toHaveLength(2)+})++it('keeps selected channels when enabling debug mode through the real controls', async () => {+ await renderOwner()+ await configure().click()+ await expect.element(channel('email')).not.toBeChecked()+ await expect.element(channel('slack')).not.toBeChecked()+ await channel('slack').click()+ await expect.element(channel('slack')).toBeChecked()+ await expect.element(settings()).toHaveTextContent('{"enabled":false,"channels":["slack"]}')+ await userEvent.keyboard('{Escape}')+ await expect.element(page.getByRole('checkbox')).not.toBeInTheDocument()+ await toggle().click()+ await expect.element(toggle()).toBeChecked()+ await expect.element(settings()).toHaveTextContent('{"enabled":true,"channels":["slack"]}')+})++it('shows missing-channel and imported compatibility errors', async () => {+ const queryClient = createChannelsQueryClient()+ onTestFinished(() => queryClient.clear())+ const wrap = (value: HumanInputV2DebugMode) => (+ <QueryClientProvider client={queryClient}>+ <DebugMode value={value} onChange={vi.fn()} readonly={false} />+ </QueryClientProvider>+ )+ const view = await render(wrap({ enabled: true, channels: [] }))+ await expect+ .element(page.getByRole('alert'))+ .toHaveTextContent('workflow.nodes.humanInputV2.error.debugChannelRequired')+ // Imported DSL can contain channel identifiers from a different server version.+ await view.rerender(+ wrap({ enabled: false, channels: ['email', 'legacy_channel'] } as HumanInputV2DebugMode),+ )+ await expect+ .element(page.getByRole('alert'))+ .toHaveTextContent(+ 'workflow.nodes.humanInputV2.debug.unsupported:{"channels":"legacy_channel"}',+ )+})++it('keeps stored channels and configuration unavailable in read-only mode', async () => {+ await renderOwner({ initial: { enabled: false, channels: ['email', 'slack'] }, readonly: true })+ await expect+ .element(configure())+ .toHaveAccessibleDescription(`${label('email')}, ${label('slack')}`)+ await expect.element(configure()).toBeDisabled()+ await expect.element(toggle()).toHaveAttribute('aria-disabled', 'true')+ await expect+ .element(settings())+ .toHaveTextContent('{"enabled":false,"channels":["email","slack"]}')+})++it('toggles an imported Lark selection without losing Email', async () => {+ await renderOwner({ initial: { enabled: true, channels: ['lark', 'email'] } }, ['resend', 'lark'])+ await expect.element(page.getByRole('alert')).not.toBeInTheDocument()+ await expect+ .element(configure())+ .toHaveAccessibleDescription(`${label('lark')}, ${label('email')}`)+ await configure().click()+ await expect.element(channel('lark')).toBeChecked()+ await channel('lark').click()+ await expect.element(channel('lark')).not.toBeChecked()+ await expect.element(channel('email')).toBeChecked()+ await expect.element(configure()).toHaveAccessibleDescription(label('email'))+ await channel('lark').click()+ await expect.element(channel('lark')).toBeChecked()+ await expect.element(settings()).toHaveTextContent('{"enabled":true,"channels":["email","lark"]}')+})diff --git a/web/app/components/workflow/nodes/human-input-v2/__tests__/debug-mode.spec.tsx b/web/app/components/workflow/nodes/human-input-v2/__tests__/debug-mode.spec.tsxdeleted file mode 100644index 1b9c64eb777..00000000000--- a/web/app/components/workflow/nodes/human-input-v2/__tests__/debug-mode.spec.tsx+++ /dev/null@@ -1,245 +0,0 @@-import type { ChannelSummary } from '@dify/contracts/api/console/workspaces/types.gen'-import type { ReactNode } from 'react'-import type { HumanInputV2DebugMode } from '../types'-import { QueryClient, QueryClientProvider } from '@tanstack/react-query'-import { render as renderUI, screen } from '@testing-library/react'-import userEvent from '@testing-library/user-event'-import { consoleQuery } from '@/service/console'-import DebugMode from '../components/debug-mode'-import { createChannelsQueryClient } from './channel-fixtures'--const channelLabel = (channel: string) => `workflow.nodes.humanInputV2.debug.channel.${channel}`-const render = (- ui: ReactNode,- providers?: ChannelSummary['provider'][],- queryClient = createChannelsQueryClient(providers),-) => {- return renderUI(ui, {- wrapper: ({ children }) => (- <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>- ),- })-}--describe('Human Input v2 Debug Mode', () => {- afterEach(() => {- vi.restoreAllMocks()- })-- it('only offers channels configured in the current workspace', async () => {- const user = userEvent.setup()- render(- <DebugMode value={{ enabled: false, channels: [] }} onChange={vi.fn()} readonly={false} />,- )- await user.click(- screen.getByRole('button', { name: 'workflow.nodes.humanInputV2.debug.configure' }),- )-- expect(screen.getByRole('checkbox', { name: channelLabel('email') })).toBeInTheDocument()- expect(screen.getByRole('checkbox', { name: channelLabel('slack') })).toBeInTheDocument()- expect(screen.queryByRole('checkbox', { name: channelLabel('feishu') })).not.toBeInTheDocument()- expect(screen.getAllByRole('checkbox')).toHaveLength(2)- })-- it('shows the real email and prevents clearing the final selected channel with a keyboard-reachable explanation', async () => {- const user = userEvent.setup()- const onChange = vi.fn()- render(- <DebugMode- value={{ enabled: true, channels: ['email'] }}- onChange={onChange}- readonly={false}- email="[email protected]"- />,- )- await user.click(- screen.getByRole('button', { name: 'workflow.nodes.humanInputV2.debug.configure' }),- )- const checkbox = screen.getByRole('checkbox', { name: channelLabel('email') })- expect(checkbox).toBeChecked()- expect(checkbox).toHaveAttribute('aria-disabled', 'true')- expect(screen.getByText('[email protected]')).toBeInTheDocument()- await user.click(screen.getByRole('checkbox', { name: channelLabel('email') }))- expect(onChange).not.toHaveBeenCalled()- expect(checkbox).toHaveAccessibleDescription('workflow.nodes.humanInputV2.debug.keepOneChannel')- expect(checkbox).not.toBeDisabled()- await user.click(checkbox)- await user.keyboard(' ')- expect(onChange).not.toHaveBeenCalled()- await user.click(screen.getByRole('checkbox', { name: channelLabel('slack') }))- expect(onChange).toHaveBeenLastCalledWith({ enabled: true, channels: ['email', 'slack'] })- })-- it('protects the last configured selection even when the imported node retains an unconfigured channel', async () => {- const user = userEvent.setup()- const onChange = vi.fn()- render(- <DebugMode- value={{ enabled: true, channels: ['email', 'feishu'] }}- onChange={onChange}- readonly={false}- />,- )- await user.click(- screen.getByRole('button', { name: 'workflow.nodes.humanInputV2.debug.configure' }),- )- expect(screen.getByRole('checkbox', { name: channelLabel('email') })).toHaveAttribute(- 'aria-disabled',- 'true',- )- expect(screen.queryByRole('checkbox', { name: channelLabel('feishu') })).not.toBeInTheDocument()- expect(- screen.getByRole('button', { name: 'workflow.nodes.humanInputV2.debug.configure' }),- ).toHaveAccessibleDescription(channelLabel('email'))- await user.click(screen.getByRole('checkbox', { name: channelLabel('email') }))- expect(onChange).not.toHaveBeenCalled()- })-- it('shows no selectable channels when none are configured and does not change the node', async () => {- const user = userEvent.setup()- const onChange = vi.fn()- render(- <DebugMode value={{ enabled: false, channels: [] }} onChange={onChange} readonly={false} />,- [],- )- await user.click(- screen.getByRole('button', { name: 'workflow.nodes.humanInputV2.debug.configure' }),- )- expect(screen.queryByRole('checkbox')).not.toBeInTheDocument()- expect(screen.getByRole('status')).toHaveTextContent(- 'workflow.nodes.humanInputV2.template.notConfigured',- )- expect(screen.getByRole('switch')).toHaveAttribute('aria-disabled', 'true')- expect(onChange).not.toHaveBeenCalled()- })-- it('does not fall back to all channels after a load failure and can retry', async () => {- const user = userEvent.setup()- const queryKey =- consoleQuery.workspaces.current.humanInput.v2.channels.get.queryOptions().queryKey- const response = createChannelsQueryClient().getQueryData(queryKey)- vi.spyOn(globalThis, 'fetch')- .mockResolvedValueOnce(- new Response('{}', { status: 503, headers: { 'Content-Type': 'application/json' } }),- )- .mockResolvedValueOnce(- new Response(JSON.stringify(response), { headers: { 'Content-Type': 'application/json' } }),- )- render(- <DebugMode value={{ enabled: false, channels: [] }} onChange={vi.fn()} readonly={false} />,- undefined,- new QueryClient({ defaultOptions: { queries: { retry: false } } }),- )- await user.click(- screen.getByRole('button', { name: 'workflow.nodes.humanInputV2.debug.configure' }),- )- expect(await screen.findByRole('alert')).toHaveTextContent(- 'contacts.imPlatform.loadError.title',- )- expect(screen.queryByRole('checkbox')).not.toBeInTheDocument()- await user.click(screen.getByRole('button', { name: 'common.operation.retry' }))- expect(await screen.findByRole('checkbox', { name: channelLabel('slack') })).toBeInTheDocument()- expect(screen.getAllByRole('checkbox')).toHaveLength(2)- })- it('edits supported channel values and only emits DSL changes', async () => {- const user = userEvent.setup()- const onChange = vi.fn()- const value: HumanInputV2DebugMode = { enabled: false, channels: [] }- render(<DebugMode value={value} onChange={onChange} readonly={false} />)-- await user.click(- screen.getByRole('button', { name: 'workflow.nodes.humanInputV2.debug.configure' }),- )- for (const channel of ['email', 'slack']) {- expect(screen.getByRole('checkbox', { name: channelLabel(channel) })).not.toBeChecked()- }-- await user.click(screen.getByText(channelLabel('slack')))- expect(onChange).toHaveBeenCalledWith({ enabled: false, channels: ['slack'] })-- await user.click(- screen.getByRole('switch', { name: 'workflow.nodes.humanInputV2.debug.toggle' }),- )- expect(onChange).toHaveBeenLastCalledWith({ enabled: true, channels: [] })- })-- it('shows enabled-without-channel and imported compatibility errors', () => {- const { rerender } = render(- <DebugMode value={{ enabled: true, channels: [] }} onChange={vi.fn()} readonly={false} />,- )-- expect(screen.getByRole('alert')).toHaveTextContent(- 'workflow.nodes.humanInputV2.error.debugChannelRequired',- )-- rerender(- <DebugMode- value={{ enabled: false, channels: ['email', 'legacy_channel'] } as HumanInputV2DebugMode}- onChange={vi.fn()}- readonly={false}- />,- )- expect(screen.getByRole('alert')).toHaveTextContent(- 'workflow.nodes.humanInputV2.debug.unsupported',- )- expect(screen.getByRole('alert')).toHaveTextContent('legacy_channel')- })-- it('is non-mutating in read-only mode and preserves selected channels while disabled', async () => {- const user = userEvent.setup()- const onChange = vi.fn()- render(- <DebugMode- value={{ enabled: false, channels: ['email', 'slack'] }}- onChange={onChange}- readonly- />,- )-- expect(- screen.getByRole('button', { name: 'workflow.nodes.humanInputV2.debug.configure' }),- ).toHaveAccessibleDescription(`${channelLabel('email')}, ${channelLabel('slack')}`)- expect(- screen.getByRole('button', { name: 'workflow.nodes.humanInputV2.debug.configure' }),- ).toBeDisabled()- await user.click(- screen.getByRole('switch', { name: 'workflow.nodes.humanInputV2.debug.toggle' }),- )- expect(onChange).not.toHaveBeenCalled()- })-- it('accepts an imported Lark selection and lets the user toggle it without losing Email', async () => {- const user = userEvent.setup()- const onChange = vi.fn()- const { rerender } = render(- <DebugMode- value={{ enabled: true, channels: ['lark', 'email'] }}- onChange={onChange}- readonly={false}- />,- ['resend', 'lark'],- )- expect(screen.queryByRole('alert')).not.toBeInTheDocument()- expect(- screen.getByRole('button', { name: 'workflow.nodes.humanInputV2.debug.configure' }),- ).toHaveAccessibleDescription(`${channelLabel('lark')}, ${channelLabel('email')}`)- await user.click(- screen.getByRole('button', { name: 'workflow.nodes.humanInputV2.debug.configure' }),- )- expect(screen.getByRole('checkbox', { name: channelLabel('lark') })).toBeChecked()- await user.click(screen.getByRole('checkbox', { name: channelLabel('lark') }))- expect(onChange).toHaveBeenLastCalledWith({ enabled: true, channels: ['email'] })- rerender(- <DebugMode- value={{ enabled: true, channels: ['email'] }}- onChange={onChange}- readonly={false}- />,- )- expect(- screen.getByRole('button', { name: 'workflow.nodes.humanInputV2.debug.configure' }),- ).toHaveAccessibleDescription(channelLabel('email'))- await user.click(screen.getByRole('checkbox', { name: channelLabel('lark') }))- expect(onChange).toHaveBeenLastCalledWith({ enabled: true, channels: ['email', 'lark'] })- })-})diff --git a/web/app/components/workflow/nodes/human-input-v2/__tests__/message-template-body.browser.spec.tsx b/web/app/components/workflow/nodes/human-input-v2/__tests__/message-template-body.browser.spec.tsxnew file mode 100644index 00000000000..e7e4d7d3cff--- /dev/null+++ b/web/app/components/workflow/nodes/human-input-v2/__tests__/message-template-body.browser.spec.tsx@@ -0,0 +1,91 @@+import { detectPlatform } from '@tanstack/react-hotkeys'+import { useState } from 'react'+import { page, userEvent } from 'vite-plus/test/browser'+import { render } from 'vitest-browser-react'+import { guardUnexpectedFetch } from '@/test/unexpected-fetch'+import MessageTemplateBody from '../components/message-template-body'++function BodyOwner({+ initial = 'Please review this request. ',+ readOnly = false,+}: {+ initial?: string+ readOnly?: boolean+}) {+ const [value, setValue] = useState(initial)+ return (+ <>+ <MessageTemplateBody+ nodeId="approval"+ value={value}+ onChange={setValue}+ readOnly={readOnly}+ />+ <output aria-label="Message body value">{value}</output>+ </>+ )+}+const insert = () =>+ page.getByRole('button', { name: 'workflow.nodes.humanInputV2.template.insertRequestURL' })+const inserted = () =>+ page.getByRole('button', { name: 'workflow.nodes.humanInputV2.template.requestURLInserted' })+const editor = () =>+ page.getByRole('textbox', { name: 'workflow.nodes.humanInputV2.template.body' })++beforeEach(async () => {+ onTestFinished(guardUnexpectedFetch())+ await page.viewport(1000, 700)+})++it('inserts one request URL at the end without replacing the unfocused body', async () => {+ await render(<BodyOwner />)+ await insert().dblClick()+ await expect+ .element(page.getByRole('status', { name: 'Message body value' }))+ .toHaveTextContent('Please review this request. {{#url#}}')+ await expect.element(inserted()).toBeDisabled()+ await expect+ .element(editor().getByText('common.promptEditor.requestURL.item.title'))+ .toBeVisible()+})++it('allows insertion again after the URL is removed through the real editor', async () => {+ await render(<BodyOwner initial="Review {{#url#}}" />)+ await expect.element(inserted()).toBeDisabled()+ await editor().click()+ const mod = detectPlatform() === 'mac' ? 'Meta' : 'Control'+ await userEvent.keyboard(`{${mod}>}a{/${mod}}`)+ await userEvent.keyboard('{Backspace}')+ await expect.element(insert()).toBeEnabled()+ await expect+ .element(editor().getByText('common.promptEditor.requestURL.item.title'))+ .not.toBeInTheDocument()+ await expect+ .element(page.getByRole('status', { name: 'Message body value' }))+ .toBeEmptyDOMElement()+})++it('keeps a read-only body unchanged and insertion unavailable', async () => {+ await render(<BodyOwner readOnly />)+ await expect.element(insert()).toBeDisabled()+ await expect.element(editor()).toHaveAttribute('contenteditable', 'false')+ await expect+ .element(page.getByRole('status', { name: 'Message body value' }))+ .toHaveTextContent('Please review this request.')+})++it('connects validation and guidance to the actual Lexical textbox', async () => {+ await render(+ <MessageTemplateBody+ nodeId="approval"+ value="Review"+ onChange={vi.fn()}+ error="A request URL is required"+ />,+ )+ await expect.element(editor()).toHaveAttribute('aria-invalid', 'true')+ await expect.element(editor()).toHaveAccessibleDescription(/A request URL is required/)+ await expect+ .element(editor())+ .toHaveAccessibleDescription(/workflow.nodes.humanInputV2.template.requestURLHint/)+})diff --git a/web/app/components/workflow/nodes/human-input-v2/__tests__/message-template-body.spec.tsx b/web/app/components/workflow/nodes/human-input-v2/__tests__/message-template-body.spec.tsxdeleted file mode 100644index 026ef35ab37..00000000000--- a/web/app/components/workflow/nodes/human-input-v2/__tests__/message-template-body.spec.tsx+++ /dev/null@@ -1,90 +0,0 @@-import { render, screen, waitFor } from '@testing-library/react'-import userEvent from '@testing-library/user-event'-import { useState } from 'react'-import MessageTemplateBody from '../components/message-template-body'--const BodyEditor = ({ readOnly = false }: { readOnly?: boolean }) => {- const [value, setValue] = useState('Please review this request. ')- return (- <>- <MessageTemplateBody- nodeId="approval"- value={value}- onChange={setValue}- readOnly={readOnly}- />- <output aria-label="Message body value">{value}</output>- </>- )-}--describe('Human Input V2 message body editor', () => {- it('inserts one request URL at the end without replacing the existing body before the editor is focused', async () => {- const user = userEvent.setup()- render(<BodyEditor />)-- await user.dblClick(- screen.getByRole('button', { name: 'workflow.nodes.humanInputV2.template.insertRequestURL' }),- )-- await waitFor(() =>- expect(screen.getByLabelText('Message body value')).toHaveTextContent(- 'Please review this request. {{#url#}}',- ),- )- expect(- screen.getByRole('button', {- name: 'workflow.nodes.humanInputV2.template.requestURLInserted',- }),- ).toBeDisabled()- expect(screen.getByText('common.promptEditor.requestURL.item.title')).toBeInTheDocument()- })-- it('updates insertion availability when an existing URL is removed from the body', async () => {- const onChange = vi.fn()- const { rerender } = render(- <MessageTemplateBody nodeId="approval" value="Review {{#url#}}" onChange={onChange} />,- )- expect(- screen.getByRole('button', {- name: 'workflow.nodes.humanInputV2.template.requestURLInserted',- }),- ).toBeDisabled()-- rerender(<MessageTemplateBody nodeId="approval" value="Review" onChange={onChange} />)- expect(- screen.getByRole('button', { name: 'workflow.nodes.humanInputV2.template.insertRequestURL' }),- ).toBeEnabled()- expect(screen.queryByText('common.promptEditor.requestURL.item.title')).not.toBeInTheDocument()- })-- it('keeps a read-only body unchanged and prevents insertion', () => {- render(<BodyEditor readOnly />)- expect(- screen.getByRole('button', { name: 'workflow.nodes.humanInputV2.template.insertRequestURL' }),- ).toBeDisabled()- expect(screen.getByLabelText('Message body value')).toHaveTextContent(- 'Please review this request.',- )- expect(- screen.getByRole('textbox', { name: 'workflow.nodes.humanInputV2.template.body' }),- ).toHaveAttribute('contenteditable', 'false')- })-})--it('connects validation and guidance to the actual Lexical textbox', () => {- render(- <MessageTemplateBody- nodeId="approval"- value="Review"- onChange={vi.fn()}- error="A request URL is required"- />,- )- const editor = screen.getByRole('textbox', { name: 'workflow.nodes.humanInputV2.template.body' })- expect(editor).toHaveAttribute('aria-invalid', 'true')- expect(editor).toHaveAccessibleDescription(expect.stringContaining('A request URL is required'))- expect(editor).toHaveAccessibleDescription(- expect.stringContaining('workflow.nodes.humanInputV2.template.requestURLHint'),- )-})diff --git a/web/app/components/workflow/nodes/human-input-v2/__tests__/recipient-contact-preview.browser.spec.tsx b/web/app/components/workflow/nodes/human-input-v2/__tests__/recipient-contact-preview.browser.spec.tsxnew file mode 100644index 00000000000..e0d60f43b8a--- /dev/null+++ b/web/app/components/workflow/nodes/human-input-v2/__tests__/recipient-contact-preview.browser.spec.tsx@@ -0,0 +1,140 @@+import type { ContactOption } from '@dify/contracts/api/console/workspaces/types.gen'+import { useRef, useState } from 'react'+import { page, userEvent } from 'vite-plus/test/browser'+import { render } from 'vitest-browser-react'+import { guardUnexpectedFetch } from '@/test/unexpected-fetch'+import { RecipientContactPreview } from '../components/recipient-contact-preview'+import { contact, organizationContact } from './fixtures/contact-api'++function Harness({ target }: { target?: ContactOption }) {+ const inputRef = useRef<HTMLInputElement>(null)+ return (+ <>+ <input ref={inputRef} aria-label="Recipients" />+ <RecipientContactPreview contact={target} returnFocus={inputRef}>+ <button type="button" disabled={!target}>+ Contact details+ </button>+ </RecipientContactPreview>+ </>+ )+}++beforeEach(async () => {+ onTestFinished(guardUnexpectedFetch())+ await page.viewport(1000, 700)+})++describe('recipient contact preview', () => {+ it('shows each bound IM provider once alongside Email with an accessible channel name', async () => {+ await render(+ <Harness+ target={{+ ...contact,+ im_providers: ['feishu', 'lark', 'slack', 'ding_talk', 'ms_teams', 'we_com', 'feishu'],+ }}+ />,+ )+ await page.getByRole('button', { name: 'Contact details' }).click()+ const dialog = page.getByRole('dialog', { name: contact.name })+ const channels = dialog.getByRole('group', { name: 'contacts.details.channels' })+ for (const name of [+ 'contacts.directory.channel.email',+ 'Feishu',+ 'Lark',+ 'Slack',+ 'DingTalk',+ 'Microsoft Teams',+ 'WeCom',+ ]) {+ await expect.element(channels.getByRole('img', { name })).toBeVisible()+ }+ expect(channels.getByRole('img').all()).toHaveLength(7)+ })++ it('shows a bound IM channel even when the contact has no email', async () => {+ await render(<Harness target={{ ...contact, email: null, im_providers: ['feishu'] }} />)+ await page.getByRole('button', { name: 'Contact details' }).click()+ const dialog = page.getByRole('dialog', { name: contact.name })+ await expect.element(dialog.getByRole('img', { name: 'Feishu' })).toBeVisible()+ await expect+ .element(dialog.getByRole('img', { name: 'contacts.directory.channel.email' }))+ .not.toBeInTheDocument()+ })++ it('does not imply an IM binding for an email-only contact', async () => {+ await render(<Harness target={contact} />)+ await page.getByRole('button', { name: 'Contact details' }).click()+ const dialog = page.getByRole('dialog', { name: contact.name })+ await expect+ .element(dialog.getByRole('img', { name: 'contacts.directory.channel.email' }))+ .toBeVisible()+ expect(dialog.getByRole('img').all()).toHaveLength(1)+ await expect.element(dialog.getByRole('img', { name: 'Feishu' })).not.toBeInTheDocument()+ })++ it('does not display a channel when no email or IM provider is available', async () => {+ await render(<Harness target={{ ...contact, email: null }} />)+ await page.getByRole('button', { name: 'Contact details' }).click()+ const dialog = page.getByRole('dialog', { name: contact.name })+ await expect+ .element(dialog.getByRole('group', { name: 'contacts.details.channels' }))+ .not.toBeInTheDocument()+ await expect.element(dialog.getByRole('img')).not.toBeInTheDocument()+ })++ it('preserves the details trigger while its current contact becomes available or clears', async () => {+ const { rerender } = await render(<Harness />)+ const trigger = page.getByRole('button', { name: 'Contact details' })+ await expect.element(trigger).toBeDisabled()+ await expect.element(page.getByRole('dialog')).not.toBeInTheDocument()++ await rerender(<Harness target={contact} />)+ await trigger.click()+ await expect.element(page.getByRole('dialog', { name: contact.name })).toBeVisible()++ await rerender(<Harness />)+ await expect.element(trigger).toBeDisabled()+ await expect.element(page.getByRole('dialog')).not.toBeInTheDocument()+ })++ it('returns keyboard focus to the recipient input after closing details', async () => {+ await render(<Harness target={contact} />)+ await userEvent.tab()+ await userEvent.tab()+ await expect.element(page.getByRole('button', { name: 'Contact details' })).toHaveFocus()+ await userEvent.keyboard('{Enter}')+ await expect.element(page.getByRole('dialog', { name: contact.name })).toBeVisible()+ await userEvent.keyboard('{Escape}')+ await expect.element(page.getByRole('dialog')).not.toBeInTheDocument()+ await expect.element(page.getByRole('textbox', { name: 'Recipients' })).toHaveFocus()+ })++ it('keeps existing chip previews able to replace a conflicting contact', async () => {+ function ConflictOwner() {+ const [selected, setSelected] = useState<ContactOption>(contact)+ return (+ <>+ <output aria-label="Selected contact">{selected.name}</output>+ <RecipientContactPreview+ contact={organizationContact}+ conflictingContact={selected}+ onReplace={() => setSelected(organizationContact)}+ >+ <button type="button">Contact details</button>+ </RecipientContactPreview>+ </>+ )+ }+ await render(<ConflictOwner />)+ await page.getByRole('button', { name: 'Contact details' }).click()+ await expect.element(page.getByRole('dialog', { name: organizationContact.name })).toBeVisible()+ await page+ .getByRole('button', { name: 'workflow.nodes.humanInputV2.recipients.useThisInstead' })+ .click()+ await expect+ .element(page.getByRole('status', { name: 'Selected contact' }))+ .toHaveTextContent(organizationContact.name)+ await expect.element(page.getByRole('dialog')).not.toBeInTheDocument()+ })+})diff --git a/web/app/components/workflow/nodes/human-input-v2/__tests__/recipient-contact-preview.spec.tsx b/web/app/components/workflow/nodes/human-input-v2/__tests__/recipient-contact-preview.spec.tsxdeleted file mode 100644index 9ac9f8981f5..00000000000--- a/web/app/components/workflow/nodes/human-input-v2/__tests__/recipient-contact-preview.spec.tsx+++ /dev/null@@ -1,135 +0,0 @@-import type { ContactOption } from '@dify/contracts/api/console/workspaces/types.gen'-import { render, screen, waitFor, within } from '@testing-library/react'-import userEvent from '@testing-library/user-event'-import { useRef } from 'react'-import { RecipientContactPreview } from '../components/recipient-contact-preview'-import { contact, organizationContact } from './fixtures/contact-api'--function Harness({ target }: { target?: ContactOption }) {- const inputRef = useRef<HTMLInputElement>(null)- return (- <>- <input ref={inputRef} aria-label="Recipients" />- <RecipientContactPreview contact={target} returnFocus={inputRef}>- <button type="button" disabled={!target}>- Contact details- </button>- </RecipientContactPreview>- </>- )-}--describe('recipient contact preview', () => {- it('shows each bound IM provider once alongside Email with an accessible channel name', async () => {- const user = userEvent.setup()- render(- <Harness- target={{- ...contact,- im_providers: ['feishu', 'lark', 'slack', 'ding_talk', 'ms_teams', 'we_com', 'feishu'],- }}- />,- )- await user.click(screen.getByRole('button', { name: 'Contact details' }))- const dialog = await screen.findByRole('dialog', { name: contact.name })- const channels = within(dialog).getByRole('group', { name: 'contacts.details.channels' })- for (const name of [- 'contacts.directory.channel.email',- 'Feishu',- 'Lark',- 'Slack',- 'DingTalk',- 'Microsoft Teams',- 'WeCom',- ]) {- expect(within(channels).getByRole('img', { name })).toBeVisible()- }- expect(within(channels).getAllByRole('img')).toHaveLength(7)- })-- it('shows a bound IM channel even when the contact has no email', async () => {- const user = userEvent.setup()- render(<Harness target={{ ...contact, email: null, im_providers: ['feishu'] }} />)- await user.click(screen.getByRole('button', { name: 'Contact details' }))- const dialog = await screen.findByRole('dialog', { name: contact.name })- expect(within(dialog).getByRole('img', { name: 'Feishu' })).toBeVisible()- expect(- within(dialog).queryByRole('img', { name: 'contacts.directory.channel.email' }),- ).not.toBeInTheDocument()- })-- it('does not imply an IM binding for an email-only contact', async () => {- const user = userEvent.setup()- render(<Harness target={contact} />)- await user.click(screen.getByRole('button', { name: 'Contact details' }))- const dialog = await screen.findByRole('dialog', { name: contact.name })- expect(- within(dialog).getByRole('img', { name: 'contacts.directory.channel.email' }),- ).toBeVisible()- expect(within(dialog).getAllByRole('img')).toHaveLength(1)- expect(within(dialog).queryByRole('img', { name: 'Feishu' })).not.toBeInTheDocument()- })-- it('does not display a channel when no email or IM provider is available', async () => {- const user = userEvent.setup()- render(<Harness target={{ ...contact, email: null }} />)- await user.click(screen.getByRole('button', { name: 'Contact details' }))- const dialog = await screen.findByRole('dialog', { name: contact.name })- expect(- within(dialog).queryByRole('group', { name: 'contacts.details.channels' }),- ).not.toBeInTheDocument()- expect(within(dialog).queryByRole('img')).not.toBeInTheDocument()- })-- it('preserves the details trigger while its current contact becomes available or clears', async () => {- const user = userEvent.setup()- const { rerender } = render(<Harness />)- const trigger = screen.getByRole('button', { name: 'Contact details' })- expect(trigger).toBeDisabled()- expect(screen.queryByRole('dialog')).not.toBeInTheDocument()-- rerender(<Harness target={contact} />)- expect(screen.getByRole('button', { name: 'Contact details' })).toBe(trigger)- await user.click(trigger)- expect(await screen.findByRole('dialog', { name: contact.name })).toBeVisible()-- rerender(<Harness />)- expect(screen.getByRole('button', { name: 'Contact details' })).toBe(trigger)- expect(trigger).toBeDisabled()- expect(screen.queryByRole('dialog')).not.toBeInTheDocument()- })-- it('returns keyboard focus to the recipient input after closing details', async () => {- const user = userEvent.setup()- render(<Harness target={contact} />)- await user.tab()- await user.tab()- expect(screen.getByRole('button', { name: 'Contact details' })).toHaveFocus()- await user.keyboard('{Enter}')- expect(await screen.findByRole('dialog', { name: contact.name })).toBeVisible()- await user.keyboard('{Escape}')- await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument())- expect(screen.getByRole('textbox', { name: 'Recipients' })).toHaveFocus()- })-- it('keeps existing chip previews able to replace a conflicting contact', async () => {- const user = userEvent.setup()- const onReplace = vi.fn()- render(- <RecipientContactPreview- contact={organizationContact}- conflictingContact={contact}- onReplace={onReplace}- >- <button type="button">Contact details</button>- </RecipientContactPreview>,- )- await user.click(screen.getByRole('button', { name: 'Contact details' }))- expect(await screen.findByRole('dialog', { name: organizationContact.name })).toBeVisible()- await user.click(- screen.getByRole('button', { name: 'workflow.nodes.humanInputV2.recipients.useThisInstead' }),- )- expect(onReplace).toHaveBeenCalledOnce()- await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument())- })-})diff --git a/web/app/components/workflow/nodes/human-input-v2/migration/__tests__/migration-banner.browser.spec.tsx b/web/app/components/workflow/nodes/human-input-v2/migration/__tests__/migration-banner.browser.spec.tsxnew file mode 100644index 00000000000..16f46453f5a--- /dev/null+++ b/web/app/components/workflow/nodes/human-input-v2/migration/__tests__/migration-banner.browser.spec.tsx@@ -0,0 +1,69 @@+import { useState } from 'react'+import { page } from 'vite-plus/test/browser'+import { render } from 'vitest-browser-react'+import { guardUnexpectedFetch } from '@/test/unexpected-fetch'+import HumanInputMigrationBanner from '../migration-banner'+import HumanInputMigrationDialog from '../migration-dialog'++function BannerOwner({ canEdit = true }: { canEdit?: boolean }) {+ const [open, setOpen] = useState(false)+ return (+ <>+ <HumanInputMigrationBanner+ canEdit={canEdit}+ helpLink="https://docs.example/human-input"+ onMigrate={() => setOpen(true)}+ />+ <HumanInputMigrationDialog+ open={open}+ pending={false}+ nodeCount={1}+ onOpenChange={setOpen}+ onConfirm={() => setOpen(false)}+ />+ </>+ )+}++beforeEach(async () => {+ onTestFinished(guardUnexpectedFetch())+ await page.viewport(1000, 700)+})++it('shows guidance and opens the migration confirmation for editors', async () => {+ await render(<BannerOwner />)+ await expect+ .element(page.getByText('workflow.nodes.humanInputMigration.banner.description'))+ .toBeVisible()+ await expect+ .element(+ page.getByRole('link', { name: /workflow.nodes.humanInputMigration.banner.learnMore/ }),+ )+ .toHaveAttribute('href', 'https://docs.example/human-input')+ await page+ .getByRole('button', { name: 'workflow.nodes.humanInputMigration.action.migrateNow' })+ .click()+ await expect+ .element(+ page.getByRole('alertdialog', {+ name: 'workflow.nodes.humanInputMigration.dialog.title:{"count":1}',+ }),+ )+ .toBeVisible()+})++it('keeps the explanation and documentation without offering read-only migration', async () => {+ await render(<BannerOwner canEdit={false} />)+ await expect+ .element(page.getByText('workflow.nodes.humanInputMigration.banner.description'))+ .toBeVisible()+ await expect+ .element(page.getByRole('link'))+ .toHaveAttribute('href', 'https://docs.example/human-input')+ await expect+ .element(+ page.getByRole('button', { name: 'workflow.nodes.humanInputMigration.action.migrateNow' }),+ )+ .not.toBeInTheDocument()+ await expect.element(page.getByRole('alertdialog')).not.toBeInTheDocument()+})diff --git a/web/app/components/workflow/nodes/human-input-v2/migration/__tests__/migration-banner.spec.tsx b/web/app/components/workflow/nodes/human-input-v2/migration/__tests__/migration-banner.spec.tsxdeleted file mode 100644index 2aee93faaa1..00000000000--- a/web/app/components/workflow/nodes/human-input-v2/migration/__tests__/migration-banner.spec.tsx+++ /dev/null@@ -1,53 +0,0 @@-import { render, screen } from '@testing-library/react'-import userEvent from '@testing-library/user-event'-import { describe, expect, it, vi } from 'vitest'-import HumanInputMigrationBanner from '../migration-banner'--describe('Human Input migration banner', () => {- it('shows guidance, opens documentation, and starts migration for editors', async () => {- const user = userEvent.setup()- const onMigrate = vi.fn()- render(- <HumanInputMigrationBanner- canEdit- helpLink="https://docs.example/human-input"- onMigrate={onMigrate}- />,- )-- expect(screen.queryByRole('complementary')).not.toBeInTheDocument()- expect(- screen.getByText('workflow.nodes.humanInputMigration.banner.description'),- ).toBeInTheDocument()- expect(- screen.getByRole('link', {- name: /workflow.nodes.humanInputMigration.banner.learnMore/,- }),- ).toHaveAttribute('href', 'https://docs.example/human-input')-- await user.click(- screen.getByRole('button', { name: 'workflow.nodes.humanInputMigration.action.migrateNow' }),- )- expect(onMigrate).toHaveBeenCalledTimes(1)- })-- it('keeps the explanation and documentation but hides migration for read-only users', () => {- render(- <HumanInputMigrationBanner- canEdit={false}- helpLink="https://docs.example/human-input"- onMigrate={vi.fn()}- />,- )-- expect(- screen.getByText('workflow.nodes.humanInputMigration.banner.description'),- ).toBeInTheDocument()- expect(screen.getByRole('link')).toBeInTheDocument()- expect(- screen.queryByRole('button', {- name: 'workflow.nodes.humanInputMigration.action.migrateNow',- }),- ).not.toBeInTheDocument()- })-})diff --git a/web/app/components/workflow/nodes/human-input-v2/migration/__tests__/migration-dialog.browser.spec.tsx b/web/app/components/workflow/nodes/human-input-v2/migration/__tests__/migration-dialog.browser.spec.tsxnew file mode 100644index 00000000000..294a49d11ae--- /dev/null+++ b/web/app/components/workflow/nodes/human-input-v2/migration/__tests__/migration-dialog.browser.spec.tsx@@ -0,0 +1,93 @@+import { useState } from 'react'+import { page, userEvent } from 'vite-plus/test/browser'+import { render } from 'vitest-browser-react'+import { guardUnexpectedFetch } from '@/test/unexpected-fetch'+import HumanInputMigrationDialog from '../migration-dialog'++function DialogOwner() {+ const [open, setOpen] = useState(false)+ const [pending, setPending] = useState(false)+ const [requests, setRequests] = useState(0)+ return (+ <>+ <button type="button" onClick={() => setOpen(true)}>+ Open migration+ </button>+ <a href="#outside">Outside</a>+ <output aria-label="Migration requests">{requests}</output>+ <HumanInputMigrationDialog+ open={open}+ pending={pending}+ nodeCount={3}+ onOpenChange={setOpen}+ onConfirm={() => {+ setRequests((n) => n + 1)+ setPending(true)+ }}+ />+ </>+ )+}+const trigger = () => page.getByRole('button', { name: 'Open migration' })+const dialog = () => page.getByRole('alertdialog')+const cancel = () => page.getByRole('button', { name: 'common.operation.cancel' })+const confirm = () =>+ page.getByRole('button', { name: 'workflow.nodes.humanInputMigration.action.migrate' })++beforeEach(async () => {+ onTestFinished(guardUnexpectedFetch())+ await page.viewport(1000, 700)+})++it('presents the migration copy and returns to its caller after Cancel', async () => {+ await render(<DialogOwner />)+ await trigger().click()+ await expect+ .element(+ page.getByRole('alertdialog', {+ name: 'workflow.nodes.humanInputMigration.dialog.title:{"count":3}',+ }),+ )+ .toBeVisible()+ await expect+ .element(dialog())+ .toHaveAccessibleDescription(+ /workflow.nodes.humanInputMigration.dialog.description.*workflow.nodes.humanInputMigration.dialog.review.*workflow.nodes.humanInputMigration.dialog.draftNotice/,+ )+ await cancel().click()+ await expect.element(dialog()).not.toBeInTheDocument()+ await expect.element(trigger()).toHaveFocus()+})++it('keeps the pending confirmation open and accepts only one request', async () => {+ await render(<DialogOwner />)+ await trigger().click()+ await confirm().click()+ await expect.element(confirm()).toHaveAttribute('aria-disabled', 'true')+ await expect.element(cancel()).toHaveAttribute('aria-disabled', 'true')+ // The pending actions remain keyboard reachable; activation must not dismiss or resubmit.+ await expect.element(confirm()).toHaveFocus()+ await userEvent.keyboard('{Enter}')+ await userEvent.tab({ shift: true })+ await expect.element(cancel()).toHaveFocus()+ await userEvent.keyboard('{Enter}')+ await userEvent.keyboard('{Escape}')+ await expect.element(dialog()).toBeVisible()+ await expect.element(page.getByLabelText('Migration requests')).toHaveTextContent('1')+})++it('presents the recoverable error within the migration confirmation', async () => {+ await render(+ <HumanInputMigrationDialog+ open+ pending={false}+ nodeCount={1}+ error="Approval could not be migrated"+ onOpenChange={vi.fn()}+ onConfirm={vi.fn()}+ />,+ )+ await expect+ .element(dialog().getByRole('alert'))+ .toHaveTextContent('Approval could not be migrated')+})diff --git a/web/app/components/workflow/nodes/human-input-v2/migration/__tests__/migration-dialog.spec.tsx b/web/app/components/workflow/nodes/human-input-v2/migration/__tests__/migration-dialog.spec.tsxdeleted file mode 100644index 5bbd458580d..00000000000--- a/web/app/components/workflow/nodes/human-input-v2/migration/__tests__/migration-dialog.spec.tsx+++ /dev/null@@ -1,103 +0,0 @@-import { render, screen, waitFor } from '@testing-library/react'-import userEvent from '@testing-library/user-event'-import { useState } from 'react'-import { describe, expect, it, vi } from 'vitest'-import HumanInputMigrationDialog from '../migration-dialog'--const DialogHarness = ({ onConfirm = vi.fn() }: { onConfirm?: () => void }) => {- const [open, setOpen] = useState(false)- const [pending, setPending] = useState(false)- return (- <>- <button type="button" onClick={() => setOpen(true)}>- open migration- </button>- <a href="#outside">outside</a>- <HumanInputMigrationDialog- open={open}- pending={pending}- nodeCount={3}- onOpenChange={setOpen}- onConfirm={() => {- onConfirm()- setPending(true)- }}- />- </>- )-}--describe('Human Input migration dialog', () => {- it('renders accessible confirmation copy, traps focus, cancels, and restores focus', async () => {- const user = userEvent.setup()- render(<DialogHarness />)- const trigger = screen.getByRole('button', { name: 'open migration' })- await user.click(trigger)-- expect(- screen.getByRole('alertdialog', {- name: 'workflow.nodes.humanInputMigration.dialog.title:{"count":3}',- }),- ).toBeInTheDocument()- expect(- screen.getByText('workflow.nodes.humanInputMigration.dialog.description'),- ).toBeInTheDocument()- expect(screen.getByText('workflow.nodes.humanInputMigration.dialog.review')).toBeInTheDocument()- expect(- screen.getByText('workflow.nodes.humanInputMigration.dialog.draftNotice'),- ).toBeInTheDocument()- expect(screen.getByText('outside')).not.toHaveFocus()-- await user.click(screen.getByRole('button', { name: 'common.operation.cancel' }))- await waitFor(() => expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument())- expect(trigger).toHaveFocus()- })-- it('closes on Escape and restores focus to the invoking control', async () => {- const user = userEvent.setup()- render(<DialogHarness />)- const trigger = screen.getByRole('button', { name: 'open migration' })- await user.click(trigger)- await user.keyboard('{Escape}')-- await waitFor(() => expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument())- expect(trigger).toHaveFocus()- })-- it('locks both actions and prevents duplicate confirmation while pending', async () => {- const user = userEvent.setup()- const onConfirm = vi.fn()- render(<DialogHarness onConfirm={onConfirm} />)- await user.click(screen.getByRole('button', { name: 'open migration' }))- const confirm = screen.getByRole('button', {- name: 'workflow.nodes.humanInputMigration.action.migrate',- })- await user.dblClick(confirm)-- expect(onConfirm).toHaveBeenCalledTimes(1)- expect(- screen.getByRole('button', { name: 'workflow.nodes.humanInputMigration.action.migrate' }),- ).toHaveAttribute('aria-disabled', 'true')- expect(screen.getByRole('button', { name: 'common.operation.cancel' })).toHaveAttribute(- 'aria-disabled',- 'true',- )- await user.keyboard('{Escape}')- expect(screen.getByRole('alertdialog')).toBeInTheDocument()- })-- it('presents a node-specific recoverable error', () => {- render(- <HumanInputMigrationDialog- open- pending={false}- nodeCount={1}- error="Approval could not be migrated"- onOpenChange={vi.fn()}- onConfirm={vi.fn()}- />,- )-- expect(screen.getByRole('alert')).toHaveTextContent('Approval could not be migrated')- })-})diff --git a/web/app/components/workflow/nodes/human-input/components/__tests__/button-style-dropdown.browser.spec.tsx b/web/app/components/workflow/nodes/human-input/components/__tests__/button-style-dropdown.browser.spec.tsxnew file mode 100644index 00000000000..f4ddc209d18--- /dev/null+++ b/web/app/components/workflow/nodes/human-input/components/__tests__/button-style-dropdown.browser.spec.tsx@@ -0,0 +1,47 @@+import { useState } from 'react'+import { page, userEvent } from 'vite-plus/test/browser'+import { render } from 'vitest-browser-react'+import { guardUnexpectedFetch } from '@/test/unexpected-fetch'+import { UserActionButtonType } from '../../types'+import ButtonStyleDropdown from '../button-style-dropdown'++const prefix = 'workflowHumanInput.nodes.humanInput.userActions'+function StyleOwner({ readonly = false }: { readonly?: boolean }) {+ const [style, setStyle] = useState<UserActionButtonType>(UserActionButtonType.Ghost)+ return <ButtonStyleDropdown text="Approve" data={style} onChange={setStyle} readonly={readonly} />+}++beforeEach(async () => {+ onTestFinished(guardUnexpectedFetch())+ await page.viewport(800, 600)+})++it('keeps the keyboard-selected style after closing and reopening the picker', async () => {+ await render(<StyleOwner />)+ const trigger = page.getByRole('button', { name: `Approve: ${prefix}.chooseStyle` })+ await userEvent.tab()+ await expect.element(trigger).toHaveFocus()+ await userEvent.keyboard('{Enter}')+ const ghost = page.getByRole('radio', { name: `Approve, ${prefix}.buttonStyle.ghost` })+ await expect.element(ghost).toBeChecked()+ await ghost.click()+ await userEvent.keyboard('{ArrowRight}')+ const primary = page.getByRole('radio', { name: `Approve, ${prefix}.buttonStyle.primary` })+ await expect.element(primary).toHaveFocus()+ await userEvent.keyboard(' ')+ await expect.element(primary).toBeChecked()+ await userEvent.keyboard('{Escape}')+ await expect.element(page.getByRole('radiogroup')).not.toBeInTheDocument()+ await expect.element(trigger).toHaveFocus()+ await trigger.click()+ await expect.element(primary).toBeChecked()+})++it('keeps the style picker unavailable in readonly mode', async () => {+ await render(<StyleOwner readonly />)+ await expect+ .element(page.getByRole('button', { name: `Approve: ${prefix}.chooseStyle` }))+ .toBeDisabled()+ await userEvent.tab()+ await expect.element(page.getByRole('radiogroup')).not.toBeInTheDocument()+})diff --git a/web/app/components/workflow/nodes/human-input/components/__tests__/button-style-dropdown.spec.tsx b/web/app/components/workflow/nodes/human-input/components/__tests__/button-style-dropdown.spec.tsxdeleted file mode 100644index a358aac73e8..00000000000--- a/web/app/components/workflow/nodes/human-input/components/__tests__/button-style-dropdown.spec.tsx+++ /dev/null@@ -1,88 +0,0 @@-import { render, screen } from '@testing-library/react'-import userEvent from '@testing-library/user-event'-import { withSelectorKey } from '@/test/i18n-mock'-import { UserActionButtonType } from '../../types'-import ButtonStyleDropdown from '../button-style-dropdown'--const mockUseTranslation = vi.hoisted(() => vi.fn())-vi.mock('react-i18next', () => ({- useTranslation: () => mockUseTranslation(),-}))--describe('ButtonStyleDropdown', () => {- const onChange = vi.fn()-- beforeEach(() => {- vi.clearAllMocks()- mockUseTranslation.mockReturnValue({- t: withSelectorKey((key: string) => {- const translations: Record<string, string> = {- 'nodes.humanInput.userActions.buttonStyle.ghost': 'Ghost',- 'nodes.humanInput.userActions.buttonStyle.primary': 'Primary',- }- return translations[key] ?? key- }),- })- })-- it('should open the style picker and update the selected style', async () => {- const user = userEvent.setup()- const view = render(- <ButtonStyleDropdown- text="Approve"- data={UserActionButtonType.Ghost}- onChange={(nextStyle) => {- onChange(nextStyle)- view.rerender(<ButtonStyleDropdown text="Approve" data={nextStyle} onChange={onChange} />)- }}- />,- )-- const trigger = screen.getByRole('button', {- name: 'Approve: nodes.humanInput.userActions.chooseStyle',- })- await user.tab()- expect(trigger).toHaveFocus()- await user.keyboard('{Enter}')- const radioGroup = screen.getByRole('radiogroup', {- name: 'Approve: nodes.humanInput.userActions.chooseStyle',- })- expect(radioGroup).toBeInTheDocument()-- const ghostRadio = screen.getByRole('radio', { name: 'Approve, Ghost' })- expect(ghostRadio).toHaveAttribute('aria-checked', 'true')- const primaryRadio = screen.getByRole('radio', { name: 'Approve, Primary' })- ghostRadio.focus()- await user.keyboard('{ArrowRight}')-- expect(primaryRadio).toHaveFocus()- await user.keyboard(' ')- expect(primaryRadio).toHaveAttribute('aria-checked', 'true')- expect(onChange).toHaveBeenCalledWith(UserActionButtonType.Primary)- await user.keyboard('{Escape}')- expect(screen.queryByRole('dialog')).not.toBeInTheDocument()- await user.click(trigger)- expect(screen.getByRole('radio', { name: 'Approve, Primary' })).toBeChecked()- })-- it('should keep the dropdown closed in readonly mode', async () => {- const user = userEvent.setup()- render(- <ButtonStyleDropdown- text="Approve"- data={UserActionButtonType.Default}- onChange={onChange}- readonly- />,- )-- const trigger = screen.getByRole('button', {- name: 'Approve: nodes.humanInput.userActions.chooseStyle',- })- expect(trigger).toBeDisabled()- await user.click(trigger)-- expect(screen.queryByRole('dialog')).not.toBeInTheDocument()- expect(onChange).not.toHaveBeenCalled()- })-})diff --git a/web/app/components/workflow/nodes/human-input/components/__tests__/timeout.browser.spec.tsx b/web/app/components/workflow/nodes/human-input/components/__tests__/timeout.browser.spec.tsxnew file mode 100644index 00000000000..60db0ea861a--- /dev/null+++ b/web/app/components/workflow/nodes/human-input/components/__tests__/timeout.browser.spec.tsx@@ -0,0 +1,97 @@+import { useState } from 'react'+import { page, userEvent } from 'vite-plus/test/browser'+import { render } from 'vitest-browser-react'+import { guardUnexpectedFetch } from '@/test/unexpected-fetch'+import TimeoutInput from '../timeout'++function TimeoutOwner({+ initial = 3,+ unit = 'day',+ readonly = false,+}: {+ initial?: number+ unit?: 'day' | 'hour'+ readonly?: boolean+}) {+ const [value, setValue] = useState({ timeout: initial, unit })+ return (+ <>+ <TimeoutInput {...value} onChange={setValue} readonly={readonly} />+ <output aria-label="Saved timeout">{JSON.stringify(value)}</output>+ </>+ )+}++beforeEach(async () => {+ onTestFinished(guardUnexpectedFetch())+ await page.viewport(800, 600)+})++it('keeps the keyboard-edited timeout when switching units', async () => {+ await render(<TimeoutOwner />)+ const input = page.getByRole('textbox', { name: 'workflow.nodes.humanInput.timeout.title' })+ await input.click()+ await userEvent.keyboard('{ArrowUp}')+ await expect.element(input).toHaveValue('4')+ await page+ .getByRole('radio', { name: 'workflowHumanInput.nodes.humanInput.timeout.hours' })+ .click()+ await expect.element(input).toHaveValue('4')+ await expect+ .element(page.getByRole('status', { name: 'Saved timeout' }))+ .toHaveTextContent('{"timeout":4,"unit":"hour"}')+ await expect+ .element(page.getByRole('radio', { name: 'workflowHumanInput.nodes.humanInput.timeout.hours' }))+ .toBeChecked()+})++it('falls back to 1 when cleared and preserves the value in read-only mode', async () => {+ const view = await render(<TimeoutOwner initial={5} unit="hour" />)+ const input = page.getByRole('textbox', { name: 'workflow.nodes.humanInput.timeout.title' })+ await input.fill('')+ await userEvent.tab()+ await expect.element(input).toHaveValue('1')+ await view.rerender(<TimeoutOwner initial={5} unit="hour" readonly />)+ await expect.element(input).toBeDisabled()+ await expect.element(input).toHaveValue('1')+ await expect+ .element(page.getByRole('radio', { name: 'workflowHumanInput.nodes.humanInput.timeout.days' }))+ .toBeDisabled()+ await expect+ .element(page.getByRole('radio', { name: 'workflowHumanInput.nodes.humanInput.timeout.hours' }))+ .toBeChecked()+})++it('rounds a fractional timeout before keeping it through a unit change', async () => {+ await render(<TimeoutOwner unit="hour" />)+ const input = page.getByRole('textbox', { name: 'workflow.nodes.humanInput.timeout.title' })+ await input.fill('1.5')+ await userEvent.tab()+ await expect.element(input).toHaveValue('2')+ await page+ .getByRole('radio', { name: 'workflowHumanInput.nodes.humanInput.timeout.days' })+ .click()+ await expect.element(input).toHaveValue('2')+ await expect+ .element(page.getByRole('status', { name: 'Saved timeout' }))+ .toHaveTextContent('{"timeout":2,"unit":"day"}')+ await expect+ .element(page.getByRole('radio', { name: 'workflowHumanInput.nodes.humanInput.timeout.days' }))+ .toBeChecked()+})++it('normalizes an imported fractional timeout when switching units', async () => {+ await render(<TimeoutOwner initial={1.5} unit="hour" />)+ await page+ .getByRole('radio', { name: 'workflowHumanInput.nodes.humanInput.timeout.days' })+ .click()+ await expect+ .element(page.getByRole('textbox', { name: 'workflow.nodes.humanInput.timeout.title' }))+ .toHaveValue('2')+ await expect+ .element(page.getByRole('status', { name: 'Saved timeout' }))+ .toHaveTextContent('{"timeout":2,"unit":"day"}')+ await expect+ .element(page.getByRole('radio', { name: 'workflowHumanInput.nodes.humanInput.timeout.days' }))+ .toBeChecked()+})diff --git a/web/app/components/workflow/nodes/human-input/components/__tests__/timeout.hitl-v2.spec.tsx b/web/app/components/workflow/nodes/human-input/components/__tests__/timeout.hitl-v2.spec.tsxdeleted file mode 100644index 2f5841ce944..00000000000--- a/web/app/components/workflow/nodes/human-input/components/__tests__/timeout.hitl-v2.spec.tsx+++ /dev/null@@ -1,63 +0,0 @@-import { render, screen } from '@testing-library/react'-import userEvent from '@testing-library/user-event'-import { useState } from 'react'-import { withSelectorKey } from '@/test/i18n-mock'-import TimeoutInput from '../timeout'--const mockUseTranslation = vi.hoisted(() => vi.fn())--vi.mock('react-i18next', () => ({- useTranslation: () => mockUseTranslation(),-}))--describe('TimeoutInput', () => {- const onChange = vi.fn()-- beforeEach(() => {- vi.clearAllMocks()- mockUseTranslation.mockReturnValue({- t: withSelectorKey((key: string) => key),- })- })-- it('keeps a pasted fractional timeout and unit changes within the integer contract', async () => {- const user = userEvent.setup()- const ControlledTimeout = () => {- const [state, setState] = useState<{ timeout: number; unit: 'day' | 'hour' }>({- timeout: 3,- unit: 'hour',- })- return (- <TimeoutInput- {...state}- onChange={(next) => {- onChange(next)- setState(next)- }}- />- )- }- render(<ControlledTimeout />)-- const input = screen.getByRole('textbox', { name: 'nodes.humanInput.timeout.title' })- await user.clear(input)- await user.paste('1.5')- await user.tab()-- expect(input).toHaveValue('2')- expect(onChange).toHaveBeenLastCalledWith({ timeout: 2, unit: 'hour' })- expect(onChange.mock.calls.every(([value]) => Number.isInteger(value.timeout))).toBe(true)-- await user.click(screen.getByRole('radio', { name: 'nodes.humanInput.timeout.days' }))- expect(onChange).toHaveBeenLastCalledWith({ timeout: 2, unit: 'day' })- })-- it('does not preserve an imported fractional timeout when switching units', async () => {- const user = userEvent.setup()- render(<TimeoutInput timeout={1.5} unit="hour" onChange={onChange} />)-- await user.click(screen.getByRole('radio', { name: 'nodes.humanInput.timeout.days' }))-- expect(onChange).toHaveBeenCalledExactlyOnceWith({ timeout: 2, unit: 'day' })- })-})diff --git a/web/app/components/workflow/nodes/human-input/components/__tests__/timeout.spec.tsx b/web/app/components/workflow/nodes/human-input/components/__tests__/timeout.spec.tsxdeleted file mode 100644index 8883cc95178..00000000000--- a/web/app/components/workflow/nodes/human-input/components/__tests__/timeout.spec.tsx+++ /dev/null@@ -1,48 +0,0 @@-import { render, screen } from '@testing-library/react'-import userEvent from '@testing-library/user-event'-import TimeoutInput from '../timeout'--describe('TimeoutInput', () => {- const onChange = vi.fn()-- it('should update the timeout with the keyboard and switch units', async () => {- const user = userEvent.setup()- render(<TimeoutInput timeout={3} unit="day" onChange={onChange} />)-- const timeoutInput = screen.getByRole('textbox', {- name: 'workflow.nodes.humanInput.timeout.title',- })- await user.click(timeoutInput)- await user.keyboard('{ArrowUp}')- await user.click(- screen.getByRole('radio', { name: 'workflowHumanInput.nodes.humanInput.timeout.hours' }),- )-- expect(onChange).toHaveBeenNthCalledWith(1, { timeout: 4, unit: 'day' })- expect(onChange).toHaveBeenNthCalledWith(2, { timeout: 3, unit: 'hour' })- })-- it('should fall back to 1 when cleared and stay read-only when disabled', async () => {- const user = userEvent.setup()- const { rerender } = render(<TimeoutInput timeout={5} unit="hour" onChange={onChange} />)-- const timeoutInput = screen.getByRole('textbox', {- name: 'workflow.nodes.humanInput.timeout.title',- })- await user.clear(timeoutInput)- expect(onChange).toHaveBeenCalledWith({ timeout: 1, unit: 'hour' })-- rerender(<TimeoutInput timeout={5} unit="hour" onChange={onChange} readonly />)-- await user.click(- screen.getByRole('radio', { name: 'workflowHumanInput.nodes.humanInput.timeout.days' }),- )- expect(onChange).toHaveBeenCalledTimes(1)- expect(- screen.getByRole('textbox', { name: 'workflow.nodes.humanInput.timeout.title' }),- ).toBeDisabled()- expect(- screen.getByRole('radio', { name: 'workflowHumanInput.nodes.humanInput.timeout.days' }),- ).toBeDisabled()- })-})diff --git a/web/app/components/workflow/nodes/human-input/components/__tests__/user-action.browser.spec.tsx b/web/app/components/workflow/nodes/human-input/components/__tests__/user-action.browser.spec.tsxnew file mode 100644index 00000000000..c338420ca27--- /dev/null+++ b/web/app/components/workflow/nodes/human-input/components/__tests__/user-action.browser.spec.tsx@@ -0,0 +1,96 @@+import type { UserAction } from '../../types'+import { useState } from 'react'+import { page, userEvent } from 'vite-plus/test/browser'+import { render } from 'vitest-browser-react'+import { guardUnexpectedFetch } from '@/test/unexpected-fetch'+import { UserActionButtonType } from '../../types'+import UserActionItem from '../user-action'++const notify = vi.hoisted(() => vi.fn())+vi.mock('@/app/notifications', () => ({ toast: { error: notify } }))+const prefix = 'workflowHumanInput.nodes.humanInput.userActions'+const initial: UserAction = {+ id: 'approve',+ title: 'Approve',+ button_style: UserActionButtonType.Primary,+}++function ActionOwner({ readonly = false }: { readonly?: boolean }) {+ const [action, setAction] = useState<UserAction | null>(initial)+ return (+ <>+ {action && (+ <UserActionItem+ data={action}+ onChange={setAction}+ onDelete={(id) => {+ if (id === action.id) setAction(null)+ }}+ readonly={readonly}+ />+ )}+ <output aria-label="Saved action">{JSON.stringify(action)}</output>+ </>+ )+}++beforeEach(async () => {+ onTestFinished(guardUnexpectedFetch())+ await page.viewport(1000, 600)+})++it('sanitizes identifiers, rejects invalid input, and keeps the identifier when editing the title', async () => {+ await render(<ActionOwner />)+ const identifier = page.getByRole('textbox', { name: `${prefix}.actionNamePlaceholder` })+ await identifier.fill('Approve action')+ await expect.element(identifier).toHaveValue('Approve_action')+ await identifier.fill('')+ await identifier.fill('1invalid')+ await expect.element(identifier).toHaveValue('')+ expect(notify).toHaveBeenLastCalledWith(`${prefix}.actionIdFormatTip`)+ await identifier.fill('averyveryveryverylongidentifier')+ await expect.element(identifier).toHaveValue('averyveryveryverylon')+ expect(notify).toHaveBeenLastCalledWith(`${prefix}.actionIdTooLong:{"maxLength":20}`)+ await page+ .getByRole('textbox', { name: `${prefix}.buttonTextPlaceholder` })+ .fill('Approve request')+ await expect.element(page.getByRole('status', { name: 'Saved action' })).toHaveTextContent(+ JSON.stringify({+ ...initial,+ id: 'averyveryveryverylon',+ title: 'Approve request',+ }),+ )+})++it('keeps the edited identifier through style changes and removes the matching action', async () => {+ const view = await render(<ActionOwner />)+ const identifier = page.getByRole('textbox', { name: `${prefix}.actionNamePlaceholder` })+ await identifier.fill('accept')+ await page.getByRole('button', { name: `Approve: ${prefix}.chooseStyle` }).click()+ await page.getByRole('radio', { name: `Approve, ${prefix}.buttonStyle.ghost` }).click()+ await expect.element(page.getByRole('status', { name: 'Saved action' })).toHaveTextContent(+ JSON.stringify({+ ...initial,+ id: 'accept',+ button_style: UserActionButtonType.Ghost,+ }),+ )+ await userEvent.keyboard('{Escape}')+ await expect.element(page.getByRole('radiogroup')).not.toBeInTheDocument()+ await view.rerender(<ActionOwner readonly />)+ await expect.element(identifier).toBeDisabled()+ await expect+ .element(page.getByRole('textbox', { name: `${prefix}.buttonTextPlaceholder` }))+ .toBeDisabled()+ await expect+ .element(page.getByRole('button', { name: `Approve: ${prefix}.chooseStyle` }))+ .toBeDisabled()+ await expect+ .element(page.getByRole('button', { name: 'common.operation.delete' }))+ .not.toBeInTheDocument()+ await view.rerender(<ActionOwner />)+ await page.getByRole('button', { name: 'common.operation.delete' }).click()+ await expect.element(identifier).not.toBeInTheDocument()+ await expect.element(page.getByRole('status', { name: 'Saved action' })).toHaveTextContent('null')+})diff --git a/web/app/components/workflow/nodes/human-input/components/__tests__/user-action.spec.tsx b/web/app/components/workflow/nodes/human-input/components/__tests__/user-action.spec.tsxdeleted file mode 100644index 85a605138c6..00000000000--- a/web/app/components/workflow/nodes/human-input/components/__tests__/user-action.spec.tsx+++ /dev/null@@ -1,102 +0,0 @@-import type { UserAction } from '../../types'-import { render, screen } from '@testing-library/react'-import userEvent from '@testing-library/user-event'-import { useState } from 'react'-import { UserActionButtonType } from '../../types'-import UserActionItem from '../user-action'--const mockNotify = vi.hoisted(() => vi.fn())-vi.mock('@/app/notifications', () => ({ toast: { error: mockNotify } }))--const prefix = 'workflowHumanInput.nodes.humanInput.userActions'-const action: UserAction = {- id: 'approve',- title: 'Approve',- button_style: UserActionButtonType.Primary,-}--function Harness({- onChange,- onDelete = vi.fn(),- readonly = false,-}: {- onChange: (action: UserAction) => void- onDelete?: (id: string) => void- readonly?: boolean-}) {- const [data, setData] = useState(action)- return (- <UserActionItem- data={data}- onChange={(next) => {- setData(next)- onChange(next)- }}- onDelete={onDelete}- readonly={readonly}- />- )-}--describe('UserActionItem', () => {- it('sanitizes pasted identifiers, rejects invalid ones, and preserves edits when changing the title', async () => {- const user = userEvent.setup()- const onChange = vi.fn()- render(<Harness onChange={onChange} />)- const identifier = screen.getByRole('textbox', { name: `${prefix}.actionNamePlaceholder` })- await user.clear(identifier)- await user.paste('Approve action')- expect(identifier).toHaveValue('Approve_action')-- await user.clear(identifier)- onChange.mockClear()- await user.paste('1invalid')- expect(onChange).not.toHaveBeenCalled()- expect(identifier).toHaveValue('')- expect(mockNotify).toHaveBeenLastCalledWith(`${prefix}.actionIdFormatTip`)-- await user.paste('averyveryveryverylongidentifier')- expect(identifier).toHaveValue('averyveryveryverylon')- expect(mockNotify).toHaveBeenLastCalledWith(`${prefix}.actionIdTooLong:{"maxLength":20}`)-- const title = screen.getByRole('textbox', { name: `${prefix}.buttonTextPlaceholder` })- await user.clear(title)- await user.paste('Approve request')- expect(onChange).toHaveBeenLastCalledWith({- ...action,- id: 'averyveryveryverylon',- title: 'Approve request',- })- })-- it('keeps the edited identifier through style changes and deletes that action', async () => {- const user = userEvent.setup()- const onChange = vi.fn()- const onDelete = vi.fn()- const { rerender } = render(<Harness onChange={onChange} onDelete={onDelete} />)- const identifier = screen.getByRole('textbox', { name: `${prefix}.actionNamePlaceholder` })- await user.clear(identifier)- expect(identifier).toHaveValue('')- await user.paste('accept')- await user.click(screen.getByRole('button', { name: `Approve: ${prefix}.chooseStyle` }))- await user.click(- await screen.findByRole('radio', { name: `Approve, ${prefix}.buttonStyle.ghost` }),- )- expect(onChange).toHaveBeenLastCalledWith({- ...action,- id: 'accept',- button_style: UserActionButtonType.Ghost,- })- await user.keyboard('{Escape}')- await user.click(screen.getByRole('button', { name: 'common.operation.delete' }))- expect(onDelete).toHaveBeenCalledWith('accept')-- rerender(<Harness onChange={onChange} onDelete={onDelete} readonly />)- expect(identifier).toBeDisabled()- expect(screen.getByRole('textbox', { name: `${prefix}.buttonTextPlaceholder` })).toBeDisabled()- expect(screen.getByRole('button', { name: `Approve: ${prefix}.chooseStyle` })).toBeDisabled()- expect(- screen.queryByRole('button', { name: 'common.operation.delete' }),- ).not.toBeInTheDocument()- })-})