namespace Books.E2E.Tests.Infrastructure;

/// <summary>
/// Configuration for E2E tests.
/// URLs can be configured via environment variables or appsettings.
/// </summary>
public class E2EConfiguration
{
    /// <summary>
    /// Backend API URL. Default: https://localhost:5001
    /// Override with E2E_BACKEND_URL environment variable.
    /// </summary>
    public string BackendUrl { get; }

    /// <summary>
    /// Frontend URL. Default: http://localhost:5173
    /// Override with E2E_FRONTEND_URL environment variable.
    /// </summary>
    public string FrontendUrl { get; }

    /// <summary>
    /// GraphQL endpoint URL. Derived from BackendUrl.
    /// </summary>
    public string GraphQLUrl => $"{BackendUrl}/graphql";

    /// <summary>
    /// Test user email for authentication.
    /// </summary>
    public string TestUserEmail { get; } = "nhh@softwarehuset.com";

    /// <summary>
    /// Test user password for authentication.
    /// </summary>
    public string TestUserPassword { get; } = "nXfdFVlAr30GiK";

    public E2EConfiguration()
    {
        BackendUrl = Environment.GetEnvironmentVariable("E2E_BACKEND_URL")
            ?? "https://localhost:5001";

        FrontendUrl = Environment.GetEnvironmentVariable("E2E_FRONTEND_URL")
            ?? "http://localhost:3000";

        Console.WriteLine($"[E2EConfiguration] Backend URL: {BackendUrl}");
        Console.WriteLine($"[E2EConfiguration] Frontend URL: {FrontendUrl}");
    }
}
