返回 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 ROOT = Path(__file__).resolve().parents[1]
6 SKILL_MD = ROOT / "skills" / "last30days" / "SKILL.md"
7 SAVE_HTML = ROOT / "skills" / "last30days" / "references" / "save-html-brief.md"
8
9
10 def test_skill_routes_html_to_reference_and_artifact_handoff():
11 text = SKILL_MD.read_text(encoding="utf-8")
12 start = text.index("## SHAREABLE HTML BRIEF")
13 end = text.index("## WAIT FOR USER'S RESPONSE", start)
14 section = text[start:end]
15
16 assert "Read `references/save-html-brief.md`" in section
17 assert "artifact handoff" in section
18 assert "open the local file when the host can do so" in section
19 assert "Upload or publish" in section
20 assert "Append the confirmation line" not in section
21 assert "a literal flag is not required" in section
22 assert "do not confuse it with the complete Python CLI contract" in section
23
24
25 def test_html_deliverable_is_artifact_first_not_full_markdown_repeat():
26 text = SAVE_HTML.read_text(encoding="utf-8")
27 assert "**HTML as the requested deliverable**" in text
28 assert 'prose like "give it to me in HTML"' in text
29 assert "the HTML artifact is the primary output" in text
30 assert "use the exact synthesis draft you prepared for" in text
31 assert "Do not paste it to chat first" in text
32 assert "the chat handoff is the single user-visible" in text
33 assert "printf '📎 Shareable brief saved to %s\\n'" not in text
34 assert 'echo "📎 Shareable brief saved to $HTML_PATH"' not in text
35 assert "do **not** paste the full Markdown report back into chat" in text
36 assert "The user asked for an HTML deliverable" in text
37 assert "What do you want to do next?" in text
38 assert "1. Open HTML file" in text
39 assert "3. Done for now" in text
40
41
42 def test_html_handoff_opens_locally_without_os_command_menu():
43 text = SAVE_HTML.read_text(encoding="utf-8")
44 assert "Let the host choose the correct OS-specific mechanism" in text
45 assert "do not print a menu of shell commands" in text
46 assert "If opening fails or the host is headless" in text
47 assert 'xdg-open "<absolute HTML path>"' not in text
48 assert 'start "" "<absolute HTML path>"' not in text
49
50
51 def test_html_save_flow_does_not_publish_or_upload():
52 text = SAVE_HTML.read_text(encoding="utf-8")
53 assert "Do not upload in this flow unless the user chooses a publishing option" in text
54 assert "Do NOT publish, upload, or send the HTML to a third-party service" in text
55 assert "Do NOT block a local HTML export on a hosting decision" in text
56 assert "Show the saved path and next-step choices first" in text
57
58
59 def test_markdown_and_html_access_paths_are_separate():
60 text = SKILL_MD.read_text(encoding="utf-8")
61 start = text.index("**Saved artifact access flow:**")
62 section = text[start:start + 1600]
63
64 assert "**Markdown file requested:**" in section
65 assert "Do not offer hosted publishing for Markdown" in section
66 assert "**HTML file requested:**" in section
67 assert "show the absolute path" in section
68 assert "open the HTML file, publish to an available/preferred HTML publishing service, or done for now" in section
69
70
71 def test_follow_up_turn_preserves_html_deliverable_mode():
72 text = SAVE_HTML.read_text(encoding="utf-8")
73 assert "explicitly refers back to that visible synthesis" in text
74 assert "treat it as HTML-as-deliverable mode" in text
75 assert "Always report whichever path the redirect actually used in the chat handoff" in text
76
76 lines PYTHON