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.

test(dify-ui): stabilize dropdown menu story (#40916)

yyh05499b9011b7
diff --git a/packages/dify-ui/src/input-group/index.stories.tsx b/packages/dify-ui/src/input-group/index.stories.tsx
index fc7a0a1fce3..8f8a322d19e 100644
--- a/packages/dify-ui/src/input-group/index.stories.tsx
+++ b/packages/dify-ui/src/input-group/index.stories.tsx
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from '@storybook/react-vite'
import * as React from 'react'
-import { expect, spyOn, within } from 'storybook/test'
+import { expect, spyOn, waitFor, waitForElementToBeRemoved, within } from 'storybook/test'
import { Button } from '../button'
import {
DropdownMenu,
@@ -204,9 +204,15 @@ export const WithDropdownAction: Story = {
await userEvent.click(trigger)
const body = within(canvasElement.ownerDocument.body)
- await userEvent.click(await body.findByRole('menuitem', { name: 'Settings' }))
-
- await expect(trigger).toHaveFocus()
- await expect(body.queryByRole('menuitem', { name: 'Settings' })).not.toBeInTheDocument()
+ const settings = await body.findByRole('menuitem', { name: 'Settings' })
+ const settingsRemoved = waitForElementToBeRemoved(() =>
+ body.queryByRole('menuitem', { name: 'Settings', hidden: true }),
+ )
+ await userEvent.click(settings)
+
+ await settingsRemoved
+ await waitFor(async () => {
+ await expect(trigger).toHaveFocus()
+ })
},
}