Files
backend/src/modules/investments/tbank-sync/tbank-screen.spec.ts
T
ksv741 d6e6c4ace5
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
feat!: persist T-Bank data and synchronize reads
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.
2026-09-26 21:29:15 +03:00

66 lines
1.9 KiB
TypeScript

import { normalizeScreen } from './tbank-screen';
describe('manual sync screen boundary', () => {
it('normalizes equivalent descriptors to the same scope', () => {
expect(normalizeScreen({ screen: 'stocks', query: ' sber ' })).toEqual({
screen: 'stocks',
query: 'SBER',
});
expect(
JSON.stringify(
normalizeScreen({
screen: 'operations',
accountId: 'a',
categories: ['tax', 'income', 'tax'],
limit: 20,
}),
),
).toBe(
JSON.stringify(
normalizeScreen({
limit: 20,
categories: ['income', 'tax'],
accountId: 'a',
screen: 'operations',
}),
),
);
});
it('rejects missing identities and fields that would expand another screen', () => {
for (const scope of [
{ screen: 'accounts', accountId: 'a' },
{ screen: 'account' },
{ screen: 'stock' },
{ screen: 'stocks', query: ' ' },
{ screen: 'events', accountId: 'a', instrumentUid: 'uid' },
{ screen: 'income', accountId: 'a', from: '2026-01-01' },
{
screen: 'events',
accountId: 'a',
from: '2026-02-01',
to: '2026-01-01',
},
] as Parameters<typeof normalizeScreen>[0][])
expect(() => normalizeScreen(scope)).toThrow();
});
it('retains inclusive calendar days, rejecting instant values for date-only owners', () => {
const scope = {
screen: 'events' as const,
accountId: 'all',
from: '2026-01-01',
to: '2026-01-01',
};
expect(normalizeScreen(scope)).toEqual(scope);
expect(() =>
normalizeScreen({ ...scope, from: '2026-01-01T00:00:00Z' }),
).toThrow();
expect(() =>
normalizeScreen({
screen: 'stock',
instrumentUid: 'uid',
candleRange: { from: '2026-01-02', to: '2026-01-01' },
}),
).toThrow();
});
});