mirror of
https://github.com/langgenius/dify.git
synced 2026-06-17 06:21:07 +08:00
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: fatelei <fatelei@gmail.com> Co-authored-by: Asuka Minato <i@asukaminato.eu.org> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com> Co-authored-by: gigglewang <gigglewang@dify.ai> Co-authored-by: Yunlu Wen <yunlu.wen@dify.ai> Co-authored-by: chariri <w@chariri.moe> Co-authored-by: Evan <2869018789@qq.com> Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com>
60 lines
2.1 KiB
TypeScript
60 lines
2.1 KiB
TypeScript
import { render, screen } from '@testing-library/react'
|
|
import * as React from 'react'
|
|
import Empty from '../empty'
|
|
|
|
const defaultMessage = 'workflow.tabs.noSnippetsFound'
|
|
|
|
describe('Empty', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
})
|
|
|
|
describe('Rendering', () => {
|
|
it('should render without crashing', () => {
|
|
render(<Empty message={defaultMessage} />)
|
|
expect(screen.getByText(defaultMessage)).toBeInTheDocument()
|
|
})
|
|
|
|
it('should render 16 placeholder cards', () => {
|
|
const { container } = render(<Empty message={defaultMessage} />)
|
|
const placeholderCards = container.querySelectorAll('.bg-background-default-lighter')
|
|
expect(placeholderCards).toHaveLength(16)
|
|
})
|
|
|
|
it('should display the no apps found message', () => {
|
|
render(<Empty />)
|
|
expect(screen.getByText('app.filterEmpty.noApps')).toBeInTheDocument()
|
|
})
|
|
|
|
it('should display the provided message', () => {
|
|
render(<Empty message="app.newApp.noAppsFound" />)
|
|
expect(screen.getByText('app.newApp.noAppsFound')).toBeInTheDocument()
|
|
})
|
|
})
|
|
|
|
describe('Styling', () => {
|
|
it('should have correct container styling for overlay', () => {
|
|
const { container } = render(<Empty message={defaultMessage} />)
|
|
const overlay = container.querySelector('.pointer-events-none')
|
|
expect(overlay).toBeInTheDocument()
|
|
expect(overlay).toHaveClass('absolute', 'inset-0', 'z-20', 'grid', 'grid-cols-4')
|
|
})
|
|
|
|
it('should have correct styling for placeholder cards', () => {
|
|
const { container } = render(<Empty message={defaultMessage} />)
|
|
const card = container.querySelector('.bg-background-default-lighter')
|
|
expect(card).toHaveClass('rounded-xl', 'opacity-75')
|
|
})
|
|
})
|
|
|
|
describe('Edge Cases', () => {
|
|
it('should handle multiple renders without issues', () => {
|
|
const { rerender } = render(<Empty message={defaultMessage} />)
|
|
expect(screen.getByText(defaultMessage)).toBeInTheDocument()
|
|
|
|
rerender(<Empty message="app.newApp.noAppsFound" />)
|
|
expect(screen.getByText('app.newApp.noAppsFound')).toBeInTheDocument()
|
|
})
|
|
})
|
|
})
|