CI (SIAX Cloud) / integration (push) Skipped
CI (SIAX Cloud) / sonar (push) Skipped
masterplan-lock / check (push) Successful in 5s
Security Scan (SIAX Cloud) / security (push) Successful in 15s
CI (SIAX Cloud) / security (push) Successful in 16s
CI (SIAX Cloud) / sonar (pull_request) Skipped
masterplan-lock / check (pull_request) Successful in 7s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 21s
CI (SIAX Cloud) / security (pull_request) Successful in 25s
CI (SIAX Cloud) / quality (push) Successful in 1m17s
CI (SIAX Cloud) / integration (pull_request) Successful in 54s
CI (SIAX Cloud) / quality (pull_request) Successful in 1m7s
26 lines
1.3 KiB
TypeScript
26 lines
1.3 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest';
|
|
import { DocumentCaptureService } from '@/src/services/document-capture-service';
|
|
import { DocumentExtractionService } from '@/src/services/document-extraction-service';
|
|
|
|
describe('document extraction scope', () => {
|
|
it.each([
|
|
{ tenant_id: 'tenant-b', project_id: 'project-a' },
|
|
{ tenant_id: 'tenant-a', project_id: 'project-b' },
|
|
])('rejects an out-of-scope document before any byte read or external call', async (scope) => {
|
|
const capture = new DocumentCaptureService();
|
|
vi.spyOn(capture, 'getDocument').mockResolvedValue({ tenant_id: 'tenant-a', project_id: 'project-a' } as never);
|
|
const bytes = vi.spyOn(capture, 'getDocumentBytes');
|
|
const fetchMock = vi.fn();
|
|
vi.stubGlobal('fetch', fetchMock);
|
|
try {
|
|
const service = new DocumentExtractionService(capture, {
|
|
documentIntelligence: { endpoint: 'https://di.example.test', apiKey: 'test-key' },
|
|
});
|
|
await expect(service.extractDocument('doc', { ...scope, actor_id: 'actor-a', correlation_id: 'corr', model_id: 'test' }))
|
|
.rejects.toThrow('Document doc not found');
|
|
expect(bytes).not.toHaveBeenCalled();
|
|
expect(fetchMock).not.toHaveBeenCalled();
|
|
} finally { vi.unstubAllGlobals(); vi.restoreAllMocks(); }
|
|
});
|
|
});
|