From 2382b5b4839fc88cf7fff2e14e33a5a304b49b09 Mon Sep 17 00:00:00 2001 From: Armor00 <2654988228@qq.com> Date: Thu, 9 Jul 2026 23:46:41 +0800 Subject: [PATCH] test(topology): require database-driven visual semantics Co-Authored-By: Claude --- tests/test_guanghan_topology_demo.py | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/test_guanghan_topology_demo.py b/tests/test_guanghan_topology_demo.py index 981a33f..765bf3e 100644 --- a/tests/test_guanghan_topology_demo.py +++ b/tests/test_guanghan_topology_demo.py @@ -40,6 +40,36 @@ class GuanghanTopologySourceTests(unittest.TestCase): self.assertIn("const API_BASE = ''", self.html) self.assertNotIn("http://localhost:5000", self.html) + def test_page_uses_database_presentation_payload(self) -> None: + self.assertIn("currentData.layout.presentation", self.html) + self.assertIn("nodeStyles", self.html) + self.assertIn("edgeStyles", self.html) + self.assertIn("decorationStyles", self.html) + self.assertIn("legendItems", self.html) + + def test_business_visual_semantics_are_not_css_hardcoded(self) -> None: + forbidden = [ + ".connection.structural", + ".connection.pressurized", + ".connection.utility", + ".node-card { fill:", + ".core-card { fill:", + ".power-card { fill:", + ".power-node-card { fill:", + ".vehicle-card { fill:", + "function connectionClass", + ] + for token in forbidden: + self.assertNotIn(token, self.html) + + def test_legend_is_rendered_from_presentation_payload(self) -> None: + self.assertIn('id="legend"', self.html) + self.assertNotIn("结构直连", self.html) + self.assertNotIn("加压走道", self.html) + self.assertNotIn("燃料 / 供电", self.html) + self.assertNotIn("大型折叠散热面板", self.html) + self.assertIn("renderLegend", self.html) + def test_controls_use_api_navigation_and_safe_text(self) -> None: self.assertIn("/api/v1/bases/guanghan/missions", self.html) self.assertNotIn("return ['BL-01'", self.html)