feat(ai): add ADR-036 unified OCR architecture and frontend test coverage
CI / CD Pipeline / build (push) Failing after 6m24s
CI / CD Pipeline / deploy (push) Has been skipped

- 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
This commit is contained in:
2026-06-14 06:34:07 +07:00
parent e3503b6a77
commit 7e8f4859cd
108 changed files with 33914 additions and 339 deletions
@@ -0,0 +1,58 @@
// File: frontend/components/admin/__tests__/sidebar.test.tsx
// Change Log
// - 2026-06-13: Add coverage for admin sidebar navigation and expansion behavior.
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { AdminMobileSidebar, AdminSidebar } from '../sidebar';
const pathnameMock = vi.fn();
vi.mock('next/navigation', () => ({
usePathname: () => pathnameMock(),
}));
vi.mock('next/link', () => ({
default: ({ href, children, onClick, className }: { href: string; children: React.ReactNode; onClick?: () => void; className?: string }) => (
<a href={href} onClick={onClick} className={className}>
{children}
</a>
),
}));
describe('AdminSidebar', () => {
beforeEach(() => {
pathnameMock.mockReturnValue('/admin/access-control/users');
});
it('auto-expands the active menu and renders child links', () => {
render(<AdminSidebar />);
expect(screen.getByText('Admin Console')).toBeInTheDocument();
expect(screen.getByRole('link', { name: 'ผู้ใช้งาน' })).toHaveAttribute('href', '/admin/access-control/users');
expect(screen.getByRole('link', { name: /back to dashboard/i })).toHaveAttribute('href', '/dashboard');
});
it('toggles a collapsed menu on click', async () => {
const user = userEvent.setup();
pathnameMock.mockReturnValue('/admin/settings');
render(<AdminSidebar />);
expect(screen.queryByRole('link', { name: 'โครงการ' })).not.toBeInTheDocument();
await user.click(screen.getByRole('button', { name: /ตั้งค่าโครงการ/i }));
expect(screen.getByRole('link', { name: 'โครงการ' })).toBeInTheDocument();
});
});
describe('AdminMobileSidebar', () => {
beforeEach(() => {
pathnameMock.mockReturnValue('/admin/settings');
});
it('opens mobile navigation from trigger button', async () => {
const user = userEvent.setup();
render(<AdminMobileSidebar />);
await user.click(screen.getByRole('button', { name: 'Toggle admin menu' }));
expect(screen.getByText('Admin Navigation')).toBeInTheDocument();
expect(screen.getByRole('link', { name: /AI Console/i })).toHaveAttribute('href', '/admin/ai');
});
});