2026-06-14 11:24:36 -04:00
|
|
|
"""Tests for automaton.dashboard.core.board."""
|
|
|
|
|
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
from automaton.dashboard.core.board import KanbanBoard
|
|
|
|
|
from automaton.dashboard.core.task import determine_task_state
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _task(name: str, tmp_path: Path, artifacts: dict[str, str]) -> object:
|
|
|
|
|
from automaton.dashboard.core.task import Task
|
|
|
|
|
|
|
|
|
|
task_dir = tmp_path / name
|
|
|
|
|
task_dir.mkdir(parents=True)
|
|
|
|
|
for filename, content in artifacts.items():
|
|
|
|
|
(task_dir / filename).write_text(content)
|
2026-06-26 10:05:18 -04:00
|
|
|
state, _, artifact_map = determine_task_state(task_dir)
|
2026-06-14 11:24:36 -04:00
|
|
|
return Task(name=name, folder_path=task_dir, state=state, artifacts=artifact_map)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_board_columns(tmp_path: Path) -> None:
|
|
|
|
|
tasks = [
|
|
|
|
|
_task("research", tmp_path, {"SPEC.md": "# Spec"}),
|
|
|
|
|
_task("done", tmp_path, {"VERDICT.md": "## Status: PASS"}),
|
|
|
|
|
]
|
|
|
|
|
board = KanbanBoard(tasks)
|
|
|
|
|
assert board.columns[tasks[0].state] == [tasks[0]]
|
|
|
|
|
assert board.columns[tasks[1].state] == [tasks[1]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_board_filter_by_phase(tmp_path: Path) -> None:
|
|
|
|
|
research = _task("research", tmp_path, {"SPEC.md": "# Spec"})
|
|
|
|
|
done = _task("done", tmp_path, {"VERDICT.md": "## Status: PASS"})
|
|
|
|
|
board = KanbanBoard([research, done])
|
|
|
|
|
filtered = board.filter_columns(phase_filter=research.state)
|
|
|
|
|
assert research in filtered[research.state]
|
|
|
|
|
assert done not in filtered[research.state]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_board_search(tmp_path: Path) -> None:
|
|
|
|
|
apple = _task("apple-task", tmp_path, {"SPEC.md": "# Spec"})
|
|
|
|
|
banana = _task("banana-task", tmp_path, {"SPEC.md": "# Spec"})
|
|
|
|
|
board = KanbanBoard([apple, banana])
|
|
|
|
|
filtered = board.filter_columns(search_query="apple")
|
|
|
|
|
assert apple in filtered[apple.state]
|
|
|
|
|
assert banana not in filtered[banana.state]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_board_wip_count(tmp_path: Path) -> None:
|
|
|
|
|
research = _task("research", tmp_path, {"SPEC.md": "# Spec"})
|
|
|
|
|
done = _task("done", tmp_path, {"VERDICT.md": "## Status: PASS"})
|
|
|
|
|
board = KanbanBoard([research, done])
|
|
|
|
|
assert board.get_wip_count() == 1
|