chore: strengthen backend eslint profile

This commit is contained in:
2026-09-28 16:37:01 +03:00
committed by ksv741
parent 53b2794963
commit a970eaaf7a
179 changed files with 4485 additions and 2716 deletions
+21 -14
View File
@@ -1,18 +1,21 @@
import assert from 'node:assert/strict';
import type { Server } from 'node:http';
import { INestApplication } from '@nestjs/common';
import { JwtService } from '@nestjs/jwt';
import { Test } from '@nestjs/testing';
import assert from 'node:assert/strict';
import { setTimeout as delay } from 'node:timers/promises';
import type { Server } from 'node:http';
import request from 'supertest';
import type { IncomeAnalyticsResourceDto } from '../src/modules/investments/income/income-analytics.dto';
import { AppModule } from '../src/app.module';
import { configureApp } from '../src/main';
import { PrismaService } from '../src/prisma/prisma.service';
import { InstrumentMetadataRepository } from '../src/integrations/tbank/instrument-metadata.repository';
import { TbankClient } from '../src/integrations/tbank/tbank.client';
import { BrokerageOperationsResourceDto } from '../src/modules/investments/operations/presentation/brokerage-operation.dto';
import { configureApp } from '../src/main';
import { BrokerageOperationsRepository } from '../src/modules/investments/operations/infrastructure/brokerage-operations.repository';
import type { IncomeAnalyticsResourceDto } from '../src/modules/investments/income/income-analytics.dto';
import { BrokerageOperationsResourceDto } from '../src/modules/investments/operations/presentation/brokerage-operation.dto';
import { PrismaService } from '../src/prisma/prisma.service';
const uid = '11111111-1111-4111-8111-111111111111';
const period = 'from=2025-01-01&to=2025-01-31';
@@ -48,10 +51,11 @@ describe('persistent ledger HTTP and cursor (SQLite)', () => {
await app.init();
await app.listen(0, '127.0.0.1');
prisma = app.get(PrismaService);
for (const id of ['owner', 'other'])
for (const id of ['owner', 'other']) {
await prisma.user.create({
data: { id, email: `${id}@example.invalid`, passwordHash: 'synthetic' },
});
}
});
afterAll(async () => app?.close());
beforeEach(async () => {
@@ -84,7 +88,7 @@ describe('persistent ledger HTTP and cursor (SQLite)', () => {
fetchedAt: new Date(),
},
});
for (const id of ['1', '2', '3'])
for (const id of ['1', '2', '3']) {
await prisma.tbankOperation.create({
data: {
userId: 'owner',
@@ -103,10 +107,11 @@ describe('persistent ledger HTTP and cursor (SQLite)', () => {
},
},
});
}
}
});
it('reads ordered pages with identical IDs/timestamps across accounts and no upstream RPC, including after reopen', async () => {
let cursor: string | null = null;
let cursor: null | string = null;
const ids: string[] = [];
do {
const response = await get(
@@ -186,7 +191,7 @@ describe('persistent ledger HTTP and cursor (SQLite)', () => {
})),
).toEqual(expected);
const items: { id: string; occurredAt: string }[] = [];
let cursor: string | null = null;
let cursor: null | string = null;
do {
const response = await request(app.getHttpServer())
.get(
@@ -235,9 +240,9 @@ describe('persistent ledger HTTP and cursor (SQLite)', () => {
data: { occurredAt: new Date(observedAt.valueOf() - 1000) },
});
const query =
periodKind === 'default'
? ''
: `&to=${observedAt.toISOString().slice(0, 10)}${periodKind === 'today timestamp' ? 'T23:59:59.999Z' : ''}`;
periodKind === 'default' ?
'' :
`&to=${observedAt.toISOString().slice(0, 10)}${periodKind === 'today timestamp' ? 'T23:59:59.999Z' : ''}`;
const page = (cursor?: string, observe = false) =>
request(app.getHttpServer())
.get(
@@ -418,10 +423,12 @@ describe('persistent ledger HTTP and cursor (SQLite)', () => {
expect(cold.meta.availability).toBe('missing');
await get('sync=observe', 'a').expect(200);
expect(upstream.getOperationsByCursor).toHaveBeenCalledTimes(1);
// eslint-disable-next-line sonarjs/no-extra-arguments -- The typed callback is assigned the promise resolver before invocation.
unblock({ hasNext: false, items: [] });
for (let index = 0; index < 300; index += 1) {
if (!(await prisma.tbankSyncWork.count({ where: { state: 'running' } })))
if (!(await prisma.tbankSyncWork.count({ where: { state: 'running' } }))) {
break;
}
await delay(5);
}
const count = upstream.getOperationsByCursor.mock.calls.length;