#!/bin/bash # test_visual_artifacts_md.sh - Verify bundle/context/visual-artifacts.md (task-6) # RED: Run before file is created (should fail) # GREEN: Run after file is created (should pass) REPO=/home/ken/workspace/research-workbench PASS=0 FAIL=0 check_file_exists() { local path="$1" if [ -f "$REPO/$path" ]; then echo "PASS: '$path' exists" ((PASS++)) else echo "FAIL: '$path' should exist but is missing" ((FAIL++)) fi } check_contains() { local file="$1" local description="$2" local pattern="$3" if grep -qF -- "$pattern" "$REPO/$file" 2>/dev/null; then echo "PASS: $file contains '$description'" ((PASS++)) else echo "FAIL: $file is missing '$description'" ((FAIL++)) fi } check_regex() { local file="$1" local description="$2" local pattern="$3" if grep -qE "$pattern" "$REPO/$file" 2>/dev/null; then echo "PASS: $file matches '$description'" ((PASS++)) else echo "FAIL: $file is missing '$description' (pattern: $pattern)" ((FAIL++)) fi } TARGET="bundle/context/visual-artifacts.md" # ───────────────────────────────────────────────────────────────────────────── # File existence # ───────────────────────────────────────────────────────────────────────────── echo "=== Checking $TARGET exists ===" check_file_exists "$TARGET" # ───────────────────────────────────────────────────────────────────────────── # Intro section # ───────────────────────────────────────────────────────────────────────────── echo "" echo "=== Checking Intro section ===" check_regex "$TARGET" "intro / overview heading" "^# |^## " check_contains "$TARGET" "visual fenced code block tag" '```visual' check_regex "$TARGET" "sandboxed iframe mention" 'sandbox|iframe|sandboxed' check_regex "$TARGET" "pre-loaded libraries mention" 'pre.loaded|preloaded|pre-loaded' # ───────────────────────────────────────────────────────────────────────────── # When to Generate section # ───────────────────────────────────────────────────────────────────────────── echo "" echo "=== Checking When to Generate section ===" check_regex "$TARGET" "When to Generate heading" 'When to Generate|When to Use' check_regex "$TARGET" "comparing options trigger" 'compar' check_regex "$TARGET" "trends trigger" 'trend' check_regex "$TARGET" "locations trigger" 'locat' check_regex "$TARGET" "scoring/ranking trigger" 'scor|rank' check_regex "$TARGET" "budget/breakdown trigger" 'budget|breakdown' check_regex "$TARGET" "dashboard trigger" 'dashboard' check_regex "$TARGET" "proactive / don't wait to be asked" "proactive|don.t wait|without being asked" # ───────────────────────────────────────────────────────────────────────────── # Available Libraries section # ───────────────────────────────────────────────────────────────────────────── echo "" echo "=== Checking Available Libraries section ===" check_regex "$TARGET" "Available Libraries heading" 'Available Lib|Libraries.*pre' check_regex "$TARGET" "Tabler CSS entry" 'Tabler' check_regex "$TARGET" "Chart.js entry" 'Chart\.js|Chart' check_contains "$TARGET" "Chart global variable" '`Chart`' check_regex "$TARGET" "Leaflet.js entry" 'Leaflet' check_contains "$TARGET" "L global variable" '`L`' check_regex "$TARGET" "React v19 entry" 'React.*19|React v19' check_contains "$TARGET" "React global" '`React`' check_contains "$TARGET" "ReactDOM global" '`ReactDOM`' check_regex "$TARGET" "Babel entry" 'Babel' check_regex "$TARGET" "JSX compilation" 'JSX|jsx' # ───────────────────────────────────────────────────────────────────────────── # Output Format section # ───────────────────────────────────────────────────────────────────────────── echo "" echo "=== Checking Output Format section ===" check_regex "$TARGET" "Output Format heading" 'Output Format' check_contains "$TARGET" "visual tag in output example" '```visual' check_regex "$TARGET" "title field" '"title"' check_regex "$TARGET" "code field" '"code"' check_regex "$TARGET" "data field" '"data"' check_regex "$TARGET" "height field" '"height"' check_regex "$TARGET" "height default 300" '300' check_regex "$TARGET" "height max 800" '800' # ───────────────────────────────────────────────────────────────────────────── # Code Formats section # ───────────────────────────────────────────────────────────────────────────── echo "" echo "=== Checking Code Formats section ===" check_regex "$TARGET" "Code Formats heading" 'Code Format' check_regex "$TARGET" "JSX auto-detection" 'JSX|React.*detect|detect.*React' check_regex "$TARGET" "HTML detection" 'HTML.*detect|detect.*HTML|