mirror of
https://github.com/langgenius/dify.git
synced 2026-05-09 12:59:18 +08:00
chore: tests
This commit is contained in:
parent
e5947d518e
commit
d3c8af6aa9
@ -0,0 +1,50 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import { render, screen } from '@testing-library/react'
|
||||
import FileExplorerIntro from './file-explorer-intro'
|
||||
|
||||
vi.mock('react-i18next', () => ({
|
||||
Trans: ({ i18nKey, ns, components }: {
|
||||
i18nKey: string
|
||||
ns?: string
|
||||
components?: Record<string, ReactNode>
|
||||
}) => (
|
||||
<span data-i18n-key={ns ? `${ns}.${i18nKey}` : i18nKey}>
|
||||
<span>Manage uploaded files here</span>
|
||||
{components?.mention}
|
||||
<span>to reference them in prompts.</span>
|
||||
</span>
|
||||
),
|
||||
}))
|
||||
|
||||
describe('FileExplorerIntro', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
describe('Rendering', () => {
|
||||
it('should render translated intro copy with the injected mention chip', () => {
|
||||
render(<FileExplorerIntro />)
|
||||
|
||||
expect(screen.getByText('Manage uploaded files here')).toBeInTheDocument()
|
||||
expect(screen.getByText('to reference them in prompts.')).toBeInTheDocument()
|
||||
expect(screen.getByText('@')).toBeInTheDocument()
|
||||
expect(screen.getByText('Manage uploaded files here').parentElement).toHaveAttribute('data-i18n-key', 'workflow.skill.startTab.fileExplorerIntro')
|
||||
})
|
||||
})
|
||||
|
||||
describe('Presentation', () => {
|
||||
it('should render the intro as a bordered hint bar', () => {
|
||||
const { container } = render(<FileExplorerIntro />)
|
||||
|
||||
expect(container.firstChild).toHaveClass('px-6', 'pb-4', 'pt-4')
|
||||
expect(container.querySelector('p')).toHaveClass(
|
||||
'flex',
|
||||
'h-8',
|
||||
'items-center',
|
||||
'rounded-md',
|
||||
'border',
|
||||
'border-text-accent-secondary',
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
@ -55,13 +55,17 @@ describe('StartTabContent', () => {
|
||||
it('should render create/import actions and template list when mounted', () => {
|
||||
const { container } = render(<StartTabContent />)
|
||||
|
||||
expect(screen.getByText('skill.startTab.fileExplorerIntro')).toBeInTheDocument()
|
||||
expect(screen.getByRole('button', { name: /workflow\.skill\.startTab\.createBlankSkill/i })).toBeInTheDocument()
|
||||
const intro = screen.getByText('skill.startTab.fileExplorerIntro')
|
||||
const createButton = screen.getByRole('button', { name: /workflow\.skill\.startTab\.createBlankSkill/i })
|
||||
|
||||
expect(intro).toBeInTheDocument()
|
||||
expect(createButton).toBeInTheDocument()
|
||||
expect(screen.getByRole('button', { name: /workflow\.skill\.startTab\.importSkill/i })).toBeInTheDocument()
|
||||
expect(screen.getByRole('textbox')).toBeInTheDocument()
|
||||
expect(screen.getByText('workflow.skill.startTab.templatesTitle')).toBeInTheDocument()
|
||||
expect(screen.getByRole('region', { name: 'workflow.skill.startTab.templatesTitle' })).toBeInTheDocument()
|
||||
expect(screen.getAllByRole('button', { name: /workflow\.skill\.startTab\.useThisSkill/i }).length).toBeGreaterThan(0)
|
||||
expect(intro.compareDocumentPosition(createButton) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy()
|
||||
expect(container.firstChild).toHaveClass('flex', 'h-full', 'min-h-0', 'w-full', 'bg-components-panel-bg')
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user