Browse Source

merge: summon test suite truthful green

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
0xDarkMatter 6 days ago
parent
commit
05baa19f2e
2 changed files with 37 additions and 16 deletions
  1. 5 16
      skills/summon/tests/run.sh
  2. 32 0
      skills/summon/tests/test_summon.py

+ 5 - 16
skills/summon/tests/run.sh

@@ -11,32 +11,21 @@
 # no real LLM call is ever made by this suite), the pick --json inventory
 # envelope, and the in-chat picker asset (present + cited from SKILL.md).
 #
+# All checks live in test_summon.py so its pass/fail summary IS the whole
+# suite — no shell-level checks that could fail outside the counter.
+#
 # Usage:   bash tests/run.sh
 # Exit:    0 all pass, 1 one or more failures
 
 set -uo pipefail
 
 HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-FAILED=0
-
-# --- In-chat picker asset: file present, INJECT block intact, cited from SKILL.md
-ASSET="$HERE/../assets/picker-widget.html"
-if [[ -f "$ASSET" ]] \
-    && grep -q ">>> INJECT" "$ASSET" \
-    && grep -q "sendPrompt" "$ASSET" \
-    && grep -q "assets/picker-widget.html" "$HERE/../SKILL.md"; then
-  echo "  PASS  picker-widget.html asset present + INJECT block + cited from SKILL.md"
-else
-  echo "  FAIL  picker-widget.html asset present + INJECT block + cited from SKILL.md"
-  FAILED=1
-fi
 
 # Pick a python that actually executes — skips the Windows Store python3 stub.
 PYTHON=""
 for c in python python3 py; do
   if command -v "$c" >/dev/null 2>&1 && "$c" -c "" >/dev/null 2>&1; then PYTHON="$c"; break; fi
 done
-[[ -z "$PYTHON" ]] && { echo "no working python found — skipping python suite" >&2; exit "$FAILED"; }
+[[ -z "$PYTHON" ]] && { echo "no working python found" >&2; exit 1; }
 
-"$PYTHON" "$HERE/test_summon.py" || FAILED=1
-exit "$FAILED"
+exec "$PYTHON" "$HERE/test_summon.py"

+ 32 - 0
skills/summon/tests/test_summon.py

@@ -47,6 +47,10 @@ Pick --json (the in-chat visual picker's data feed):
       get worktree ""; brokenCwd flags the session whose recorded cwd is gone;
       transcriptPath is resolved (scan fallback included) and ISO timestamps
       parse
+
+In-chat picker asset:
+  23. assets/picker-widget.html exists, carries the <script id="D"> injection
+      block + sendPrompt wiring, and is cited from SKILL.md
 """
 
 from __future__ import annotations
@@ -649,6 +653,31 @@ def pick_json_tests() -> None:
         shutil.rmtree(tmp, ignore_errors=True)
 
 
+def asset_tests() -> None:
+    """In-chat picker asset: present, injectable, and cited from SKILL.md.
+
+    The injection marker is the `<script id="D">` JSON block (the original
+    `>>> INJECT <<<` comment was replaced when the card picker was rebuilt
+    in 551292e) — keep this assertion in sync with SKILL.md's render step.
+    """
+    name = "picker-widget.html asset present + <script id=\"D\"> block + cited from SKILL.md"
+    asset = HERE.parent / "assets" / "picker-widget.html"
+    skill = HERE.parent / "SKILL.md"
+    checks = {}
+    checks["asset exists"] = asset.is_file()
+    if checks["asset exists"]:
+        html = asset.read_text(encoding="utf-8")
+        checks["script id=D block"] = '<script id="D"' in html
+        checks["sendPrompt wiring"] = "sendPrompt" in html
+    checks["cited from SKILL.md"] = (
+        skill.is_file() and "assets/picker-widget.html" in skill.read_text(encoding="utf-8")
+    )
+    if all(checks.values()):
+        ok(name)
+    else:
+        no(name, f"failed={[k for k, v in checks.items() if not v]}")
+
+
 def main() -> int:
     # 1. Piped selection honoured even with --yes (the original bug: --yes
     #    used to select ALL candidates, ignoring the piped picks).
@@ -754,6 +783,9 @@ def main() -> int:
     # 21-22. pick --json: envelope, clean stdout, worktree split, brokenCwd
     pick_json_tests()
 
+    # 23. In-chat picker asset: present + injectable + cited from SKILL.md
+    asset_tests()
+
     print(f"\nsummon tests: {PASS} passed, {FAIL} failed")
     return 1 if FAIL else 0