7e8f4859cd
- Add ADR-036 unified OCR architecture (typhoon-ocr via Ollama) - Extend AI execution profiles for OCR sandbox configuration - Add comprehensive frontend test coverage (components, hooks, services) - Add backend test coverage for document-numbering services - Update OCR sidecar with typhoon-ocr integration - Add AI policy service and execution profile management - Update AGENTS.md and architecture documentation
46 lines
1.8 KiB
TypeScript
46 lines
1.8 KiB
TypeScript
// File: frontend/components/common/__tests__/workflow-error-boundary.test.tsx
|
|
// Change Log:
|
|
// - 2026-06-13: Initial creation - test coverage for WorkflowErrorBoundary component
|
|
|
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
import { render, screen } from '@testing-library/react';
|
|
import { WorkflowErrorBoundary } from '../workflow-error-boundary';
|
|
|
|
const ProblematicComponent = () => {
|
|
throw new Error('Test crash error');
|
|
};
|
|
|
|
describe('WorkflowErrorBoundary Component', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
});
|
|
|
|
it('ควรเรนเดอร์ children ตามปกติเมื่อไม่มีข้อผิดพลาด', () => {
|
|
render(
|
|
<WorkflowErrorBoundary>
|
|
<div>Safe Content</div>
|
|
</WorkflowErrorBoundary>
|
|
);
|
|
expect(screen.getByText('Safe Content')).toBeInTheDocument();
|
|
});
|
|
|
|
it('ควรเรนเดอร์ default message เมื่อตรวจพบข้อผิดพลาดใน Component ย่อย', () => {
|
|
render(
|
|
<WorkflowErrorBoundary>
|
|
<ProblematicComponent />
|
|
</WorkflowErrorBoundary>
|
|
);
|
|
expect(screen.getByText('เกิดข้อผิดพลาด ไม่สามารถแสดง Workflow ได้ กรุณารีเฟรชหน้า')).toBeInTheDocument();
|
|
});
|
|
|
|
it('ควรเรนเดอร์ custom fallback เมื่อตรวจพบข้อผิดพลาดและส่ง fallback มาให้', () => {
|
|
render(
|
|
<WorkflowErrorBoundary fallback={<div>Custom Error Alert</div>}>
|
|
<ProblematicComponent />
|
|
</WorkflowErrorBoundary>
|
|
);
|
|
expect(screen.getByText('Custom Error Alert')).toBeInTheDocument();
|
|
});
|
|
});
|