refactor!: support RUB only (WealthLedger/main#55) (#204)
BREAKING CHANGE: per-currency API fields replaced with single RUB Money.
This commit was merged in pull request #204.
This commit is contained in:
@@ -16,18 +16,15 @@ describe('portfolio publication (SQLite)', () => {
|
||||
const snapshot = {
|
||||
lastSuccessfulAt: '2026-01-01T00:00:00.000Z',
|
||||
isStale: false,
|
||||
totalsByCurrency: [],
|
||||
totals: { currency: 'RUB', value: '0' },
|
||||
positions: [],
|
||||
cashBalances: [],
|
||||
structure: { currencies: [], unvaluedCategories: [] },
|
||||
cash: { currency: 'RUB', value: '0' },
|
||||
structure: { totalValue: '0', hasNegativeValues: false, categories: [], unvaluedCategories: [] },
|
||||
} satisfies PortfolioDto;
|
||||
const accountId = 'account';
|
||||
const valuedSnapshot = {
|
||||
...snapshot,
|
||||
totalsByCurrency: [
|
||||
{ currency: 'RUB', value: '200' },
|
||||
{ currency: 'USD', value: '10' },
|
||||
],
|
||||
totals: { currency: 'RUB', value: '200' },
|
||||
} satisfies PortfolioDto;
|
||||
const createRunningAttempt = () =>
|
||||
prisma.tbankSyncWork.create({
|
||||
@@ -95,7 +92,7 @@ describe('portfolio publication (SQLite)', () => {
|
||||
expect(await prisma.tbankPortfolio.count()).toBe(1);
|
||||
});
|
||||
|
||||
it('rolls back the snapshot, first value point and claim when the second point fails', async () => {
|
||||
it('rolls back the snapshot, value point and claim when the point write fails', async () => {
|
||||
const previousFetchedAt = new Date('2025-12-31T00:00:00.000Z');
|
||||
const previousCapturedAt = new Date('2025-12-31T01:00:00.000Z');
|
||||
await prisma.tbankPortfolio.create({
|
||||
@@ -114,7 +111,6 @@ describe('portfolio publication (SQLite)', () => {
|
||||
points: {
|
||||
create: {
|
||||
attemptId: 'previous-attempt',
|
||||
currency: 'RUB',
|
||||
value: '100',
|
||||
capturedAt: previousCapturedAt,
|
||||
},
|
||||
@@ -123,11 +119,9 @@ describe('portfolio publication (SQLite)', () => {
|
||||
});
|
||||
await createRunningAttempt();
|
||||
interceptTransaction((tx) => {
|
||||
const upsert = tx.tbankPortfolioValuePoint.upsert.bind(tx.tbankPortfolioValuePoint);
|
||||
jest
|
||||
.spyOn(tx.tbankPortfolioValuePoint, 'upsert')
|
||||
.mockImplementationOnce((args) => upsert(args))
|
||||
.mockRejectedValueOnce(new Error('injected second point failure'));
|
||||
.mockRejectedValueOnce(new Error('injected point failure'));
|
||||
});
|
||||
|
||||
await expect(
|
||||
@@ -136,7 +130,7 @@ describe('portfolio publication (SQLite)', () => {
|
||||
accountId,
|
||||
valuedSnapshot,
|
||||
),
|
||||
).rejects.toThrow('injected second point failure');
|
||||
).rejects.toThrow('injected point failure');
|
||||
|
||||
expect(
|
||||
await prisma.tbankPortfolio.findUnique({
|
||||
|
||||
Reference in New Issue
Block a user