using Sdt.Config;
using Sdt.Core;
using Xunit;

namespace DevTool.Tests;

public sealed class ActionRunnerLegacyPwshTests
{
    [Fact]
    public async Task LegacyPwshTarget_ReroutesToPythonScript_WhenPs1Missing()
    {
        var root = Path.Combine(Path.GetTempPath(), "sdt-actionrunner-" + Guid.NewGuid().ToString("N"));
        var scripts = Path.Combine(root, "scripts");
        Directory.CreateDirectory(scripts);
        File.WriteAllText(Path.Combine(scripts, "publish-app.py"), "print('rerouted')");

        var step = new WorkflowStep
        {
            Id = "legacy",
            Label = "legacy",
            Command = "pwsh",
            Args = ["-NoProfile", "-File", "scripts/publish-app.ps1", "-Target", "web"],
            WorkingDir = "."
        };

        var runner = new ActionRunner();
        var run = await runner.RunStepAsync(step, root, (_, _) => { });

        Assert.True(run.Success);
    }
}
