chore: strengthen backend eslint profile
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
import type { Server } from 'node:http';
|
||||
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { setTimeout as delay } from 'node:timers/promises';
|
||||
import type { Server } from 'node:http';
|
||||
import request from 'supertest';
|
||||
|
||||
import { AppModule } from '../src/app.module';
|
||||
import { configureApp } from '../src/main';
|
||||
import { PrismaService } from '../src/prisma/prisma.service';
|
||||
import { TbankClient } from '../src/integrations/tbank/tbank.client';
|
||||
import { TbankTokenService } from '../src/integrations/tbank/tbank-token.service';
|
||||
import { TbankClient } from '../src/integrations/tbank/tbank.client';
|
||||
import { configureApp } from '../src/main';
|
||||
import { TbankSyncStatusDto } from '../src/modules/investments/tbank-sync/tbank-sync.dto';
|
||||
import { PrismaService } from '../src/prisma/prisma.service';
|
||||
|
||||
describe('screen sync HTTP and SQLite', () => {
|
||||
let app: INestApplication<Server>;
|
||||
@@ -51,10 +53,11 @@ describe('screen sync HTTP and 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' },
|
||||
});
|
||||
}
|
||||
});
|
||||
beforeEach(async () => {
|
||||
await prisma.tbankConnection.deleteMany();
|
||||
@@ -62,7 +65,7 @@ describe('screen sync HTTP and SQLite', () => {
|
||||
upstream.getOpenAccounts.mockResolvedValue([]);
|
||||
upstream.getPortfolio.mockResolvedValue({ positions: [] });
|
||||
upstream.getPositions.mockResolvedValue({ money: [] });
|
||||
for (const userId of ['owner', 'other'])
|
||||
for (const userId of ['owner', 'other']) {
|
||||
await prisma.tbankConnection.create({
|
||||
data: {
|
||||
userId,
|
||||
@@ -72,6 +75,7 @@ describe('screen sync HTTP and SQLite', () => {
|
||||
membershipRevision: 1,
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
afterAll(async () => app.close());
|
||||
it('accepts before blocked RPC finishes, joins identical requests, and observes without starting work', async () => {
|
||||
@@ -145,9 +149,9 @@ describe('screen sync HTTP and SQLite', () => {
|
||||
screen: 'stock',
|
||||
instrumentUid: '00000000-0000-4000-8000-000000000001',
|
||||
candleRange: {
|
||||
from: '2026-02-01',
|
||||
to: '2026-01-01',
|
||||
jobs: [],
|
||||
'from': '2026-02-01',
|
||||
'to': '2026-01-01',
|
||||
'jobs': [],
|
||||
'~bad/path': 'SYNTHETIC_VALIDATION_SECRET',
|
||||
},
|
||||
},
|
||||
@@ -158,7 +162,7 @@ describe('screen sync HTTP and SQLite', () => {
|
||||
);
|
||||
const problem = response.body as {
|
||||
code: string;
|
||||
errors: { pointer: string; detail: string }[];
|
||||
errors: { detail: string; pointer: string }[];
|
||||
};
|
||||
expect(problem.code).toBe('VALIDATION_ERROR');
|
||||
expect(problem.errors.length).toBeGreaterThan(0);
|
||||
@@ -167,15 +171,19 @@ describe('screen sync HTTP and SQLite', () => {
|
||||
expect(typeof error.detail).toBe('string');
|
||||
}
|
||||
if ('candleRange' in scope) {
|
||||
// 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(
|
||||
problem.errors.filter(
|
||||
(error) => error.pointer === '#/candleRange/jobs',
|
||||
),
|
||||
).toHaveLength(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(problem.errors).toContainEqual({
|
||||
pointer: '#/candleRange/~0bad~1path',
|
||||
// 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.
|
||||
detail: expect.any(String) as unknown,
|
||||
});
|
||||
// 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(JSON.stringify(response.body)).not.toContain(
|
||||
'SYNTHETIC_VALIDATION_SECRET',
|
||||
);
|
||||
@@ -350,9 +358,9 @@ describe('screen sync HTTP and SQLite', () => {
|
||||
}),
|
||||
)
|
||||
.mockImplementation(() =>
|
||||
outcome === 'failed'
|
||||
? Promise.reject(new Error('Synthetic outage'))
|
||||
: Promise.resolve({ hasNext: false, items: [] }),
|
||||
outcome === 'failed' ?
|
||||
Promise.reject(new Error('Synthetic outage')) :
|
||||
Promise.resolve({ hasNext: false, items: [] }),
|
||||
);
|
||||
const accept = async (from: string, to: string) => {
|
||||
const response = await post({
|
||||
|
||||
Reference in New Issue
Block a user