using System.Runtime.CompilerServices;
using ClaudeDo.Ui.Services;

namespace ClaudeDo.Ui.Tests;

internal static class TestSetup
{
    // Runs once when this test assembly loads, before any test executes. Without it, every test
    // that constructs a real DetailsIslandViewModel/TasksIslandViewModel/WorkerClient and calls a
    // method instrumented with OperationTiming.Shared.Record writes straight into the live app's
    // ~/.todo-app/logs/operation-timing.ndjson — a single Ui.Tests run added 50-100 cancelled
    // "DetailsIsland.BindAsync:?" lines to that file, dwarfing real usage and making the churn
    // look like a UI bug.
    [ModuleInitializer]
    internal static void RedirectOperationTimingAwayFromRealAppData()
    {
        var path = Path.Combine(Path.GetTempPath(), "claudedo-ui-tests", $"operation-timing-{Environment.ProcessId}.ndjson");
        OperationTiming.Shared = new OperationTiming(path);
    }
}
