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
+25 -11
View File
@@ -3,15 +3,17 @@ import { fork } from 'node:child_process';
import { once } from 'node:events';
import { join } from 'node:path';
import { setTimeout as delay } from 'node:timers/promises';
import { PrismaService } from '../src/prisma/prisma.service';
import { TbankAccessService } from '../src/integrations/tbank/tbank-access.service';
import type {
TbankOperationsByCursorRequest,
TbankOperationsByCursorResponse,
} from '../src/integrations/tbank/tbank.client';
import { TbankAccessService } from '../src/integrations/tbank/tbank-access.service';
import { TbankTokenService } from '../src/integrations/tbank/tbank-token.service';
import { BrokerageOperationsRepository } from '../src/modules/investments/operations/infrastructure/brokerage-operations.repository';
import { BrokerageOperationsSyncService } from '../src/modules/investments/operations/application/brokerage-operations-sync.service';
import { BrokerageOperationsRepository } from '../src/modules/investments/operations/infrastructure/brokerage-operations.repository';
import { PrismaService } from '../src/prisma/prisma.service';
function deferred<T>() {
let resolve: (value: T) => void = () => {
@@ -154,11 +156,12 @@ describe('Request-driven operations synchronization (SQLite)', () => {
upstream.getOperationsByCursor
.mockReturnValueOnce(gate.promise)
.mockImplementation((_token, request) => {
if (Number(request.from?.seconds) + 1 === march.from.valueOf() / 1000)
if (Number(request.from?.seconds) + 1 === march.from.valueOf() / 1000) {
return Promise.resolve({
hasNext: false,
items: [operation('20', '1773000000')],
});
}
return Promise.reject(new Error('unrelated history unavailable'));
});
const history = requiredHandle(
@@ -332,8 +335,9 @@ describe('Request-driven operations synchronization (SQLite)', () => {
if (
failFebruary &&
request.from?.seconds === String(february.from.valueOf() / 1000 - 1)
)
) {
return Promise.reject(new Error('Second month unavailable'));
}
return Promise.resolve({
hasNext: false,
items: [
@@ -431,22 +435,29 @@ describe('Request-driven operations synchronization (SQLite)', () => {
await delay(10);
expect(upstream.getOperationsByCursor).not.toHaveBeenCalled();
if (checkpoint === 'after-publish') {
// eslint-disable-next-line jest/no-conditional-expect -- The parameterized fixture chooses the scenario; each branch asserts its outcome and the test also asserts common invariants.
expect(await prisma.tbankOperation.count()).toBe(1);
// eslint-disable-next-line jest/no-conditional-expect -- The parameterized fixture chooses the scenario; each branch asserts its outcome and the test also asserts common invariants.
expect(await prisma.tbankSyncStage.count()).toBe(0);
} else {
// eslint-disable-next-line jest/no-conditional-expect -- The parameterized fixture chooses the scenario; each branch asserts its outcome and the test also asserts common invariants.
expect(await prisma.tbankOperation.count()).toBe(0);
// eslint-disable-next-line jest/no-conditional-expect -- The parameterized fixture chooses the scenario; each branch asserts its outcome and the test also asserts common invariants.
expect(await prisma.tbankSyncStage.count()).toBeGreaterThan(0);
upstream.getOperationsByCursor.mockResolvedValueOnce(complete);
await service.request('owner', [january], true);
await state(handle, 'complete');
// eslint-disable-next-line jest/no-conditional-expect -- The parameterized fixture chooses the scenario; each branch asserts its outcome and the test also asserts common invariants.
expect(
upstream.getOperationsByCursor.mock.calls[0][1].cursor,
).toBeUndefined();
// eslint-disable-next-line jest/no-conditional-expect -- The parameterized fixture chooses the scenario; each branch asserts its outcome and the test also asserts common invariants.
expect(await prisma.tbankOperation.count()).toBe(1);
}
} finally {
if (child.exitCode === null && child.signalCode === null)
if (child.exitCode === null && child.signalCode === null) {
child.kill('SIGKILL');
}
await exited;
}
},
@@ -492,8 +503,9 @@ describe('Request-driven operations synchronization (SQLite)', () => {
let index = 0;
index < 500 && upstream.getOperationsByCursor.mock.calls.length < 2;
index += 1
)
) {
await delay(2);
}
expect(upstream.getOperationsByCursor).toHaveBeenCalledTimes(2);
expect(upstream.getOperationsByCursor.mock.calls[1][1].from).toEqual({
seconds: String(early.to.valueOf() / 1000 - 1),
@@ -507,8 +519,8 @@ describe('Request-driven operations synchronization (SQLite)', () => {
it('lets new screen work overtake history between provider pages', async () => {
const first = deferred<{
hasNext: boolean;
nextCursor: string;
items: never[];
nextCursor: string;
}>();
upstream.getOperationsByCursor
.mockReturnValueOnce(first.promise)
@@ -542,8 +554,9 @@ describe('Request-driven operations synchronization (SQLite)', () => {
let index = 0;
index < 500 && upstream.getOperationsByCursor.mock.calls.length < 2;
index += 1
)
) {
await delay(2);
}
expect(await prisma.tbankOperation.count()).toBe(1);
const before = await prisma.tbankOperationCoverage.findMany();
expect(before).toHaveLength(1);
@@ -675,8 +688,9 @@ describe('Request-driven operations synchronization (SQLite)', () => {
let index = 0;
index < 500 && upstream.getOperationsByCursor.mock.calls.length < 2;
index += 1
)
) {
await delay(2);
}
expect(upstream.getOperationsByCursor).toHaveBeenCalledTimes(2);
const before = await prisma.tbankSyncWork.findUniqueOrThrow({
where: { id: handle },
@@ -708,7 +722,7 @@ describe('Request-driven operations synchronization (SQLite)', () => {
});
});
function requiredHandle(value: string | null): string {
function requiredHandle(value: null | string): string {
if (!value) throw new Error('Expected sync handle');
return value;
}