feat(dev): 新增组件样式与表单辅助 Skill
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
"""前端辅助 Skill 的结构与行为边界测试。"""
|
||||
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
DEV_SKILLS = ROOT / "plugins" / "dev" / "skills"
|
||||
|
||||
|
||||
def read_skill(name: str) -> str:
|
||||
"""读取指定 Skill 的入口及引用文档。"""
|
||||
folder = DEV_SKILLS / name
|
||||
files = [folder / "SKILL.md", *sorted((folder / "references").glob("*.md"))]
|
||||
return "\n".join(path.read_text(encoding="utf-8") for path in files)
|
||||
|
||||
|
||||
class FrontendHelpersTest(unittest.TestCase):
|
||||
"""验证三个 Skill 能互补协作且不恢复来源专有规则。"""
|
||||
|
||||
def test_component_requires_project_evidence(self) -> None:
|
||||
content = read_skill("component")
|
||||
self.assertIn(".craftkit/project.json", content)
|
||||
self.assertIn(".craftkit/standards/frontend/components.md", content)
|
||||
self.assertIn("不编造结论", content)
|
||||
self.assertIn("官方文档", content)
|
||||
self.assertIn("不复制依赖库文档", content)
|
||||
|
||||
def test_style_uses_existing_visual_authority(self) -> None:
|
||||
content = read_skill("style")
|
||||
self.assertIn("设计令牌", content)
|
||||
self.assertIn("经用户确认后再修改", content)
|
||||
self.assertIn("不内置固定矩阵", content)
|
||||
|
||||
def test_form_does_not_invent_business_rules(self) -> None:
|
||||
content = read_skill("form")
|
||||
self.assertIn("不自行确定字段必填", content)
|
||||
self.assertIn("不设计接口", content)
|
||||
self.assertIn("component", content)
|
||||
|
||||
def test_precise_skills_replace_router(self) -> None:
|
||||
self.assertFalse((DEV_SKILLS / "guide").exists())
|
||||
descriptions = {
|
||||
name: (DEV_SKILLS / name / "SKILL.md").read_text(encoding="utf-8").split("---", 2)[1]
|
||||
for name in ("component", "style", "form")
|
||||
}
|
||||
self.assertEqual(3, len(set(descriptions.values())))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -71,6 +71,9 @@ class GuidanceInitTest(unittest.TestCase):
|
||||
self.assertEqual(1, payload["schemaVersion"])
|
||||
self.assertIn(payload["initialization"]["mode"], {"existing", "new"})
|
||||
self.assertEqual([], payload["dependencies"]["internal"])
|
||||
self.assertEqual([], payload["frontend"]["componentLibraries"])
|
||||
self.assertEqual([], payload["frontend"]["componentRoots"])
|
||||
self.assertEqual([], payload["frontend"]["documentation"])
|
||||
self.assertEqual(
|
||||
".craftkit/standards/index.md",
|
||||
payload["guidance"]["standardsIndex"],
|
||||
@@ -78,6 +81,23 @@ class GuidanceInitTest(unittest.TestCase):
|
||||
serialized = json.dumps(payload, ensure_ascii=False)
|
||||
self.assertNotIn(":\\", serialized)
|
||||
|
||||
def test_init_collects_frontend_component_metadata(self) -> None:
|
||||
"""初始化应记录组件库证据和入口,但不能默认选择组件库。"""
|
||||
|
||||
content = "\n".join(
|
||||
path.read_text(encoding="utf-8")
|
||||
for path in (
|
||||
INIT / "SKILL.md",
|
||||
INIT / "references" / "project-config.md",
|
||||
INIT / "references" / "existing.md",
|
||||
INIT / "references" / "new.md",
|
||||
)
|
||||
)
|
||||
self.assertIn("componentLibraries", content)
|
||||
self.assertIn("组件根", content)
|
||||
self.assertIn("不默认选择流行方案", content)
|
||||
self.assertTrue((INIT / "assets" / "frontend-components.md").is_file())
|
||||
|
||||
def test_local_directories_are_the_only_nested_ignores(self) -> None:
|
||||
"""初始化模板只排除本地状态和缓存,不得排除共享资料。"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user