chore: strengthen backend eslint profile
This commit is contained in:
@@ -1,23 +1,26 @@
|
||||
import type { Server } from 'node:http';
|
||||
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import type { Server } from 'node:http';
|
||||
import { setTimeout as delay } from 'node:timers/promises';
|
||||
import request from 'supertest';
|
||||
|
||||
import type { BondCouponsResourceDto } from '../src/modules/investments/instruments/bonds/presentation/bond.dto';
|
||||
import type { StockDividendsResourceDto } from '../src/modules/investments/instruments/stocks/presentation/stock.dto';
|
||||
import type { UpcomingEventsResourceDto } from '../src/modules/investments/upcoming-events/upcoming-events.dto';
|
||||
|
||||
import { AppModule } from '../src/app.module';
|
||||
import { configureApp } from '../src/main';
|
||||
import { PrismaService } from '../src/prisma/prisma.service';
|
||||
import { MoexClient } from '../src/integrations/moex/moex.api';
|
||||
import {
|
||||
TbankClient,
|
||||
TbankTokenService,
|
||||
tbankSourceTtlMs,
|
||||
TbankTokenService,
|
||||
} from '../src/integrations/tbank/tbank.api';
|
||||
import { MoexClient } from '../src/integrations/moex/moex.api';
|
||||
import { configureApp } from '../src/main';
|
||||
import { CatalogEnrichmentService } from '../src/modules/investments/instruments/application/catalog-enrichment.service';
|
||||
import { ForecastRepository } from '../src/modules/investments/portfolio/infrastructure/forecast.repository';
|
||||
import type { UpcomingEventsResourceDto } from '../src/modules/investments/upcoming-events/upcoming-events.dto';
|
||||
import type { StockDividendsResourceDto } from '../src/modules/investments/instruments/stocks/presentation/stock.dto';
|
||||
import type { BondCouponsResourceDto } from '../src/modules/investments/instruments/bonds/presentation/bond.dto';
|
||||
import { PrismaService } from '../src/prisma/prisma.service';
|
||||
|
||||
const shareUid = '00000000-0000-4000-8000-000000000001';
|
||||
const bondUid = '00000000-0000-4000-8000-000000000002';
|
||||
@@ -86,8 +89,9 @@ describe('saved payout calendars and complete forecasts (SQLite HTTP)', () => {
|
||||
await delay(10);
|
||||
if (
|
||||
!(await prisma.tbankSyncWork.count({ where: { state: 'running' } }))
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new Error('Forecast dependencies did not settle');
|
||||
@@ -139,10 +143,11 @@ describe('saved payout calendars and complete forecasts (SQLite HTTP)', () => {
|
||||
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' },
|
||||
});
|
||||
}
|
||||
});
|
||||
beforeEach(async () => {
|
||||
await settled();
|
||||
@@ -236,8 +241,9 @@ describe('saved payout calendars and complete forecasts (SQLite HTTP)', () => {
|
||||
const cold = (await events(false).expect(200))
|
||||
.body as UpcomingEventsResourceDto;
|
||||
expect(cold.data).toBeNull();
|
||||
for (let i = 0; i < 100 && !upstream.getDividends.mock.calls.length; i++)
|
||||
for (let i = 0; i < 100 && !upstream.getDividends.mock.calls.length; i++) {
|
||||
await delay(5);
|
||||
}
|
||||
await events().expect(200);
|
||||
release([]);
|
||||
await settled();
|
||||
@@ -290,9 +296,9 @@ describe('saved payout calendars and complete forecasts (SQLite HTTP)', () => {
|
||||
.body as UpcomingEventsResourceDto;
|
||||
await portfolio([position(shareUid, '7'), position(newUid, '5')]);
|
||||
upstream.getDividends.mockImplementation((_token: string, uid: string) =>
|
||||
uid === newUid
|
||||
? Promise.reject(new Error('new calendar unavailable'))
|
||||
: Promise.resolve([]),
|
||||
uid === newUid ?
|
||||
Promise.reject(new Error('new calendar unavailable')) :
|
||||
Promise.resolve([]),
|
||||
);
|
||||
const pending = (await events(false).expect(200))
|
||||
.body as UpcomingEventsResourceDto;
|
||||
@@ -450,12 +456,13 @@ describe('saved payout calendars and complete forecasts (SQLite HTTP)', () => {
|
||||
const path = `${kind}/${uid}/${payout}`;
|
||||
const read = async () =>
|
||||
(await get(`${path}?sync=observe`).expect(200)).body as
|
||||
StockDividendsResourceDto | BondCouponsResourceDto;
|
||||
BondCouponsResourceDto | StockDividendsResourceDto;
|
||||
await get(path).expect(200);
|
||||
await settled();
|
||||
const before = await read();
|
||||
if (!before.data?.positionAt)
|
||||
if (!before.data?.positionAt) {
|
||||
throw new Error('Expected a saved position');
|
||||
}
|
||||
expect(before.data.positionIsStale).toBe(false);
|
||||
const saved = await prisma.tbankForecast.findFirstOrThrow();
|
||||
const expiresAt =
|
||||
@@ -504,8 +511,9 @@ describe('saved payout calendars and complete forecasts (SQLite HTTP)', () => {
|
||||
} finally {
|
||||
publish.mockRestore();
|
||||
}
|
||||
for (const rpc of Object.values(upstream))
|
||||
for (const rpc of Object.values(upstream)) {
|
||||
expect(rpc).not.toHaveBeenCalled();
|
||||
}
|
||||
expect(moex.bondEvents).not.toHaveBeenCalled();
|
||||
} finally {
|
||||
clock.mockRestore();
|
||||
@@ -615,8 +623,9 @@ describe('saved payout calendars and complete forecasts (SQLite HTTP)', () => {
|
||||
}),
|
||||
);
|
||||
await events(false).expect(200);
|
||||
for (let i = 0; i < 100 && !upstream.getDividends.mock.calls.length; i++)
|
||||
for (let i = 0; i < 100 && !upstream.getDividends.mock.calls.length; i++) {
|
||||
await delay(5);
|
||||
}
|
||||
await prisma.tbankConnection.delete({ where: { userId: 'owner' } });
|
||||
release([
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user