/** * ADR-002, test dédié : quand DEMO_MODE n'est pas actif, les routes démo * N'EXISTENT PAS (404) — le module n'est pas enregistré. */ // « false » plutôt que delete : dotenv (importé par config/env.ts) repeuplerait // une variable supprimée depuis .env, mais n'écrase jamais une valeur existante. process.env.DEMO_MODE = 'false'; import { INestApplication } from '@nestjs/common'; import { Test } from '@nestjs/testing'; import request from 'supertest'; import { AppModule } from '../src/app.module'; describe('Auth démo (e2e, DEMO_MODE absent)', () => { let app: INestApplication; beforeAll(async () => { const moduleRef = await Test.createTestingModule({ imports: [AppModule.forRoot()], }).compile(); app = moduleRef.createNestApplication(); await app.init(); }); afterAll(async () => { await app?.close(); }); it('GET /auth/demo-accounts → 404', async () => { await request(app.getHttpServer()).get('/auth/demo-accounts').expect(404); }); it('POST /auth/demo-login → 404', async () => { await request(app.getHttpServer()) .post('/auth/demo-login') .send({ userId: '00000000-0000-4000-8000-000000000000' }) .expect(404); }); it('la connexion classique, elle, reste disponible', async () => { // 401 (identifiants) et non 404 : la route existe bien await request(app.getHttpServer()) .post('/auth/login') .send({ email: 'nobody@spelev.ma', password: 'x' }) .expect(401); }); });