Files
claude/lib/tests/design-toolchain-reminder.test.sh
T
Bastien Chanot eab2a10cd5 fix(hooks): drop \bux\b from design-toolchain pattern (FR prose FPs)
3rd tightening pass (series LRN-1005/1007): bare "ux" matched inside
French prose (2 logged FPs, both FR — latest "changement ux vu").
\bui\b kept: zero logged FP, one logged true positive, now locked by a
must-fire test row. Flip-tested: quiet row fired pre-change.
2026-07-30 12:57:38 +02:00

46 lines
2.4 KiB
Bash

#!/usr/bin/env bash
# lib/tests/design-toolchain-reminder.test.sh
set -u
H="$(cd "$(dirname "$0")/../.." && pwd)/hooks/design-toolchain-reminder.sh"
pass=0; fail=0
check() { if [ "$2" = "$3" ]; then pass=$((pass+1)); else fail=$((fail+1));
printf 'FAIL %s: got[%s] want[%s]\n' "$1" "$2" "$3"; fi; }
# fire() -> "fire" if the hook emits the reminder, else "quiet".
fire() { if printf '{"prompt":"%s"}' "$1" | bash "$H" | grep -q 'full toolchain'; then
echo fire; else echo quiet; fi; }
# --- Dropped/neutralized tokens must be QUIET (non-UI senses) ---
check D1-design "$(fire 'a design decision for the API')" quiet
check D2-component "$(fire 'this system component')" quiet
check D3-composant "$(fire 'le composant backend')" quiet
check D4-theme "$(fire 'the theme of the audit')" quiet
check D5-transition "$(fire 'state transition to develop')" quiet
check D6-frontend "$(fire 'frontend architecture')" quiet
check D7-palette "$(fire 'a palette of options')" quiet
check D8-dash-file "$(fire 'ecc_dashboard.py')" quiet
# --- Harness-generated inputs must be QUIET even with UI tokens ---
check D9-tasknotif "$(fire '<task-notification> <task-id>x</task-id> add css header fonts')" quiet
check D10-notif-file "$(fire '<task-notification> design-motion-principles keyframe done')" quiet
check D11-bare-ux "$(fire 'changement ux vu de tes trouvailles')" quiet
# --- Real UI signals must still FIRE ---
check F1-button "$(fire 'add a button')" fire
check F2-navbar "$(fire 'the navbar layout')" fire
check F3-landing "$(fire 'build a landing page')" fire
check F4-glass "$(fire 'a glassmorphism card')" fire
check F5-redesign "$(fire 'redesign the app')" fire
check F6-frontdesign "$(fire 'frontend design work')" fire
check F7-admin-dash "$(fire 'admin dashboard screen')" fire
check F8-animation "$(fire 'add an animation')" fire
check F9-designsys "$(fire 'our design system')" fire
check F10-bare-ui "$(fire 'revois l'\''ui du panneau admin')" fire
# --- Fire is logged (time + token + excerpt) ---
tmp="$(mktemp -d)"
printf '{"prompt":"a glassmorphism card"}' | HOME="$tmp" bash "$H" >/dev/null 2>&1
check L1-logged "$(grep -c 'glassmorph' "$tmp/.claude/logs/design-toolchain-fires.log" 2>/dev/null)" 1
rm -rf "$tmp"
printf 'PASS=%s FAIL=%s\n' "$pass" "$fail"; [ "$fail" -eq 0 ]