mirror of
https://github.com/langgenius/dify.git
synced 2026-05-02 16:38:04 +08:00
- Introduced new test files for DocumentList, IndexingProgressItem, RuleDetail, UpgradeBanner, and various utility functions related to the embedding process. - Enhanced test coverage by validating rendering, user interactions, and edge cases for each component. - Ensured proper functionality of user interactions, such as button clicks and state changes, as well as validation of parameters in hooks and utilities. These additions improve the reliability and maintainability of the embedding process and website features.
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import { render, screen } from '@testing-library/react'
|
|
import { describe, expect, it, vi } from 'vitest'
|
|
import ErrorMessage from './error-message'
|
|
|
|
vi.mock('@/app/components/base/icons/src/vender/solid/alertsAndFeedback', () => ({
|
|
AlertTriangle: (props: React.SVGProps<SVGSVGElement>) => <svg data-testid="alert-icon" {...props} />,
|
|
}))
|
|
|
|
describe('ErrorMessage', () => {
|
|
it('should render title', () => {
|
|
render(<ErrorMessage title="Something went wrong" />)
|
|
expect(screen.getByText('Something went wrong')).toBeInTheDocument()
|
|
})
|
|
|
|
it('should render error message when provided', () => {
|
|
render(<ErrorMessage title="Error" errorMsg="Detailed error info" />)
|
|
expect(screen.getByText('Detailed error info')).toBeInTheDocument()
|
|
})
|
|
|
|
it('should not render error message when not provided', () => {
|
|
render(<ErrorMessage title="Error" />)
|
|
expect(screen.queryByText('Detailed error info')).not.toBeInTheDocument()
|
|
})
|
|
|
|
it('should render alert icon', () => {
|
|
render(<ErrorMessage title="Error" />)
|
|
expect(screen.getByTestId('alert-icon')).toBeInTheDocument()
|
|
})
|
|
})
|