test-plugin-loading.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. # Test 1: Verify plugin file exists and is registered
  12. echo "Test 1: Checking plugin registration..."
  13. if [ -L "$HOME/.config/opencode/plugins/superpowers.js" ]; then
  14. echo " [PASS] Plugin symlink exists"
  15. else
  16. echo " [FAIL] Plugin symlink not found at $HOME/.config/opencode/plugins/superpowers.js"
  17. exit 1
  18. fi
  19. # Verify symlink target exists
  20. if [ -f "$(readlink -f "$HOME/.config/opencode/plugins/superpowers.js")" ]; then
  21. echo " [PASS] Plugin symlink target exists"
  22. else
  23. echo " [FAIL] Plugin symlink target does not exist"
  24. exit 1
  25. fi
  26. # Test 2: Verify skills directory is populated
  27. echo "Test 2: Checking skills directory..."
  28. skill_count=$(find "$HOME/.config/opencode/superpowers/skills" -name "SKILL.md" | wc -l)
  29. if [ "$skill_count" -gt 0 ]; then
  30. echo " [PASS] Found $skill_count skills installed"
  31. else
  32. echo " [FAIL] No skills found in installed location"
  33. exit 1
  34. fi
  35. # Test 4: Check using-superpowers skill exists (critical for bootstrap)
  36. echo "Test 4: Checking using-superpowers skill (required for bootstrap)..."
  37. if [ -f "$HOME/.config/opencode/superpowers/skills/using-superpowers/SKILL.md" ]; then
  38. echo " [PASS] using-superpowers skill exists"
  39. else
  40. echo " [FAIL] using-superpowers skill not found (required for bootstrap)"
  41. exit 1
  42. fi
  43. # Test 5: Verify plugin JavaScript syntax (basic check)
  44. echo "Test 5: Checking plugin JavaScript syntax..."
  45. plugin_file="$HOME/.config/opencode/superpowers/.opencode/plugins/superpowers.js"
  46. if node --check "$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 6: Verify personal test skill was created
  53. echo "Test 6: Checking test fixtures..."
  54. if [ -f "$HOME/.config/opencode/skills/personal-test/SKILL.md" ]; then
  55. echo " [PASS] Personal test skill fixture created"
  56. else
  57. echo " [FAIL] Personal test skill fixture not found"
  58. exit 1
  59. fi
  60. echo ""
  61. echo "=== All plugin loading tests passed ==="