using ClaudeDo.Ui.ViewModels;
using Xunit;

namespace ClaudeDo.Ui.Tests;

public class StaleWorkerBannerDecisionTests
{
    private const string ShaA = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
    private const string ShaB = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";

    [Fact]
    public void True_when_build_is_a_strict_ancestor_of_head()
    {
        Assert.True(IslandsShellViewModel.ShouldShowStaleWorkerBanner(ShaA, ShaB, isAncestor: true));
    }

    [Fact]
    public void False_when_build_equals_head_even_if_ancestor_check_says_true()
    {
        Assert.False(IslandsShellViewModel.ShouldShowStaleWorkerBanner(ShaA, ShaA, isAncestor: true));
    }

    [Fact]
    public void False_when_ancestor_check_says_no()
    {
        Assert.False(IslandsShellViewModel.ShouldShowStaleWorkerBanner(ShaA, ShaB, isAncestor: false));
    }

    [Fact]
    public void False_when_ancestor_check_is_unknown()
    {
        // Unknown must never be treated as stale.
        Assert.False(IslandsShellViewModel.ShouldShowStaleWorkerBanner(ShaA, ShaB, isAncestor: null));
    }

    [Fact]
    public void False_when_build_sha_missing()
    {
        Assert.False(IslandsShellViewModel.ShouldShowStaleWorkerBanner(null, ShaB, isAncestor: true));
    }

    [Fact]
    public void False_when_head_sha_missing()
    {
        Assert.False(IslandsShellViewModel.ShouldShowStaleWorkerBanner(ShaA, null, isAncestor: true));
    }
}
