Backend security / security (push) Successful in 8s
Backend verify / verify (push) Failing after 10m45s
Conventional commits / commits (pull_request) Successful in 29s
Backend security / security (pull_request) Successful in 8s
Backend verify / verify (pull_request) Failing after 10m37s
Store account membership, portfolio, operations, forecasts and market sources in SQLite. Coalesce scoped refreshes, fence connection revisions, preserve complete financial snapshots and stabilize operation period state. BREAKING CHANGE: investment reads return data/meta resource envelopes and locally persisted snapshots; consumers must use the matching OpenAPI contract and explicit synchronization endpoints.
71 lines
2.2 KiB
TypeScript
71 lines
2.2 KiB
TypeScript
jest.mock('../../../prisma/prisma.service', () => ({
|
|
PrismaService: class {},
|
|
}));
|
|
import { BrokerageAccountsService } from './brokerage-accounts.service';
|
|
import { investmentResourceMeta } from '../investment-resource.mapper';
|
|
|
|
jest.mock('../portfolio/application/portfolio.service', () => ({
|
|
PortfolioService: class PortfolioService {},
|
|
}));
|
|
|
|
const meta = investmentResourceMeta({
|
|
resourceKey: 'membership',
|
|
dataRevision: '1',
|
|
availability: 'complete',
|
|
fetchedAt: new Date(),
|
|
freshForMs: 300_000,
|
|
work: null,
|
|
});
|
|
|
|
describe('saved brokerage account projection', () => {
|
|
const portfolio = { saved: jest.fn() };
|
|
const service = new BrokerageAccountsService(portfolio as never);
|
|
|
|
it('distinguishes unknown membership from a confirmed empty list', async () => {
|
|
portfolio.saved.mockResolvedValueOnce({
|
|
membership: { ...meta, availability: 'missing' },
|
|
accounts: [],
|
|
});
|
|
expect((await service.list('owner', true)).data).toBeNull();
|
|
portfolio.saved.mockResolvedValueOnce({ membership: meta, accounts: [] });
|
|
expect((await service.list('owner', true)).data).toEqual([]);
|
|
});
|
|
|
|
it('keeps exact saved totals and independent missing summaries', async () => {
|
|
portfolio.saved.mockResolvedValue({
|
|
membership: meta,
|
|
accounts: [
|
|
{
|
|
id: 'a',
|
|
name: 'A',
|
|
type: 'BROKERAGE',
|
|
openedOn: null,
|
|
meta,
|
|
snapshot: {
|
|
totalsByCurrency: [
|
|
{ currency: 'RUB', value: '100000000.000000001' },
|
|
],
|
|
positions: [{ type: 'STOCK' }, { type: 'BOND' }],
|
|
},
|
|
},
|
|
{
|
|
id: 'b',
|
|
name: 'B',
|
|
type: 'BROKERAGE',
|
|
openedOn: null,
|
|
meta: { ...meta, availability: 'missing' },
|
|
snapshot: null,
|
|
},
|
|
],
|
|
});
|
|
const response = await service.list('owner', true);
|
|
expect(response.data?.[0].portfolioSummary).toEqual({
|
|
totalsByCurrency: [{ currency: 'RUB', value: '100000000.000000001' }],
|
|
stockPositionCount: 1,
|
|
bondPositionCount: 1,
|
|
});
|
|
expect(response.data?.[1].portfolioSummary).toBeNull();
|
|
expect(response.meta.availability).toBe('partial');
|
|
});
|
|
});
|