Run playwright UI tests
This commit is contained in:
@@ -1,137 +1,7 @@
|
||||
import { describe, expect, it } from 'bun:test';
|
||||
import { __financialStatementsInternals } from './financial-statements';
|
||||
import type { FilingStatementSnapshotRecord } from '@/lib/server/repos/filing-statements';
|
||||
|
||||
function sampleSnapshot(): FilingStatementSnapshotRecord {
|
||||
return {
|
||||
id: 10,
|
||||
filing_id: 44,
|
||||
ticker: 'MSFT',
|
||||
filing_date: '2025-12-31',
|
||||
filing_type: '10-K',
|
||||
period_end: '2025-12-31',
|
||||
statement_bundle: {
|
||||
periods: [
|
||||
{
|
||||
id: '2025-12-31-0001',
|
||||
filingId: 44,
|
||||
accessionNumber: '0001',
|
||||
filingDate: '2025-12-31',
|
||||
periodEnd: '2025-12-31',
|
||||
filingType: '10-K',
|
||||
periodLabel: 'Fiscal Year End'
|
||||
}
|
||||
],
|
||||
statements: {
|
||||
income: [
|
||||
{
|
||||
key: 'revenue-line',
|
||||
label: 'Revenue',
|
||||
concept: 'us-gaap:Revenues',
|
||||
order: 1,
|
||||
depth: 0,
|
||||
isSubtotal: false,
|
||||
values: { '2025-12-31-0001': 120_000 }
|
||||
}
|
||||
],
|
||||
balance: [],
|
||||
cash_flow: [],
|
||||
equity: [],
|
||||
comprehensive_income: []
|
||||
}
|
||||
},
|
||||
standardized_bundle: {
|
||||
periods: [
|
||||
{
|
||||
id: '2025-12-31-0001',
|
||||
filingId: 44,
|
||||
accessionNumber: '0001',
|
||||
filingDate: '2025-12-31',
|
||||
periodEnd: '2025-12-31',
|
||||
filingType: '10-K',
|
||||
periodLabel: 'Fiscal Year End'
|
||||
}
|
||||
],
|
||||
statements: {
|
||||
income: [
|
||||
{
|
||||
key: 'revenue',
|
||||
label: 'Revenue',
|
||||
concept: 'us-gaap:Revenues',
|
||||
category: 'core',
|
||||
sourceConcepts: ['us-gaap:Revenues'],
|
||||
values: { '2025-12-31-0001': 120_000 }
|
||||
}
|
||||
],
|
||||
balance: [],
|
||||
cash_flow: [],
|
||||
equity: [],
|
||||
comprehensive_income: []
|
||||
}
|
||||
},
|
||||
dimension_bundle: {
|
||||
statements: {
|
||||
income: [
|
||||
{
|
||||
rowKey: 'revenue-line',
|
||||
concept: 'us-gaap:Revenues',
|
||||
periodId: '2025-12-31-0001',
|
||||
axis: 'srt:StatementBusinessSegmentsAxis',
|
||||
member: 'acme:CloudMember',
|
||||
value: 55_000,
|
||||
unit: 'USD'
|
||||
}
|
||||
],
|
||||
balance: [],
|
||||
cash_flow: [],
|
||||
equity: [],
|
||||
comprehensive_income: []
|
||||
}
|
||||
},
|
||||
parse_status: 'ready',
|
||||
parse_error: null,
|
||||
source: 'sec_filing_summary',
|
||||
created_at: '2026-01-01T00:00:00.000Z',
|
||||
updated_at: '2026-01-01T00:00:00.000Z'
|
||||
};
|
||||
}
|
||||
|
||||
describe('financial statements service internals', () => {
|
||||
it('builds sorted periods for selected mode/statement', () => {
|
||||
const snapshot = sampleSnapshot();
|
||||
|
||||
const periods = __financialStatementsInternals.buildPeriods(
|
||||
[snapshot],
|
||||
'standardized',
|
||||
'income'
|
||||
);
|
||||
|
||||
expect(periods.length).toBe(1);
|
||||
expect(periods[0]?.id).toBe('2025-12-31-0001');
|
||||
});
|
||||
|
||||
it('builds standardized rows and includes dimensions when requested', () => {
|
||||
const snapshot = sampleSnapshot();
|
||||
const periods = __financialStatementsInternals.buildPeriods(
|
||||
[snapshot],
|
||||
'standardized',
|
||||
'income'
|
||||
);
|
||||
|
||||
const result = __financialStatementsInternals.buildRows(
|
||||
[snapshot],
|
||||
periods,
|
||||
'standardized',
|
||||
'income',
|
||||
true
|
||||
);
|
||||
|
||||
expect(result.rows.length).toBe(1);
|
||||
expect(result.rows[0]?.hasDimensions).toBe(true);
|
||||
expect(result.dimensions).not.toBeNull();
|
||||
expect(result.dimensions?.['revenue-line']?.length).toBe(1);
|
||||
});
|
||||
|
||||
it('returns default sync limits by window', () => {
|
||||
expect(__financialStatementsInternals.defaultFinancialSyncLimit('10y')).toBe(60);
|
||||
expect(__financialStatementsInternals.defaultFinancialSyncLimit('all')).toBe(120);
|
||||
|
||||
Reference in New Issue
Block a user