package com.cameleer.server.app.controller;

import com.cameleer.server.app.AbstractPostgresIT;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.web.client.TestRestTemplate;

import static org.assertj.core.api.Assertions.assertThat;

/**
 * Integration tests for OpenAPI documentation endpoints.
 */
class OpenApiIT extends AbstractPostgresIT {

    @Autowired
    private TestRestTemplate restTemplate;

    @Test
    void apiDocsReturnsOpenApiSpec() {
        var response = restTemplate.getForEntity("/api/v1/api-docs", String.class);
        assertThat(response.getStatusCode().value()).isEqualTo(200);
        assertThat(response.getBody()).contains("openapi");
        assertThat(response.getBody()).contains("paths");
    }

    @Test
    void swaggerUiIsAccessible() {
        var response = restTemplate.getForEntity("/api/v1/swagger-ui/index.html", String.class);
        // Swagger UI may return 200 directly or 302 redirect
        assertThat(response.getStatusCode().value()).isIn(200, 302);
    }
}
