test-plugin-loading.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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/plugin/superpowers.js" ]; then
  14. echo " [PASS] Plugin symlink exists"
  15. else
  16. echo " [FAIL] Plugin symlink not found at $HOME/.config/opencode/plugin/superpowers.js"
  17. exit 1
  18. fi
  19. # Verify symlink target exists
  20. if [ -f "$(readlink -f "$HOME/.config/opencode/plugin/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 lib/skills-core.js is in place
  27. echo "Test 2: Checking skills-core.js..."
  28. if [ -f "$HOME/.config/opencode/superpowers/lib/skills-core.js" ]; then
  29. echo " [PASS] skills-core.js exists"
  30. else
  31. echo " [FAIL] skills-core.js not found"
  32. exit 1
  33. fi
  34. # Test 3: Verify skills directory is populated
  35. echo "Test 3: Checking skills directory..."
  36. skill_count=$(find "$HOME/.config/opencode/superpowers/skills" -name "SKILL.md" | wc -l)
  37. if [ "$skill_count" -gt 0 ]; then
  38. echo " [PASS] Found $skill_count skills installed"
  39. else
  40. echo " [FAIL] No skills found in installed location"
  41. exit 1
  42. fi
  43. # Test 4: Check using-superpowers skill exists (critical for bootstrap)
  44. echo "Test 4: Checking using-superpowers skill (required for bootstrap)..."
  45. if [ -f "$HOME/.config/opencode/superpowers/skills/using-superpowers/SKILL.md" ]; then
  46. echo " [PASS] using-superpowers skill exists"
  47. else
  48. echo " [FAIL] using-superpowers skill not found (required for bootstrap)"
  49. exit 1
  50. fi
  51. # Test 5: Verify plugin JavaScript syntax (basic check)
  52. echo "Test 5: Checking plugin JavaScript syntax..."
  53. plugin_file="$HOME/.config/opencode/superpowers/.opencode/plugin/superpowers.js"
  54. if node --check "$plugin_file" 2>/dev/null; then
  55. echo " [PASS] Plugin JavaScript syntax is valid"
  56. else
  57. echo " [FAIL] Plugin has JavaScript syntax errors"
  58. exit 1
  59. fi
  60. # Test 6: Verify personal test skill was created
  61. echo "Test 6: Checking test fixtures..."
  62. if [ -f "$HOME/.config/opencode/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 ==="