Files
basic-erp/apps/api/test/sap-live.e2e-spec.ts
T

29 lines
1.1 KiB
TypeScript
Raw Normal View History

import { Test } from '@nestjs/testing';
import type { INestApplication } from '@nestjs/common';
import { AppModule } from '../src/app.module.js';
import { SapClientService } from '../src/sap/sap-client.service.js';
// Prueba contra un Service Layer real (usa apps/api/.env). Solo con SAP_LIVE=1:
// SAP_LIVE=1 npm run test:e2e
describe.skipIf(!process.env.SAP_LIVE)('SAP Service Layer (live)', () => {
let app: INestApplication;
let sap: SapClientService;
beforeAll(async () => {
const moduleRef = await Test.createTestingModule({ imports: [AppModule] }).compile();
app = moduleRef.createNestApplication();
await app.init();
sap = app.get(SapClientService);
}, 30000);
afterAll(async () => {
await app.close();
});
it('10 peticiones concurrentes se encolan y no agotan el timeout', async () => {
const res = await Promise.all(
Array.from({ length: 10 }, () => sap.get<{ value: unknown[] }>('Items', { $top: 1, $select: 'ItemCode' })),
);
expect(res.every((r) => r.status === 200 && Array.isArray(r.data.value))).toBe(true);
}, 30000);
});