feat(ai): add ADR-036 unified OCR architecture and frontend test coverage
- 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:
@@ -0,0 +1,47 @@
|
||||
// File: frontend/lib/services/__tests__/audit-log.service.test.ts
|
||||
// Change Log:
|
||||
// - 2026-06-13: Initial creation - test coverage for auditLogService
|
||||
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import apiClient from '@/lib/api/client';
|
||||
import { auditLogService } from '../audit-log.service';
|
||||
|
||||
describe('auditLogService', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('getLogs', () => {
|
||||
it('ควรดึงข้อมูล audit logs รูปแบบอาร์เรย์ได้อย่างถูกต้อง', async () => {
|
||||
const mockLogs = [
|
||||
{
|
||||
publicId: '019505a1-7c3e-7000-8000-audit1111111',
|
||||
auditId: 'AUD-001',
|
||||
action: 'LOGIN',
|
||||
severity: 'INFO',
|
||||
createdAt: '2026-06-13T00:00:00.000Z',
|
||||
},
|
||||
];
|
||||
vi.mocked(apiClient.get).mockResolvedValue({ data: mockLogs });
|
||||
const result = await auditLogService.getLogs();
|
||||
expect(apiClient.get).toHaveBeenCalledWith('/audit-logs', { params: undefined });
|
||||
expect(result).toEqual(mockLogs);
|
||||
});
|
||||
|
||||
it('ควรดึงข้อมูล audit logs รูปแบบ data wrapper ได้อย่างถูกต้อง', async () => {
|
||||
const mockLogs = [
|
||||
{
|
||||
publicId: '019505a1-7c3e-7000-8000-audit1111111',
|
||||
auditId: 'AUD-001',
|
||||
action: 'LOGIN',
|
||||
severity: 'INFO',
|
||||
createdAt: '2026-06-13T00:00:00.000Z',
|
||||
},
|
||||
];
|
||||
vi.mocked(apiClient.get).mockResolvedValue({ data: { data: mockLogs } });
|
||||
const result = await auditLogService.getLogs({ search: 'login' });
|
||||
expect(apiClient.get).toHaveBeenCalledWith('/audit-logs', { params: { search: 'login' } });
|
||||
expect(result).toEqual(mockLogs);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user