返回 last30days-skill
test_html_save_contract.py
根目录 / tests / test_html_save_contract.py
1 """Contract tests for the /last30days HTML save handoff."""
2
3 from pathlib import Path
4
5 from tests.skill_contract import reference_text
6
7 ROOT = Path(__file__).resolve().parents[1]
8 SKILL_MD = ROOT / "skills" / "last30days" / "SKILL.md"
9 SAVE_HTML = ROOT / "skills" / "last30days" / "references" / "save-html-brief.md"
10
11
12 def test_skill_routes_html_to_reference_and_artifact_handoff():
13 text = SKILL_MD.read_text(encoding="utf-8")
14 start = text.index("## HTML and follow-up handoff")
15 end = text.index("## Security & Permissions", start)
16 section = text[start:end]
17
18 assert reference_text("save-html-brief")
19 assert "read the HTML reference through the root gate before finishing" in section
20 assert "concise handoff for an HTML deliverable" in section
21 assert "open locally when supported and implied" in section
22 assert "Never upload/publish without an explicit hosted-sharing request" in section
23 assert "Append the confirmation line" not in section
24 assert "or a natural-language request for an HTML brief" in section
25 assert "not the full Python CLI contract" in section
26
27
28 def test_html_deliverable_is_artifact_first_not_full_markdown_repeat():
29 text = reference_text("save-html-brief")
30 assert "**HTML as the requested deliverable**" in text
31 assert 'prose like "give it to me in HTML"' in text
32 assert "the HTML artifact is the primary output" in text
33 assert "use the exact synthesis draft you prepared for" in text
34 assert "Do not paste it to chat first" in text
35 assert "the chat handoff is the single user-visible" in text
36 assert "printf '📎 Shareable brief saved to %s\\n'" not in text
37 assert 'echo "📎 Shareable brief saved to $HTML_PATH"' not in text
38 assert "do **not** paste the full Markdown report back into chat" in text
39 assert "The user asked for an HTML deliverable" in text
40 assert "What do you want to do next?" in text
41 assert "1. Open HTML file" in text
42 assert "3. Done for now" in text
43
44
45 def test_html_handoff_opens_locally_without_os_command_menu():
46 text = reference_text("save-html-brief")
47 assert "Let the host choose the correct OS-specific mechanism" in text
48 assert "do not print a menu of shell commands" in text
49 assert "If opening fails or the host is headless" in text
50 assert 'xdg-open "<absolute HTML path>"' not in text
51 assert 'start "" "<absolute HTML path>"' not in text
52
53
54 def test_html_save_flow_does_not_publish_or_upload():
55 text = reference_text("save-html-brief")
56 assert "Do not upload in this flow unless the user chooses a publishing option" in text
57 assert "Do NOT publish, upload, or send the HTML to a third-party service" in text
58 assert "Do NOT block a local HTML export on a hosting decision" in text
59 assert "Show the saved path and next-step choices first" in text
60
61
62 def test_markdown_and_html_access_paths_are_separate():
63 text = reference_text("synthesis")
64 start = text.index("**Saved artifact access flow:**")
65 section = text[start:start + 1600]
66
67 assert "**Markdown file requested:**" in section
68 assert "Do not offer hosted publishing for Markdown" in section
69 assert "**HTML file requested:**" in section
70 assert "show the absolute path" in section
71 assert "open the HTML file, publish to an available/preferred HTML publishing service, or done for now" in section
72
73
74 def test_follow_up_turn_preserves_html_deliverable_mode():
75 text = reference_text("save-html-brief")
76 assert "explicitly refers back to that visible synthesis" in text
77 assert "treat it as HTML-as-deliverable mode" in text
78 assert "Always report the path stored in `HTML_PATH` in the chat handoff" in text
79
79 lines PYTHON