Register future write actions with task_capability_map metadata, mutation-ledger previews, and fail-closed execution in the read-only MVP. Adds /actions routes, disabled UI buttons, and tests proving ungated attempts cannot invoke mutations. Closes #434
80 lines
2.9 KiB
Python
80 lines
2.9 KiB
Python
"""Tests for internal web UI skeleton (#426)."""
|
|
import sys
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
|
|
|
from starlette.testclient import TestClient
|
|
|
|
from webui.app import create_app
|
|
|
|
|
|
class TestWebuiSkeleton(unittest.TestCase):
|
|
def setUp(self):
|
|
self.client = TestClient(create_app())
|
|
|
|
def test_health_returns_json(self):
|
|
response = self.client.get("/health")
|
|
self.assertEqual(response.status_code, 200)
|
|
data = response.json()
|
|
self.assertEqual(data["status"], "ok")
|
|
self.assertEqual(data["service"], "mcp-control-plane-webui")
|
|
self.assertEqual(data["mode"], "read-only-mvp")
|
|
self.assertIn("timestamp", data)
|
|
|
|
def test_home_renders(self):
|
|
response = self.client.get("/")
|
|
self.assertEqual(response.status_code, 200)
|
|
self.assertIn("Operator console", response.text)
|
|
self.assertIn("Read-only MVP", response.text)
|
|
|
|
def test_route_stubs_render(self):
|
|
for path in ("/runtime", "/audit"):
|
|
with self.subTest(path=path):
|
|
response = self.client.get(path)
|
|
self.assertEqual(response.status_code, 200)
|
|
self.assertIn("child issue", response.text.lower())
|
|
|
|
def test_prompts_is_implemented(self):
|
|
response = self.client.get("/prompts")
|
|
self.assertEqual(response.status_code, 200)
|
|
self.assertIn("Prompt library", response.text)
|
|
|
|
def test_projects_is_implemented(self):
|
|
response = self.client.get("/projects")
|
|
self.assertEqual(response.status_code, 200)
|
|
self.assertIn("Gitea-Tools", response.text)
|
|
|
|
def test_extra_stub_routes(self):
|
|
for path in ("/worktrees", "/leases"):
|
|
with self.subTest(path=path):
|
|
self.assertEqual(self.client.get(path).status_code, 200)
|
|
|
|
def test_actions_is_implemented(self):
|
|
response = self.client.get("/actions")
|
|
self.assertEqual(response.status_code, 200)
|
|
self.assertIn("Gated actions", response.text)
|
|
|
|
def test_post_is_rejected(self):
|
|
response = self.client.post("/health")
|
|
self.assertEqual(response.status_code, 405)
|
|
self.assertEqual(response.json()["error"], "read-only-mvp")
|
|
|
|
def test_queue_route_renders(self):
|
|
response = self.client.get("/queue")
|
|
self.assertEqual(response.status_code, 200)
|
|
self.assertIn("Live queue", response.text)
|
|
|
|
def test_nav_links_on_all_pages(self):
|
|
for path in ("/", "/queue", "/projects", "/prompts", "/runtime", "/audit", "/actions"):
|
|
with self.subTest(path=path):
|
|
text = self.client.get(path).text
|
|
for href in (
|
|
"/queue", "/projects", "/prompts", "/runtime", "/audit", "/actions",
|
|
):
|
|
self.assertIn(f'href="{href}"', text)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main() |