import request from 'supertest'; import express from 'express'; import { routes } from '../../src/routes'; import { SignerService } from '../../src/services/signer'; describe('Signer Integration Tests', () => { let app: express.Application; beforeAll(() => { app = express(); app.use(express.json()); app.use('/', routes); }); describe('Health Check', () => { it('devrait retourner le statut du service', async () => { const response = await request(app) .get('/api/v1/health'); expect(response.status).toBe(200); expect(response.body.status).toBe('healthy'); }); }); describe('Root Endpoint', () => { it('devrait retourner la documentation de l\'API', async () => { const response = await request(app) .get('/'); expect(response.status).toBe(200); expect(response.body.message).toBe('LeCoffre Backend API'); expect(response.body.version).toBe('1.0.0'); expect(response.body.endpoints).toBeDefined(); }); }); describe('Signer Service', () => { it('devrait avoir une configuration valide', () => { const healthCheck = SignerService.getHealthCheck(); expect(healthCheck).toBeDefined(); expect(healthCheck.state).toBeDefined(); expect(healthCheck.reconnectAttempts).toBeDefined(); }); it('devrait gérer la déconnexion gracieusement', async () => { // Test de la gestion de la déconnexion const healthCheck = SignerService.getHealthCheck(); expect(healthCheck.state).toBeDefined(); }); }); describe('CORS Configuration', () => { it('devrait accepter les requêtes depuis les origines autorisées', async () => { const response = await request(app) .get('/') .set('Origin', 'https://dev4.4nkweb.com'); expect(response.status).toBe(200); }); }); });