Bundle CAD dashboard and keep verification status current
This commit is contained in:
1 parent
449418d00f
commit
b4ef20db39
10 files changed
+89
-15
No files matched your search
@@ -1,6 +1,8 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
from socket import socket
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
from threading import Thread
|
||||
import unittest
|
||||
@@ -8,6 +10,8 @@ from unittest.mock import patch
|
||||
from urllib.error import HTTPError
|
||||
from urllib.request import Request, urlopen
|
||||
|
||||
BUNDLE = Path(__file__).resolve().parents[1] / ".opencode" / "plugins" / "cad-dashboard" / "bundle"
|
||||
sys.path.insert(0, str(BUNDLE))
|
||||
from serve import (Handler, OpenCodeUnavailable, ThreadingHTTPServer, dashboard_state,
|
||||
ensure_dashboard, launch_dashboard, read_activity, read_cards)
|
||||
|
||||
@@ -40,6 +44,17 @@ class DashboardTest(unittest.TestCase):
|
||||
("CF-001", "Посадочное место", "проверка", body))
|
||||
self.assertEqual(card.read_text(encoding="utf-8"), body)
|
||||
|
||||
def test_cards_reflect_saved_status_after_verification(self):
|
||||
self.changes.mkdir()
|
||||
card = self.changes / "CF-001.md"
|
||||
for status in ("проверка", "ожидает просмотра", "на рассмотрении",
|
||||
"на доработке", "заблокировано"):
|
||||
with self.subTest(status=status):
|
||||
card.write_text(f"# CF-001\n- Текущее состояние: `{status}`\n",
|
||||
encoding="utf-8")
|
||||
row, = read_cards(self.root)["cards"]
|
||||
self.assertEqual(row["status"], status)
|
||||
|
||||
def test_activity_scopes_jobs_deduplicates_child_and_omits_non_cad(self):
|
||||
running = {"type": "running"}
|
||||
foreign = self.root / "other"
|
||||
@@ -79,6 +94,21 @@ class DashboardTest(unittest.TestCase):
|
||||
with self.assertRaises(OpenCodeUnavailable):
|
||||
read_activity(self.root, lambda root, path: None)
|
||||
|
||||
def test_install_creates_panel_and_preserves_project_files(self):
|
||||
folder = self.root / "dashboard"
|
||||
command = [sys.executable, "-I", str(BUNDLE / "serve.py"), "--install", "--root", str(self.root)]
|
||||
subprocess.run(command, cwd=self.root, check=True, timeout=5)
|
||||
files = {"serve.py", "index.html", "app.css", "app.js"}
|
||||
self.assertEqual({path.name for path in folder.iterdir()}, files)
|
||||
for name in files:
|
||||
self.assertEqual((folder / name).read_bytes(), (BUNDLE / name).read_bytes())
|
||||
|
||||
(folder / "app.css").write_bytes(b"/* project styles */")
|
||||
(folder / "app.js").unlink()
|
||||
subprocess.run(command, cwd=self.root, check=True, timeout=5)
|
||||
self.assertEqual((folder / "app.css").read_bytes(), b"/* project styles */")
|
||||
self.assertEqual((folder / "app.js").read_bytes(), (BUNDLE / "app.js").read_bytes())
|
||||
|
||||
def test_autostart_skips_occupied_port_and_reuses_panel_after_it_frees(self):
|
||||
def track_child(*args):
|
||||
child = launch_dashboard(*args)
|
||||
|
||||
Reference in new issue
Block a user