// tests/integration/api.test.js
const request = require('supertest');
const app = require('../../index');

describe('API Integration Tests', () => {
  test('GET / should return welcome message', async () => {
    const response = await request(app)
      .get('/')
      .expect(200);
      
    expect(response.body).toHaveProperty('message');
    expect(response.body.message).toBe('Welcome to MerchantsOfHope.org - TSYS Group Recruiting Platform');
    expect(response.body).toHaveProperty('status');
    expect(response.body.status).toBe('running');
    expect(response.body).toHaveProperty('tenantId');
    expect(response.body.tenantId).toBe('default');
  });

  test('GET /health should return health status', async () => {
    const response = await request(app)
      .get('/health')
      .expect(200);
      
    expect(response.body).toHaveProperty('status');
    expect(response.body.status).toBe('OK');
    expect(response.body).toHaveProperty('service');
    expect(response.body.service).toBe('MOH Portal API');
    expect(response.body).toHaveProperty('tenantId');
    expect(response.body.tenantId).toBe('default');
  });

  test('GET /nonexistent should return 404', async () => {
    const response = await request(app)
      .get('/nonexistent')
      .expect(404);
      
    expect(response.body).toHaveProperty('error');
    expect(response.body.error).toBe('Route not found');
    expect(response.body).toHaveProperty('tenantId');
    expect(response.body.tenantId).toBe('default');
  });
  
  test('GET /api/auth should return 404 since no implementation yet', async () => {
    const response = await request(app)
      .get('/api/auth')
      .expect(404);
      
    expect(response.body).toHaveProperty('error');
    expect(response.body).toHaveProperty('tenantId');
  });
  
  test('GET /api/job-seekers should return 404 since no implementation yet', async () => {
    const response = await request(app)
      .get('/api/job-seekers')
      .expect(404);
      
    expect(response.body).toHaveProperty('error');
    expect(response.body).toHaveProperty('tenantId');
  });
  
  test('GET /api/job-providers should return 404 since no implementation yet', async () => {
    const response = await request(app)
      .get('/api/job-providers')
      .expect(404);
      
    expect(response.body).toHaveProperty('error');
    expect(response.body).toHaveProperty('tenantId');
  });
  
  test('GET /api/tenants should return 404 since no implementation yet', async () => {
    const response = await request(app)
      .get('/api/tenants')
      .expect(404);
      
    expect(response.body).toHaveProperty('error');
    expect(response.body).toHaveProperty('tenantId');
  });
});