58 lines
1.9 KiB
TypeScript
58 lines
1.9 KiB
TypeScript
import { describe, expect, it } from 'bun:test';
|
|
import type { Filing } from '@/lib/types';
|
|
import { redactInternalFilingAnalysisFields } from './filing-redaction';
|
|
|
|
function filingWithExtraction(): Filing {
|
|
return {
|
|
id: 7,
|
|
ticker: 'MSFT',
|
|
filing_type: '10-K',
|
|
filing_date: '2026-02-01',
|
|
accession_number: '0000789019-26-000001',
|
|
cik: '0000789019',
|
|
company_name: 'Microsoft Corporation',
|
|
filing_url: 'https://www.sec.gov/Archives/edgar/data/789019/000078901926000001/a10k.htm',
|
|
submission_url: null,
|
|
primary_document: 'a10k.htm',
|
|
metrics: null,
|
|
analysis: {
|
|
provider: 'zhipu',
|
|
model: 'glm-4.7-flashx',
|
|
text: 'Report text',
|
|
extraction: {
|
|
summary: 'Internal extraction summary',
|
|
keyPoints: ['a'],
|
|
redFlags: ['b'],
|
|
followUpQuestions: ['c'],
|
|
portfolioSignals: ['d'],
|
|
segmentSpecificData: ['e'],
|
|
geographicRevenueBreakdown: ['f'],
|
|
companySpecificData: ['g'],
|
|
secApiCrossChecks: ['h'],
|
|
confidence: 0.4
|
|
},
|
|
extractionMeta: {
|
|
provider: 'ollama',
|
|
model: 'qwen3:8b',
|
|
source: 'primary_document',
|
|
generatedAt: '2026-02-01T00:00:00.000Z'
|
|
}
|
|
},
|
|
created_at: '2026-02-01T00:00:00.000Z',
|
|
updated_at: '2026-02-01T00:00:00.000Z'
|
|
};
|
|
}
|
|
|
|
describe('filing response redaction', () => {
|
|
it('removes internal extraction fields while preserving public fields and company metrics', () => {
|
|
const redacted = redactInternalFilingAnalysisFields(filingWithExtraction());
|
|
|
|
expect(redacted.analysis?.provider).toBe('zhipu');
|
|
expect(redacted.analysis?.model).toBe('glm-4.7-flashx');
|
|
expect(redacted.analysis?.text).toBe('Report text');
|
|
expect(redacted.analysis?.companyMetrics).toEqual(['g']);
|
|
expect(redacted.analysis?.extraction).toBeUndefined();
|
|
expect(redacted.analysis?.extractionMeta).toBeUndefined();
|
|
});
|
|
});
|