Files
dify/web/app/components/datasets/create/website/base/error-message.spec.tsx
CodingOnStar 5e6e8a16ce test: add unit tests for embedding process and website components
- 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.
2026-02-10 16:54:35 +08:00

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()
})
})