package com.correx.core.tasks

import com.correx.core.events.types.TaskId
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test

class TaskMarkdownTest {

    private fun task(id: String, status: TaskStatus, title: String, claimant: String? = null) =
        Task(TaskId(id), TaskState(key = id, status = status, title = title, claimant = claimant))

    @Test
    fun `renders grouped sections with checkboxes and claimants`() {
        val md = TaskMarkdown.render(
            listOf(
                task("auth-1", TaskStatus.IN_PROGRESS, "JWT refresh", claimant = "claude-opus"),
                task("auth-2", TaskStatus.DONE, "Login form"),
            ),
        )

        assertTrue(md.startsWith("# Tasks"))
        assertTrue(md.contains("disposable"))
        assertTrue(md.contains("## In progress (1)"))
        assertTrue(md.contains("- [ ] **auth-1** JWT refresh _(@claude-opus)_"))
        assertTrue(md.contains("## Done (1)"))
        assertTrue(md.contains("- [x] **auth-2** Login form"))
    }

    @Test
    fun `empty board renders a placeholder`() {
        assertTrue(TaskMarkdown.render(emptyList()).contains("_No tasks._"))
    }
}
