test-plugin-loading.sh 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/usr/bin/env bash
  2. # Test: Plugin Loading
  3. # Verifies that the superpowers plugin loads correctly in OpenCode
  4. set -euo pipefail
  5. SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
  6. echo "=== Test: Plugin Loading ==="
  7. # Source setup to create isolated environment
  8. source "$SCRIPT_DIR/setup.sh"
  9. # Trap to cleanup on exit
  10. trap cleanup_test_env EXIT
  11. plugin_link="$OPENCODE_CONFIG_DIR/plugins/superpowers.js"
  12. # Test 1: Verify plugin file exists and is registered
  13. echo "Test 1: Checking plugin registration..."
  14. if [ -L "$plugin_link" ]; then
  15. echo " [PASS] Plugin symlink exists"
  16. else
  17. echo " [FAIL] Plugin symlink not found at $plugin_link"
  18. exit 1
  19. fi
  20. # Verify symlink target exists
  21. if [ -f "$(readlink -f "$plugin_link")" ]; then
  22. echo " [PASS] Plugin symlink target exists"
  23. else
  24. echo " [FAIL] Plugin symlink target does not exist"
  25. exit 1
  26. fi
  27. # Test 2: Verify skills directory is populated
  28. echo "Test 2: Checking skills directory..."
  29. skill_count=$(find "$SUPERPOWERS_SKILLS_DIR" -name "SKILL.md" | wc -l)
  30. if [ "$skill_count" -gt 0 ]; then
  31. echo " [PASS] Found $skill_count skills"
  32. else
  33. echo " [FAIL] No skills found in $SUPERPOWERS_SKILLS_DIR"
  34. exit 1
  35. fi
  36. # Test 3: Check using-superpowers skill exists (critical for bootstrap)
  37. echo "Test 3: Checking using-superpowers skill (required for bootstrap)..."
  38. if [ -f "$SUPERPOWERS_SKILLS_DIR/using-superpowers/SKILL.md" ]; then
  39. echo " [PASS] using-superpowers skill exists"
  40. else
  41. echo " [FAIL] using-superpowers skill not found (required for bootstrap)"
  42. exit 1
  43. fi
  44. # Test 4: Verify plugin JavaScript syntax (basic check)
  45. echo "Test 4: Checking plugin JavaScript syntax..."
  46. if node --check "$SUPERPOWERS_PLUGIN_FILE" 2>/dev/null; then
  47. echo " [PASS] Plugin JavaScript syntax is valid"
  48. else
  49. echo " [FAIL] Plugin has JavaScript syntax errors"
  50. exit 1
  51. fi
  52. # Test 5: Verify bootstrap text does not reference a hardcoded skills path
  53. echo "Test 5: Checking bootstrap does not advertise a wrong skills path..."
  54. if grep -q 'configDir}/skills/superpowers/' "$SUPERPOWERS_PLUGIN_FILE"; then
  55. echo " [FAIL] Plugin still references old configDir skills path"
  56. exit 1
  57. else
  58. echo " [PASS] Plugin does not advertise a misleading skills path"
  59. fi
  60. # Test 6: Verify personal test skill was created
  61. echo "Test 6: Checking test fixtures..."
  62. if [ -f "$OPENCODE_CONFIG_DIR/skills/personal-test/SKILL.md" ]; then
  63. echo " [PASS] Personal test skill fixture created"
  64. else
  65. echo " [FAIL] Personal test skill fixture not found"
  66. exit 1
  67. fi
  68. echo ""
  69. echo "=== All plugin loading tests passed ==="