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

namespace ClaudeDo.Data.Tests.Filtering;

internal static class TaskFactory
{
    public static TaskEntity Make(
        string id,
        string listId = "L",
        TaskStatus status = TaskStatus.Idle,
        PlanningPhase phase = PlanningPhase.None,
        string? parentId = null,
        bool isMyDay = false,
        bool isStarred = false,
        DateTime? scheduled = null,
        WorktreeState? worktreeState = null)
    {
        var t = new TaskEntity
        {
            Id            = id,
            ListId        = listId,
            Title         = id,
            CreatedAt     = DateTime.UtcNow,
            Status        = status,
            PlanningPhase = phase,
            ParentTaskId  = parentId,
            IsMyDay       = isMyDay,
            IsStarred     = isStarred,
            ScheduledFor  = scheduled,
        };
        if (worktreeState is { } s)
        {
            t.Worktree = new WorktreeEntity
            {
                TaskId     = id,
                Path       = "/tmp/" + id,
                BranchName = "br/" + id,
                BaseCommit = "deadbeef",
                CreatedAt  = DateTime.UtcNow,
                State      = s,
            };
        }
        return t;
    }
}
