// Accounts 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('Accounts API Integration', () => {
  beforeEach(async () => {
    await cleanDatabase();
  });

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

  describe('POST /api/accounts', () => {
    it('should create a new account', async () => {
      const bank = await createTestSovereignBank();

      const response = await request(app)
        .post('/api/accounts')
        .set(createAuthHeaders({ sovereignBankId: bank.id }))
        .send({
          accountType: 'commercial',
          currencyCode: 'USD',
          assetType: 'fiat',
        });

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

  describe('GET /api/accounts/:id', () => {
    it('should retrieve account details', async () => {
      const bank = await createTestSovereignBank();

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

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

