mirror of
https://github.com/langgenius/dify.git
synced 2026-05-09 21:28:25 +08:00
test(web): update tooltip migration coverage
This commit is contained in:
parent
02e51e3b4a
commit
16e0f26ea3
@ -84,10 +84,6 @@ vi.mock('@/app/components/app/store', () => ({
|
||||
}),
|
||||
}))
|
||||
|
||||
vi.mock('@/app/components/base/tooltip', () => ({
|
||||
default: ({ children }: { children: ReactNode }) => <>{children}</>,
|
||||
}))
|
||||
|
||||
vi.mock('@/app/components/base/drawer', () => ({
|
||||
default: ({ children, isOpen, onClose }: { children: ReactNode, isOpen: boolean, onClose: () => void }) => (
|
||||
isOpen
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { ReactElement, ReactNode } from 'react'
|
||||
import type { ReactElement } from 'react'
|
||||
import type { AppDetailResponse } from '@/models/app'
|
||||
import { fireEvent, screen, waitFor } from '@testing-library/react'
|
||||
import { renderWithSystemFeatures } from '@/__tests__/utils/mock-system-features'
|
||||
@ -98,15 +98,6 @@ vi.mock('../../app-access-control', () => ({
|
||||
),
|
||||
}))
|
||||
|
||||
vi.mock('@/app/components/base/tooltip', () => ({
|
||||
default: ({ children, popupContent }: { children: ReactNode, popupContent?: ReactNode }) => (
|
||||
<div>
|
||||
{children}
|
||||
{popupContent}
|
||||
</div>
|
||||
),
|
||||
}))
|
||||
|
||||
const mockWindowOpen = vi.fn()
|
||||
Object.defineProperty(window, 'open', {
|
||||
writable: true,
|
||||
|
||||
@ -296,11 +296,6 @@ vi.mock('@langgenius/dify-ui/dropdown-menu', () => {
|
||||
}
|
||||
})
|
||||
|
||||
// Tooltip uses portals - minimal mock preserving popup content as title attribute
|
||||
vi.mock('@/app/components/base/tooltip', () => ({
|
||||
default: ({ children, popupContent }: { children: React.ReactNode, popupContent: React.ReactNode }) => React.createElement('div', { title: popupContent }, children),
|
||||
}))
|
||||
|
||||
// AppCardTags has tag API dependencies - mock for isolated testing
|
||||
vi.mock('@/features/tag-management/components/app-card-tags', () => ({
|
||||
AppCardTags: ({ tags }: { tags?: { id: string, name: string }[] }) => {
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { render, screen } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import Tooltip from '../tooltip'
|
||||
|
||||
describe('Tooltip', () => {
|
||||
@ -8,12 +9,14 @@ describe('Tooltip', () => {
|
||||
|
||||
// Rendering the info tooltip container
|
||||
describe('Rendering', () => {
|
||||
it('should render the content panel when provide with text', () => {
|
||||
it('should render the content panel when hovered', async () => {
|
||||
const user = userEvent.setup()
|
||||
const content = 'Usage resets on the first day of every month.'
|
||||
|
||||
render(<Tooltip content={content} />)
|
||||
await user.hover(screen.getByRole('button', { name: content }))
|
||||
|
||||
expect(() => screen.getByText(content)).not.toThrow()
|
||||
expect(await screen.findByText(content)).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@ -15,12 +15,6 @@ vi.mock('@/app/components/base/radio/ui', () => ({
|
||||
),
|
||||
}))
|
||||
|
||||
vi.mock('@/app/components/base/tooltip', () => ({
|
||||
default: ({ children, popupContent }: { children: React.ReactNode, popupContent: string }) => (
|
||||
<div data-testid="tooltip" title={popupContent}>{children}</div>
|
||||
),
|
||||
}))
|
||||
|
||||
vi.mock('../file-icon', () => ({
|
||||
default: () => <span data-testid="file-icon" />,
|
||||
}))
|
||||
|
||||
@ -42,10 +42,6 @@ vi.mock('../feature-icon', () => ({
|
||||
default: ({ feature }: { feature: string }) => <span data-testid="feature-icon">{feature}</span>,
|
||||
}))
|
||||
|
||||
vi.mock('@/app/components/base/tooltip', () => ({
|
||||
default: ({ children }: { children: ReactNode }) => <div>{children}</div>,
|
||||
}))
|
||||
|
||||
const mockCredentialPanelState = vi.hoisted(() => vi.fn())
|
||||
vi.mock('../../provider-added-card/use-credential-panel-state', () => ({
|
||||
useCredentialPanelState: mockCredentialPanelState,
|
||||
|
||||
@ -54,10 +54,6 @@ vi.mock('@langgenius/dify-ui/switch', () => ({
|
||||
),
|
||||
}))
|
||||
|
||||
vi.mock('@/app/components/base/tooltip', () => ({
|
||||
default: ({ children }: { children?: React.ReactNode }) => <>{children}</>,
|
||||
}))
|
||||
|
||||
vi.mock('@/app/components/header/account-setting/model-provider-page/hooks', () => ({
|
||||
useLanguage: () => 'en_US',
|
||||
}))
|
||||
@ -233,7 +229,7 @@ describe('ReasoningConfigForm', () => {
|
||||
it('should open schema modal for object fields and support app selection', () => {
|
||||
const onChange = vi.fn()
|
||||
|
||||
const { container } = render(
|
||||
render(
|
||||
<ReasoningConfigForm
|
||||
value={{
|
||||
app: {
|
||||
@ -265,7 +261,7 @@ describe('ReasoningConfigForm', () => {
|
||||
/>,
|
||||
)
|
||||
|
||||
fireEvent.click(container.querySelector('div.ml-0\\.5.cursor-pointer')!)
|
||||
fireEvent.click(screen.getByRole('button', { name: 'workflow.nodes.agent.clickToViewParameterSchema' }))
|
||||
expect(screen.getByTestId('schema-modal')).toHaveTextContent('Config')
|
||||
fireEvent.click(screen.getByTestId('close-schema'))
|
||||
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import type { WorkflowToolDrawerPayload } from '../index'
|
||||
import { render, screen, waitFor } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
@ -28,21 +27,6 @@ vi.mock('@/app/components/tools/labels/selector', () => ({
|
||||
),
|
||||
}))
|
||||
|
||||
vi.mock('@/app/components/base/tooltip', () => ({
|
||||
default: ({
|
||||
children,
|
||||
popupContent,
|
||||
}: {
|
||||
children?: ReactNode
|
||||
popupContent?: ReactNode
|
||||
}) => (
|
||||
<div>
|
||||
{children}
|
||||
{popupContent}
|
||||
</div>
|
||||
),
|
||||
}))
|
||||
|
||||
vi.mock('../confirm-modal', () => ({
|
||||
default: ({ show, onClose, onConfirm }: { show: boolean, onClose: () => void, onConfirm: () => void }) => (
|
||||
show
|
||||
|
||||
@ -23,21 +23,6 @@ const {
|
||||
},
|
||||
}))
|
||||
|
||||
vi.mock('@/app/components/base/tooltip', () => ({
|
||||
default: ({
|
||||
children,
|
||||
popupContent,
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
popupContent: React.ReactNode
|
||||
}) => (
|
||||
<div>
|
||||
<span>{popupContent}</span>
|
||||
{children}
|
||||
</div>
|
||||
),
|
||||
}))
|
||||
|
||||
vi.mock('@/service/use-plugins', () => ({
|
||||
useFeaturedToolsRecommendations: () => ({
|
||||
plugins: [],
|
||||
@ -121,11 +106,13 @@ describe('Tabs', () => {
|
||||
filterElem: <div>filter</div>,
|
||||
}
|
||||
|
||||
it('should render start content and disabled tab tooltip text', () => {
|
||||
it('should render start content and disabled tab tooltip text', async () => {
|
||||
const user = userEvent.setup()
|
||||
render(<Tabs {...baseProps} />)
|
||||
|
||||
expect(screen.getByText('start-content'))!.toBeInTheDocument()
|
||||
expect(screen.getByText('workflow.tabs.startDisabledTip'))!.toBeInTheDocument()
|
||||
await user.hover(screen.getByText('Blocks'))
|
||||
expect(await screen.findByText('workflow.tabs.startDisabledTip'))!.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should switch tabs through click handlers and render tools content with normalized icons', () => {
|
||||
|
||||
@ -1,25 +1,10 @@
|
||||
import type { QuestionClassifierNodeType, Topic } from '../types'
|
||||
import { render, screen } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { useTextGenerationCurrentProviderAndModelAndModelList } from '@/app/components/header/account-setting/model-provider-page/hooks'
|
||||
import { BlockEnum } from '@/app/components/workflow/types'
|
||||
import Node from '../node'
|
||||
|
||||
vi.mock('@/app/components/base/tooltip', () => ({
|
||||
__esModule: true,
|
||||
default: ({
|
||||
children,
|
||||
popupContent,
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
popupContent: React.ReactNode
|
||||
}) => (
|
||||
<div>
|
||||
{children}
|
||||
{popupContent}
|
||||
</div>
|
||||
),
|
||||
}))
|
||||
|
||||
vi.mock('@/app/components/header/account-setting/model-provider-page/hooks', () => ({
|
||||
useTextGenerationCurrentProviderAndModelAndModelList: vi.fn(),
|
||||
}))
|
||||
@ -101,7 +86,8 @@ describe('question-classifier/node', () => {
|
||||
expect(screen.getByText('handle-topic-2')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('returns nothing when neither model nor classes are configured and truncates long class names', () => {
|
||||
it('returns nothing when neither model nor classes are configured and truncates long class names', async () => {
|
||||
const user = userEvent.setup()
|
||||
const longName = 'L'.repeat(60)
|
||||
const { container, rerender } = render(
|
||||
<Node
|
||||
@ -119,7 +105,8 @@ describe('question-classifier/node', () => {
|
||||
)
|
||||
|
||||
expect(screen.getByText(`${longName.slice(0, 50)}...`)).toBeInTheDocument()
|
||||
expect(screen.getByText(longName)).toBeInTheDocument()
|
||||
await user.hover(screen.getByRole('button', { name: longName }))
|
||||
expect(await screen.findByText(longName)).toBeInTheDocument()
|
||||
|
||||
rerender(
|
||||
<Node
|
||||
|
||||
@ -94,10 +94,6 @@ vi.mock('@/app/components/base/input-with-copy', () => ({
|
||||
),
|
||||
}))
|
||||
|
||||
vi.mock('@/app/components/base/tooltip', () => ({
|
||||
default: ({ children }: { children: React.ReactNode }) => <>{children}</>,
|
||||
}))
|
||||
|
||||
vi.mock('@/app/components/workflow/nodes/_base/components/field', () => ({
|
||||
default: ({ title, children }: { title: string, children: React.ReactNode }) => (
|
||||
<div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user