nightshift/tests/test_web.py
K. Hodges 646c655314 Repo Lookup, Request Context, Planner, Context Stage, QoL improvements
- Added operational run logging via nightshift/runlog.py.
  - CLI now streams progress during run / run --all.
  - Runs write .nightshift/runs/<run-id>/run.log and aggregate .nightshift/nightshift.log.
  - Web dashboard now shows the last 100 run log lines.
  - Added agent temperature config.
  - Added minimal openai_compatible backend and temperature passing for it.
  - Added Ollama temperature handling.
  - Added scoped repo lookup tools in nightshift/repo_tools.py: list_files, read_file, grep.
  - Planner agents can request lookup context with lookup_requests; NightShift saves files-inspected.md and reruns the planner with retrieved context.
  - Added repo_context stage type that writes context-pack.md.
  - Marked phases 23-27 complete in docs/design.md:990.
2026-05-17 09:56:28 -07:00

43 lines
1.7 KiB
Python

from pathlib import Path
import tempfile
import unittest
from nightshift.artifacts import ArtifactStore
from nightshift.web import list_runs, read_artifact, render_dashboard
class WebDashboardTests(unittest.TestCase):
def test_render_dashboard_handles_missing_runs(self) -> None:
with tempfile.TemporaryDirectory() as directory:
html = render_dashboard(Path(directory) / ".nightshift")
self.assertIn("No runs found", html)
def test_lists_runs_and_reads_artifacts_safely(self) -> None:
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
artifacts = ArtifactStore(root, ".nightshift", run_id="test-run")
artifacts.initialize_run()
artifacts.run_summary_path.write_text("# Summary\n\nok", encoding="utf-8")
artifacts.run_log_path.write_text(
"\n".join(f"line {index}" for index in range(120)),
encoding="utf-8",
)
runs = list_runs(root / ".nightshift")
content = read_artifact(root / ".nightshift" / "runs" / "test-run", "run-summary.md")
escaped = read_artifact(root / ".nightshift" / "runs" / "test-run", "../project-context.md")
dashboard = render_dashboard(root / ".nightshift")
self.assertEqual(len(runs), 1)
self.assertEqual(len(runs[0].log_tail), 100)
self.assertIn("ok", content)
self.assertIn("escapes", escaped)
self.assertIn("Log Tail", dashboard)
self.assertIn("line 119", dashboard)
self.assertNotIn("line 19\n", dashboard)
if __name__ == "__main__":
unittest.main()