This repository has been archived on 2026-03-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Timmy-time-dashboard/tests/dashboard/test_bugs_route.py
Alexander Whitestone aa3263bc3b feat: automatic error feedback loop with bug report tracker (#80)
Errors and uncaught exceptions are now automatically captured, deduplicated,
persisted to a rotating log file, and filed as bug report tasks in the
existing task queue — giving Timmy a sovereign, local issue tracker with
zero new dependencies.

- Add RotatingFileHandler writing errors to logs/errors.log (5MB rotate, 5 backups)
- Add error capture module with stack-trace hashing and 5-min dedup window
- Add FastAPI exception middleware + global exception handler
- Instrument all background loops (briefing, thinking, task processor) with capture_error()
- Extend task queue with bug_report task type and auto-approve rule
- Fix auto-approve type matching (was ignoring task_type field entirely)
- Add /bugs dashboard page and /api/bugs JSON endpoints
- Add ERROR_CAPTURED and BUG_REPORT_CREATED event types for real-time feed
- Add BUGS nav link to desktop and mobile navigation
- Add 16 tests covering error capture, deduplication, and bug report routes

Co-authored-by: Alexander Payne <apayne@MM.local>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 19:51:37 -05:00

48 lines
1.1 KiB
Python

"""Tests for bug reports dashboard route."""
import pytest
from fastapi.testclient import TestClient
@pytest.fixture(autouse=True)
def _isolate_db(tmp_path, monkeypatch):
"""Point task_queue and event_log SQLite to a temp directory."""
db = tmp_path / "swarm.db"
monkeypatch.setattr("swarm.task_queue.models.DB_PATH", db)
monkeypatch.setattr("swarm.event_log.DB_PATH", db)
@pytest.fixture
def client():
from dashboard.app import app
with TestClient(app) as c:
yield c
def test_bugs_page_loads(client):
resp = client.get("/bugs")
assert resp.status_code == 200
assert "BUG REPORTS" in resp.text
def test_api_list_bugs(client):
resp = client.get("/api/bugs")
assert resp.status_code == 200
data = resp.json()
assert "bugs" in data
assert "count" in data
def test_api_bug_stats(client):
resp = client.get("/api/bugs/stats")
assert resp.status_code == 200
data = resp.json()
assert "stats" in data
assert "total" in data
def test_bugs_page_with_status_filter(client):
resp = client.get("/bugs?status=approved")
assert resp.status_code == 200