Skip to content

armgit / dify

Public Imported from GitHub
0

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.

fix(ui): preserve Base UI callback and ref contracts (#42721)

yyha78f716216b8
diff --git a/packages/dify-ui/package.json b/packages/dify-ui/package.json
index 1cc708878b7..737f6f09ee4 100644
--- a/packages/dify-ui/package.json
+++ b/packages/dify-ui/package.json
@@ -187,6 +187,7 @@
"type-check": "tsc"
},
"dependencies": {
+ "@base-ui/utils": "catalog:",
"cn": "catalog:"
},
"devDependencies": {
diff --git a/packages/dify-ui/src/alert-dialog/index.tsx b/packages/dify-ui/src/alert-dialog/index.tsx
index 6362050c663..e0af67d7bbd 100644
--- a/packages/dify-ui/src/alert-dialog/index.tsx
+++ b/packages/dify-ui/src/alert-dialog/index.tsx
@@ -70,20 +70,11 @@ function AlertDialogActions({ className, ...props }: AlertDialogActionsProps) {
)
}
-type AlertDialogCancelButtonProps = Omit<ButtonProps, 'children'> & {
- children: React.ReactNode
- closeProps?: Omit<BaseAlertDialog.Close.Props, 'children' | 'render'>
-}
+type AlertDialogCancelButtonProps = ButtonProps
-function AlertDialogCancelButton({
- children,
- closeProps,
- ...buttonProps
-}: AlertDialogCancelButtonProps) {
+function AlertDialogCancelButton({ children, ...buttonProps }: AlertDialogCancelButtonProps) {
return (
- <BaseAlertDialog.Close {...closeProps} render={<Button {...buttonProps} />}>
- {children}
- </BaseAlertDialog.Close>
+ <BaseAlertDialog.Close render={<Button {...buttonProps} />}>{children}</BaseAlertDialog.Close>
)
}
diff --git a/packages/dify-ui/src/context-menu/__tests__/index.spec.tsx b/packages/dify-ui/src/context-menu/__tests__/index.spec.tsx
index 93d80a2c533..ffd75a8f42d 100644
--- a/packages/dify-ui/src/context-menu/__tests__/index.spec.tsx
+++ b/packages/dify-ui/src/context-menu/__tests__/index.spec.tsx
@@ -267,3 +267,24 @@ describe('context-menu wrapper', () => {
})
})
})
+
+it('resolves submenu popup classes with the popup state', async () => {
+ const screen = await render(
+ <ContextMenu>
+ <ContextMenuTrigger>Open audit menu</ContextMenuTrigger>
+ <ContextMenuContent>
+ <ContextMenuSub open>
+ <ContextMenuSubTrigger>More audit actions</ContextMenuSubTrigger>
+ <ContextMenuSubContent className={(state) => (state.open ? 'opacity-50' : 'opacity-100')}>
+ <ContextMenuItem>Audit action</ContextMenuItem>
+ </ContextMenuSubContent>
+ </ContextMenuSub>
+ </ContextMenuContent>
+ </ContextMenu>,
+ )
+
+ await screen.getByText('Open audit menu').click({ button: 'right' })
+ await expect
+ .element(screen.getByRole('menu', { name: 'More audit actions' }))
+ .toHaveStyle({ opacity: '0.5' })
+})
diff --git a/packages/dify-ui/src/context-menu/index.tsx b/packages/dify-ui/src/context-menu/index.tsx
index c950a3b3618..aa1200e6c68 100644
--- a/packages/dify-ui/src/context-menu/index.tsx
+++ b/packages/dify-ui/src/context-menu/index.tsx
@@ -237,7 +237,13 @@ function ContextMenuSubContent({
className="z-50 outline-hidden"
>
<BaseContextMenu.Popup
- className={cn(menuPopupClassName, floatingPopupAnimationClassName, className)}
+ className={(state) =>
+ cn(
+ menuPopupClassName,
+ floatingPopupAnimationClassName,
+ resolveClassName(className, state),
+ )
+ }
{...props}
>
{children}
diff --git a/packages/dify-ui/src/dropdown-menu/__tests__/index.spec.tsx b/packages/dify-ui/src/dropdown-menu/__tests__/index.spec.tsx
index 1f0f19fc330..56e01500056 100644
--- a/packages/dify-ui/src/dropdown-menu/__tests__/index.spec.tsx
+++ b/packages/dify-ui/src/dropdown-menu/__tests__/index.spec.tsx
@@ -398,3 +398,25 @@ describe('dropdown-menu wrapper', () => {
})
})
})
+
+it('resolves submenu popup classes with the popup state', async () => {
+ const screen = await render(
+ <DropdownMenu open>
+ <DropdownMenuTrigger>Open audit menu</DropdownMenuTrigger>
+ <DropdownMenuContent>
+ <DropdownMenuSub open>
+ <DropdownMenuSubTrigger>More audit actions</DropdownMenuSubTrigger>
+ <DropdownMenuSubContent
+ className={(state) => (state.open ? 'opacity-50' : 'opacity-100')}
+ >
+ <DropdownMenuItem>Audit action</DropdownMenuItem>
+ </DropdownMenuSubContent>
+ </DropdownMenuSub>
+ </DropdownMenuContent>
+ </DropdownMenu>,
+ )
+
+ await expect
+ .element(screen.getByRole('menu', { name: 'More audit actions' }))
+ .toHaveStyle({ opacity: '0.5' })
+})
diff --git a/packages/dify-ui/src/dropdown-menu/index.tsx b/packages/dify-ui/src/dropdown-menu/index.tsx
index 788e98a6d1f..09d4b1e7443 100644
--- a/packages/dify-ui/src/dropdown-menu/index.tsx
+++ b/packages/dify-ui/src/dropdown-menu/index.tsx
@@ -232,7 +232,10 @@ function DropdownMenuSubContent({
sideOffset={sideOffset}
alignOffset={alignOffset}
>
- <DropdownMenuPopup className={cn(menuPopupSurfaceClassName, className)} {...props}>
+ <DropdownMenuPopup
+ className={(state) => cn(menuPopupSurfaceClassName, resolveClassName(className, state))}
+ {...props}
+ >
{children}
</DropdownMenuPopup>
</DropdownMenuPositioner>
diff --git a/packages/dify-ui/src/pagination/__tests__/index.spec.tsx b/packages/dify-ui/src/pagination/__tests__/index.spec.tsx
index a73ada5070e..7e92c757f9a 100644
--- a/packages/dify-ui/src/pagination/__tests__/index.spec.tsx
+++ b/packages/dify-ui/src/pagination/__tests__/index.spec.tsx
@@ -1,3 +1,4 @@
+import * as React from 'react'
import { userEvent } from 'vite-plus/test/browser'
import { render } from 'vitest-browser-react'
import {
@@ -365,3 +366,22 @@ describe('Pagination primitive', () => {
await expect.element(screen.getByTestId('skeleton')).toHaveAttribute('aria-hidden', 'true')
})
})
+
+it('keeps the public page-jump ref usable after editing and focus restoration', async () => {
+ const ref = React.createRef<HTMLButtonElement>()
+ const screen = await render(
+ <PaginationRoot page={2} totalPages={10} onPageChange={() => {}}>
+ <PaginationPageJump ref={ref} />
+ </PaginationRoot>,
+ )
+
+ expect(ref.current).toBe(screen.getByRole('button').element())
+ ref.current?.focus()
+ await expect.element(screen.getByRole('button')).toHaveFocus()
+ await screen.getByRole('button').click()
+ await expect.element(screen.getByRole('textbox', { name: 'Page number' })).toHaveFocus()
+ expect(ref.current).toBeNull()
+ await userEvent.keyboard('{Escape}')
+ await expect.element(screen.getByRole('button')).toHaveFocus()
+ expect(ref.current).toBe(screen.getByRole('button').element())
+})
diff --git a/packages/dify-ui/src/pagination/index.tsx b/packages/dify-ui/src/pagination/index.tsx
index 56435a80477..5eb9cd4e3a1 100644
--- a/packages/dify-ui/src/pagination/index.tsx
+++ b/packages/dify-ui/src/pagination/index.tsx
@@ -4,6 +4,7 @@ import type { Button as BaseButtonNS } from '@base-ui/react/button'
import { Button as BaseButton } from '@base-ui/react/button'
import { mergeProps } from '@base-ui/react/merge-props'
import { useRender } from '@base-ui/react/use-render'
+import { useMergedRefs } from '@base-ui/utils/useMergedRefs'
import * as React from 'react'
import { cn } from '../cn'
import { resolveClassName } from '../internals/resolve-class-name'
@@ -292,6 +293,7 @@ type PaginationPageJumpProps = Omit<BaseButtonNS.Props, 'children'> & {
function PaginationPageJump({
className,
+ ref,
inputLabel = 'Page number',
children,
'aria-label': ariaLabel,
@@ -301,6 +303,7 @@ function PaginationPageJump({
const [editing, setEditing] = React.useState(false)
const summaryButtonRef = React.useRef<HTMLButtonElement | null>(null)
const restoreSummaryFocusRef = React.useRef(false)
+ const mergedSummaryRef = useMergedRefs(summaryButtonRef, ref)
useIsoLayoutEffect(() => {
if (editing || !restoreSummaryFocusRef.current) return
@@ -371,7 +374,7 @@ function PaginationPageJump({
return (
<BaseButton
{...props}
- ref={summaryButtonRef}
+ ref={mergedSummaryRef}
type="button"
aria-label={
ariaLabel ?? `Edit page number, current page ${pagination.page} of ${pagination.totalPages}`
diff --git a/packages/dify-ui/src/radio-group/__tests__/index.spec.tsx b/packages/dify-ui/src/radio-group/__tests__/index.spec.tsx
index 2f44f4af606..6d4246b43d5 100644
--- a/packages/dify-ui/src/radio-group/__tests__/index.spec.tsx
+++ b/packages/dify-ui/src/radio-group/__tests__/index.spec.tsx
@@ -212,3 +212,24 @@ describe('RadioSkeleton', () => {
expect(screen.container.querySelector('[role="radio"]')).not.toBeInTheDocument()
})
})
+
+it('resolves Radio classes again when selection changes', async () => {
+ const screen = await render(
+ <RadioGroup defaultValue="a">
+ <Radio
+ value="a"
+ aria-label="Option A"
+ className={(state) => (state.checked ? 'opacity-50' : 'opacity-100')}
+ />
+ <Radio value="b" aria-label="Option B" />
+ </RadioGroup>,
+ )
+
+ await expect
+ .element(screen.getByRole('radio', { name: 'Option A' }))
+ .toHaveStyle({ opacity: '0.5' })
+ await screen.getByRole('radio', { name: 'Option B' }).click()
+ await expect
+ .element(screen.getByRole('radio', { name: 'Option A' }))
+ .toHaveStyle({ opacity: '1' })
+})
diff --git a/packages/dify-ui/src/radio-group/index.tsx b/packages/dify-ui/src/radio-group/index.tsx
index 5b2153c2cee..4051edc8785 100644
--- a/packages/dify-ui/src/radio-group/index.tsx
+++ b/packages/dify-ui/src/radio-group/index.tsx
@@ -55,18 +55,20 @@ type RadioProps<Value = string> = Omit<RadioItemProps<Value>, 'children'>
function Radio<Value = string>({ className, ...props }: RadioProps<Value>) {
return (
<BaseRadio.Root<Value>
- className={cn(
- 'inline-flex size-4 shrink-0 touch-manipulation items-center justify-center rounded-full p-0 transition-colors motion-reduce:transition-none',
- 'border border-components-radio-border bg-components-radio-bg shadow-xs shadow-shadow-shadow-3',
- 'hover:border-components-radio-border-hover hover:bg-components-radio-bg-hover',
- 'focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:ring-offset-0 focus-visible:outline-hidden',
- 'data-checked:border-[5px] data-checked:border-components-radio-border-checked data-checked:hover:border-components-radio-border-checked-hover',
- 'data-disabled:cursor-not-allowed data-disabled:border-components-radio-border-disabled data-disabled:bg-components-radio-bg-disabled',
- 'data-disabled:hover:border-components-radio-border-disabled data-disabled:hover:bg-components-radio-bg-disabled',
- 'data-disabled:data-checked:border-[5px] data-disabled:data-checked:border-components-radio-border-checked-disabled',
- 'data-disabled:data-checked:hover:border-components-radio-border-checked-disabled',
- className,
- )}
+ className={(state) =>
+ cn(
+ 'inline-flex size-4 shrink-0 touch-manipulation items-center justify-center rounded-full p-0 transition-colors motion-reduce:transition-none',
+ 'border border-components-radio-border bg-components-radio-bg shadow-xs shadow-shadow-shadow-3',
+ 'hover:border-components-radio-border-hover hover:bg-components-radio-bg-hover',
+ 'focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:ring-offset-0 focus-visible:outline-hidden',
+ 'data-checked:border-[5px] data-checked:border-components-radio-border-checked data-checked:hover:border-components-radio-border-checked-hover',
+ 'data-disabled:cursor-not-allowed data-disabled:border-components-radio-border-disabled data-disabled:bg-components-radio-bg-disabled',
+ 'data-disabled:hover:border-components-radio-border-disabled data-disabled:hover:bg-components-radio-bg-disabled',
+ 'data-disabled:data-checked:border-[5px] data-disabled:data-checked:border-components-radio-border-checked-disabled',
+ 'data-disabled:data-checked:hover:border-components-radio-border-checked-disabled',
+ resolveClassName(className, state),
+ )
+ }
{...props}
/>
)
diff --git a/packages/dify-ui/src/switch/__tests__/index.spec.tsx b/packages/dify-ui/src/switch/__tests__/index.spec.tsx
index 71d86ff3482..ba368a3bb4b 100644
--- a/packages/dify-ui/src/switch/__tests__/index.spec.tsx
+++ b/packages/dify-ui/src/switch/__tests__/index.spec.tsx
@@ -58,3 +58,20 @@ describe('Switch', () => {
})
})
})
+
+describe('Switch change cancellation', () => {
+ it('lets event details cancel an uncontrolled change', async () => {
+ const screen = await render(
+ <Switch
+ aria-label="Notifications"
+ defaultChecked={false}
+ onCheckedChange={(checked, details) => {
+ if (checked) details.cancel()
+ }}
+ />,
+ )
+
+ await screen.getByRole('switch').click()
+ await expect.element(screen.getByRole('switch')).not.toBeChecked()
+ })
+})
diff --git a/packages/dify-ui/src/switch/__tests__/types.tsx b/packages/dify-ui/src/switch/__tests__/types.tsx
new file mode 100644
index 00000000000..d18e14c2588
--- /dev/null
+++ b/packages/dify-ui/src/switch/__tests__/types.tsx
@@ -0,0 +1,19 @@
+import type { SwitchProps } from '@langgenius/dify-ui/switch'
+import { Switch } from '@langgenius/dify-ui/switch'
+
+function SwitchTypeExamples() {
+ const onCheckedChange: NonNullable<SwitchProps['onCheckedChange']> = (checked, details) => {
+ if (checked) details.cancel()
+ }
+
+ return (
+ <>
+ <Switch defaultChecked onCheckedChange={onCheckedChange} />
+ <Switch checked={false} onCheckedChange={(checked) => void checked} />
+ {/* @ts-expect-error the composite owns its thumb and loading indicator */}
+ <Switch>Custom thumb</Switch>
+ </>
+ )
+}
+
+void SwitchTypeExamples
diff --git a/packages/dify-ui/src/switch/index.tsx b/packages/dify-ui/src/switch/index.tsx
index 1cecc66797d..43fc9e94fe4 100644
--- a/packages/dify-ui/src/switch/index.tsx
+++ b/packages/dify-ui/src/switch/index.tsx
@@ -68,11 +68,10 @@ type SwitchControlProps = ControlledSwitchProps | UncontrolledSwitchProps
type SwitchProps = Omit<
BaseSwitchNS.Root.Props,
- 'checked' | 'defaultChecked' | 'size' | 'onCheckedChange'
+ 'checked' | 'children' | 'defaultChecked' | 'size'
> &
VariantProps<typeof switchRootVariants> &
SwitchControlProps & {
- onCheckedChange?: (checked: boolean) => void
loading?: boolean
}
@@ -82,7 +81,6 @@ function Switch({
disabled,
loading = false,
className,
- onCheckedChange,
...props
}: SwitchProps) {
const isDisabled = disabled || loading
@@ -93,7 +91,6 @@ function Switch({
disabled={isDisabled}
aria-busy={loading || undefined}
className={(state) => cn(switchRootVariants({ size }), resolveClassName(className, state))}
- onCheckedChange={(value) => onCheckedChange?.(value)}
{...props}
>
<BaseSwitch.Thumb className={switchThumbVariants({ size })} />
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index e0974435ba6..79d001da6e8 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -176,6 +176,9 @@ catalogs:
'@base-ui/react':
specifier: 1.8.0
version: 1.8.0
+ '@base-ui/utils':
+ specifier: 0.4.0
+ version: 0.4.0
'@chromatic-com/storybook':
specifier: 5.3.1
version: 5.3.1
@@ -1131,6 +1134,9 @@ importers:
packages/dify-ui:
dependencies:
+ '@base-ui/utils':
+ specifier: 'catalog:'
cn:
specifier: 'catalog:'
version: 0.3.0
@@ -18251,6 +18257,7 @@ time:
'@amplitude/[email protected]': '2026-09-16T19:27:10.945Z'
'@axe-core/[email protected]': '2026-08-11T17:07:40.763Z'
'@base-ui/[email protected]': '2026-09-04T08:52:51.986Z'
+ '@base-ui/[email protected]': '2026-09-04T08:49:31.070Z'
'@chromatic-com/[email protected]': '2026-09-02T13:43:27.595Z'
'@cucumber/[email protected]': '2026-08-04T07:20:28.681Z'
'@egoist/[email protected]': '2026-01-31T10:48:44.594Z'
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index 43867df97ef..bc31659fea8 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -65,6 +65,7 @@ catalog:
'@amplitude/plugin-session-replay-browser': 1.35.1
'@axe-core/playwright': 4.13.0
'@base-ui/react': 1.8.0
+ '@base-ui/utils': 0.4.0
'@chromatic-com/storybook': 5.3.1
'@cucumber/cucumber': 13.2.1
'@egoist/tailwindcss-icons': 1.9.2
diff --git a/web/app/components/custom/custom-web-app-brand/__tests__/index.spec.tsx b/web/app/components/custom/custom-web-app-brand/__tests__/index.spec.tsx
index 28b80f5bc02..ac008c9b19a 100644
--- a/web/app/components/custom/custom-web-app-brand/__tests__/index.spec.tsx
+++ b/web/app/components/custom/custom-web-app-brand/__tests__/index.spec.tsx
@@ -141,14 +141,6 @@ describe('CustomWebAppBrand', () => {
// User interactions delegated to the hook callbacks.
describe('Interactions', () => {
- it('should delegate switch changes to the hook handler', () => {
- const { hookState } = renderComponent()
-
- fireEvent.click(screen.getByRole('switch'))
-
- expect(hookState.handleSwitch).toHaveBeenCalledWith(true)
- })
-
it('should delegate file input changes and reset the native input value on click', () => {
const { container, hookState } = renderComponent()
const fileInput = container.querySelector('input[type="file"]') as HTMLInputElement
diff --git a/web/app/components/workflow/nodes/http/__tests__/panel.spec.tsx b/web/app/components/workflow/nodes/http/__tests__/panel.spec.tsx
index ff0ece4a651..cda4818f9a0 100644
--- a/web/app/components/workflow/nodes/http/__tests__/panel.spec.tsx
+++ b/web/app/components/workflow/nodes/http/__tests__/panel.spec.tsx
@@ -176,7 +176,6 @@ describe('http/panel', () => {
const showCurlPanel = vi.fn()
const hideCurlPanel = vi.fn()
const handleCurlImport = vi.fn()
- const handleSSLVerifyChange = vi.fn()
const createConfigResult = (overrides: Record<string, unknown> = {}) => ({
readOnly: false,
@@ -202,7 +201,7 @@ describe('http/panel', () => {
showCurlPanel,
hideCurlPanel,
handleCurlImport,
- handleSSLVerifyChange,
+ handleSSLVerifyChange: vi.fn(),
...overrides,
})
@@ -232,7 +231,6 @@ describe('http/panel', () => {
await user.click(screen.getByRole('button', { name: 'emit-timeout-change' }))
await user.click(screen.getByText('workflow.nodes.http.authorization.authorization'))
await user.click(screen.getByText('workflow.nodes.http.curl.title'))
- await user.click(screen.getByRole('switch'))
expect(handleMethodChange).toHaveBeenCalledWith(Method.post)
expect(handleUrlChange).toHaveBeenCalledWith('https://changed.example.com')
@@ -247,7 +245,6 @@ describe('http/panel', () => {
expect(setTimeout).toHaveBeenCalledWith(expect.objectContaining({ connect: 9 }))
expect(showAuthorization).toHaveBeenCalledTimes(1)
expect(showCurlPanel).toHaveBeenCalledTimes(1)
- expect(handleSSLVerifyChange).toHaveBeenCalledWith(false)
expect(mockApiInput).toHaveBeenCalledWith(
expect.objectContaining({
method: Method.get,
diff --git a/web/app/components/workflow/nodes/iteration/__tests__/integration.spec.tsx b/web/app/components/workflow/nodes/iteration/__tests__/integration.spec.tsx
index 2801c5da385..d913333e061 100644
--- a/web/app/components/workflow/nodes/iteration/__tests__/integration.spec.tsx
+++ b/web/app/components/workflow/nodes/iteration/__tests__/integration.spec.tsx
@@ -160,14 +160,12 @@ describe('iteration path', () => {
expect(mockToastWarning).toHaveBeenCalledWith('workflow.nodes.iteration.answerNodeWarningDesc')
})
- it('should wire panel input, output, parallel, numeric, error mode, and flatten actions', async () => {
+ it('should wire panel input, output, numeric, and error mode actions', async () => {
const user = userEvent.setup()
const handleInputChange = vi.fn()
const handleOutputVarChange = vi.fn()
- const changeParallel = vi.fn()
const changeParallelNums = vi.fn()
const changeErrorResponseMode = vi.fn()
- const changeFlattenOutput = vi.fn()
mockUseConfig.mockReturnValueOnce(
createConfigResult({
@@ -177,10 +175,8 @@ describe('iteration path', () => {
}),
handleInputChange,
handleOutputVarChange,
- changeParallel,
changeParallelNums,
changeErrorResponseMode,
- changeFlattenOutput,
}),
)
@@ -188,7 +184,6 @@ describe('iteration path', () => {
await user.click(screen.getByRole('button', { name: 'pick-input-var' }))
await user.click(screen.getByRole('button', { name: 'pick-output-var' }))
- await user.click(screen.getAllByRole('switch')[0]!)
const parallelInput = screen.getByRole('textbox', {
name: 'workflow.nodes.iteration.MaxParallelismTitle',
})
@@ -198,7 +193,6 @@ describe('iteration path', () => {
await user.click(
screen.getByRole('option', { name: 'workflow.nodes.iteration.ErrorMethod.continueOnError' }),
)
- await user.click(screen.getAllByRole('switch')[1]!)
expect(handleInputChange).toHaveBeenCalledWith(['node-1', 'items'], 'variable', {
type: VarType.arrayString,
@@ -206,14 +200,12 @@ describe('iteration path', () => {
expect(handleOutputVarChange).toHaveBeenCalledWith(['child-node', 'text'], 'variable', {
type: VarType.string,
})
- expect(changeParallel).toHaveBeenCalledWith(false)
expect(changeParallelNums).toHaveBeenCalledWith(7)
expect(changeErrorResponseMode).toHaveBeenCalledWith(
expect.objectContaining({
value: ErrorHandleMode.ContinueOnError,
}),
)
- expect(changeFlattenOutput).toHaveBeenCalledWith(true)
})
it('should hide parallel controls when parallel mode is disabled', () => {
diff --git a/web/app/components/workflow/nodes/knowledge-base/components/retrieval-setting/__tests__/search-method-option.spec.tsx b/web/app/components/workflow/nodes/knowledge-base/components/retrieval-setting/__tests__/search-method-option.spec.tsx
index 87dbda162a6..7b991d77e6e 100644
--- a/web/app/components/workflow/nodes/knowledge-base/components/retrieval-setting/__tests__/search-method-option.spec.tsx
+++ b/web/app/components/workflow/nodes/knowledge-base/components/retrieval-setting/__tests__/search-method-option.spec.tsx
@@ -101,7 +101,7 @@ function renderSearchMethodOption(
}
describe('SearchMethodOption', () => {
- it('should render semantic search controls and notify retrieval and reranking changes', () => {
+ it('should render semantic search controls', () => {
const props = createProps()
renderSearchMethodOption(props)
@@ -110,10 +110,6 @@ describe('SearchMethodOption', () => {
expect(screen.getByText('common.modelProvider.rerankModel.key'))!.toBeInTheDocument()
expect(screen.getByText('plugin.detailPanel.configureModel'))!.toBeInTheDocument()
expect(screen.getAllByRole('switch')).toHaveLength(2)
-
- fireEvent.click(screen.getAllByRole('switch')[0]!)
-
- expect(props.reranking.onEnabledChange).toHaveBeenCalledWith(true)
})
it('should notify retrieval changes when an inactive option is selected', () => {
diff --git a/web/app/components/workflow/nodes/list-operator/__tests__/panel.spec.tsx b/web/app/components/workflow/nodes/list-operator/__tests__/panel.spec.tsx
index 8ea9185748b..a33941cebb6 100644
--- a/web/app/components/workflow/nodes/list-operator/__tests__/panel.spec.tsx
+++ b/web/app/components/workflow/nodes/list-operator/__tests__/panel.spec.tsx
@@ -186,13 +186,9 @@ describe('list-operator/panel', () => {
mockUseConfig.mockReturnValue(createConfigResult())
})
- it('renders enabled sections and forwards all main interactions', async () => {
+ it('renders enabled sections and handles variable, filter, limit, and sort changes', async () => {
const user = userEvent.setup()
- const config = createConfigResult({
- handleOrderByTypeChange: vi.fn(
- (value: OrderBy) => () => config.handleOrderByEnabledChange(value === OrderBy.ASC),
- ),
- })
+ const config = createConfigResult()
mockUseConfig.mockReturnValue(config)
renderPanel()
@@ -218,9 +214,6 @@ describe('list-operator/panel', () => {
await user.click(screen.getByRole('button', { name: 'extract-input:1' }))
await user.click(screen.getByRole('button', { name: 'limit-config:10' }))
await user.click(screen.getByRole('button', { name: 'sub-variable:size' }))
- await user.click(screen.getAllByRole('switch')[0]!)
- await user.click(screen.getAllByRole('switch')[1]!)
- await user.click(screen.getAllByRole('switch')[2]!)
await user.click(screen.getByRole('button', { name: 'workflow.nodes.listFilter.asc:selected' }))
await user.click(screen.getByRole('button', { name: 'workflow.nodes.listFilter.desc:idle' }))
@@ -229,9 +222,6 @@ describe('list-operator/panel', () => {
expect(config.handleExtractsChange).toHaveBeenCalledWith('2')
expect(config.handleLimitChange).toHaveBeenCalledWith({ enabled: true, size: 11 })
expect(config.handleOrderByKeyChange).toHaveBeenCalledWith('name')
- expect(config.handleFilterEnabledChange).toHaveBeenCalledWith(false)
- expect(config.handleExtractsEnabledChange).toHaveBeenCalledWith(false)
- expect(config.handleOrderByEnabledChange).toHaveBeenCalled()
expect(config.handleOrderByTypeChange).toHaveBeenCalledWith(OrderBy.ASC)
expect(config.handleOrderByTypeChange).toHaveBeenCalledWith(OrderBy.DESC)
})
diff --git a/web/app/components/workflow/nodes/llm/components/__tests__/panel-output-section.spec.tsx b/web/app/components/workflow/nodes/llm/components/__tests__/panel-output-section.spec.tsx
index a677dd1d918..028bcd5c918 100644
--- a/web/app/components/workflow/nodes/llm/components/__tests__/panel-output-section.spec.tsx
+++ b/web/app/components/workflow/nodes/llm/components/__tests__/panel-output-section.spec.tsx
@@ -90,10 +90,7 @@ describe('llm/panel-output-section', () => {
expect(screen.queryByTestId('structure-output')).not.toBeInTheDocument()
})
- it('renders the structured output editor and toggles the switch when structured output is enabled', async () => {
- const user = userEvent.setup()
- const handleStructureOutputEnableChange = vi.fn()
-
+ it('renders the structured output editor when structured output is enabled', () => {
render(
<PanelOutputSection
readOnly={false}
@@ -110,16 +107,13 @@ describe('llm/panel-output-section', () => {
isModelSupportStructuredOutput={false}
structuredOutputCollapsed={false}
setStructuredOutputCollapsed={vi.fn()}
- handleStructureOutputEnableChange={handleStructureOutputEnableChange}
+ handleStructureOutputEnableChange={vi.fn()}
handleStructureOutputChange={vi.fn()}
/>,
)
expect(screen.getByTestId('structure-output')).toBeInTheDocument()
expect(mockStructureOutput).toHaveBeenCalled()
-
- await user.click(screen.getByRole('switch'))
- expect(handleStructureOutputEnableChange).toHaveBeenCalledWith(false)
})
it('opens the model warning with the keyboard without changing structured output', async () => {
const user = userEvent.setup()
diff --git a/web/app/components/workflow/note-node/note-editor/toolbar/__tests__/operator.spec.tsx b/web/app/components/workflow/note-node/note-editor/toolbar/__tests__/operator.spec.tsx
index 4128fa7246b..0474c4464bb 100644
--- a/web/app/components/workflow/note-node/note-editor/toolbar/__tests__/operator.spec.tsx
+++ b/web/app/components/workflow/note-node/note-editor/toolbar/__tests__/operator.spec.tsx
@@ -46,12 +46,11 @@ describe('NoteEditor Toolbar Operator', () => {
it('keeps the menu open when toggling show author', async () => {
const user = userEvent.setup()
- const { onShowAuthorChange } = renderOperator(true)
+ renderOperator(true)
await user.click(screen.getByRole('button', { name: 'common.operation.more' }))
await user.click(screen.getByRole('switch'))
- expect(onShowAuthorChange).toHaveBeenCalledWith(false)
expect(screen.getByText('workflow.nodes.note.editor.showAuthor')).toBeInTheDocument()
})
})