using ClaudeDo.Data.Filtering;
using TaskStatus = ClaudeDo.Data.Models.TaskStatus;

namespace ClaudeDo.Data.Tests.Filtering;

public sealed class SmartFilterTests
{
    [Fact]
    public void MyDay_matches_my_day_tasks_regardless_of_status()
    {
        var f = new SmartFlagFilter("smart:my-day", t => t.IsMyDay);
        Assert.True (f.Matches(TaskFactory.Make("a", isMyDay: true,  status: TaskStatus.Idle)));
        Assert.True (f.Matches(TaskFactory.Make("b", isMyDay: true,  status: TaskStatus.Done)));
        Assert.False(f.Matches(TaskFactory.Make("c", isMyDay: false, status: TaskStatus.Idle)));
    }

    [Fact]
    public void MyDay_count_excludes_done()
    {
        var f = new SmartFlagFilter("smart:my-day", t => t.IsMyDay);
        Assert.True (f.ShouldCount(TaskFactory.Make("a", isMyDay: true,  status: TaskStatus.Queued)));
        Assert.False(f.ShouldCount(TaskFactory.Make("b", isMyDay: true,  status: TaskStatus.Done)));
        Assert.False(f.ShouldCount(TaskFactory.Make("c", isMyDay: false, status: TaskStatus.Idle)));
    }

    [Fact]
    public void Important_uses_IsStarred_with_same_split()
    {
        var f = new SmartFlagFilter("smart:important", t => t.IsStarred);
        Assert.True (f.Matches    (TaskFactory.Make("a", isStarred: true, status: TaskStatus.Done)));
        Assert.False(f.ShouldCount(TaskFactory.Make("a", isStarred: true, status: TaskStatus.Done)));
        Assert.True (f.ShouldCount(TaskFactory.Make("b", isStarred: true, status: TaskStatus.Queued)));
        Assert.False(f.Matches    (TaskFactory.Make("c", isStarred: false)));
    }

    [Fact]
    public void Planned_uses_ScheduledFor_with_same_split()
    {
        var f = new SmartFlagFilter("smart:planned", t => t.ScheduledFor != null);
        var when = DateTime.Today;
        Assert.True (f.Matches    (TaskFactory.Make("a", scheduled: when, status: TaskStatus.Done)));
        Assert.False(f.ShouldCount(TaskFactory.Make("a", scheduled: when, status: TaskStatus.Done)));
        Assert.True (f.ShouldCount(TaskFactory.Make("b", scheduled: when, status: TaskStatus.Idle)));
        Assert.False(f.Matches    (TaskFactory.Make("c", scheduled: null)));
    }
}
