// FX API Integration Tests

import request from 'supertest';
import app from '@/integration/api-gateway/app';
import { createTestSovereignBank, cleanDatabase } from '@/__tests__/utils/test-db';
import { testPrisma } from '@/__tests__/utils/test-db';
import { createAuthHeaders } from '@/__tests__/utils/test-auth';

describe('FX API Integration', () => {
  beforeEach(async () => {
    await cleanDatabase();
  });

  afterAll(async () => {
    await testPrisma.$disconnect();
  });

  describe('POST /api/fx/orders', () => {
    it('should submit an FX order', async () => {
      const bank = await createTestSovereignBank();

      const response = await request(app)
        .post('/api/fx/orders')
        .set(createAuthHeaders({ sovereignBankId: bank.id }))
        .send({
          pair: 'USD/EUR',
          amount: '1000.00',
          orderType: 'market',
          settlement: 'RTGS',
        });

      expect([200, 201]).toContain(response.status);
    });
  });

  describe('GET /api/fx/trades/:id', () => {
    it('should retrieve FX trade details', async () => {
      const bank = await createTestSovereignBank();

      const response = await request(app)
        .get('/api/fx/trades/test-id')
        .set(createAuthHeaders({ sovereignBankId: bank.id }));

      expect([200, 404]).toContain(response.status);
    });
  });
});

