summaryrefslogtreecommitdiff
path: root/tests/opencode/test-plugin-loading.sh
diff options
context:
space:
mode:
authorJesse Vincent <jesse@fsck.com>2025-11-23 12:28:58 -0800
committerJesse Vincent <jesse@fsck.com>2025-11-23 12:28:58 -0800
commitf3d6c331a1950abb19ef1f28a78b01765ad1b873 (patch)
treeca3c38443b66345816a8a1557b7cc464f911eec6 /tests/opencode/test-plugin-loading.sh
parentb0ba2cf15afc786940c2cdd984962d4f7d278b4a (diff)
test: add automated test suite for opencode plugin
Create comprehensive tests in tests/opencode/ that verify the plugin works correctly in an isolated test environment: - setup.sh: Creates temp HOME and installs plugin with proper symlinks - test-plugin-loading.sh: Verifies plugin structure and JavaScript syntax - test-skills-core.sh: Unit tests for skills-core.js library functions - test-tools.sh: Integration tests for use_skill/find_skills (requires OpenCode) - test-priority.sh: Tests project > personal > superpowers priority - run-tests.sh: Main test runner with options for integration tests Run basic tests: ./tests/opencode/run-tests.sh Run all tests: ./tests/opencode/run-tests.sh --integration
Diffstat (limited to 'tests/opencode/test-plugin-loading.sh')
-rwxr-xr-xtests/opencode/test-plugin-loading.sh81
1 files changed, 81 insertions, 0 deletions
diff --git a/tests/opencode/test-plugin-loading.sh b/tests/opencode/test-plugin-loading.sh
new file mode 100755
index 0000000..11ae02b
--- /dev/null
+++ b/tests/opencode/test-plugin-loading.sh
@@ -0,0 +1,81 @@
+#!/usr/bin/env bash
+# Test: Plugin Loading
+# Verifies that the superpowers plugin loads correctly in OpenCode
+set -euo pipefail
+
+SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
+
+echo "=== Test: Plugin Loading ==="
+
+# Source setup to create isolated environment
+source "$SCRIPT_DIR/setup.sh"
+
+# Trap to cleanup on exit
+trap cleanup_test_env EXIT
+
+# Test 1: Verify plugin file exists and is registered
+echo "Test 1: Checking plugin registration..."
+if [ -L "$HOME/.config/opencode/plugin/superpowers.js" ]; then
+ echo " [PASS] Plugin symlink exists"
+else
+ echo " [FAIL] Plugin symlink not found at $HOME/.config/opencode/plugin/superpowers.js"
+ exit 1
+fi
+
+# Verify symlink target exists
+if [ -f "$(readlink -f "$HOME/.config/opencode/plugin/superpowers.js")" ]; then
+ echo " [PASS] Plugin symlink target exists"
+else
+ echo " [FAIL] Plugin symlink target does not exist"
+ exit 1
+fi
+
+# Test 2: Verify lib/skills-core.js is in place
+echo "Test 2: Checking skills-core.js..."
+if [ -f "$HOME/.config/opencode/superpowers/lib/skills-core.js" ]; then
+ echo " [PASS] skills-core.js exists"
+else
+ echo " [FAIL] skills-core.js not found"
+ exit 1
+fi
+
+# Test 3: Verify skills directory is populated
+echo "Test 3: Checking skills directory..."
+skill_count=$(find "$HOME/.config/opencode/superpowers/skills" -name "SKILL.md" | wc -l)
+if [ "$skill_count" -gt 0 ]; then
+ echo " [PASS] Found $skill_count skills installed"
+else
+ echo " [FAIL] No skills found in installed location"
+ exit 1
+fi
+
+# Test 4: Check using-superpowers skill exists (critical for bootstrap)
+echo "Test 4: Checking using-superpowers skill (required for bootstrap)..."
+if [ -f "$HOME/.config/opencode/superpowers/skills/using-superpowers/SKILL.md" ]; then
+ echo " [PASS] using-superpowers skill exists"
+else
+ echo " [FAIL] using-superpowers skill not found (required for bootstrap)"
+ exit 1
+fi
+
+# Test 5: Verify plugin JavaScript syntax (basic check)
+echo "Test 5: Checking plugin JavaScript syntax..."
+plugin_file="$HOME/.config/opencode/superpowers/.opencode/plugin/superpowers.js"
+if node --check "$plugin_file" 2>/dev/null; then
+ echo " [PASS] Plugin JavaScript syntax is valid"
+else
+ echo " [FAIL] Plugin has JavaScript syntax errors"
+ exit 1
+fi
+
+# Test 6: Verify personal test skill was created
+echo "Test 6: Checking test fixtures..."
+if [ -f "$HOME/.config/opencode/skills/personal-test/SKILL.md" ]; then
+ echo " [PASS] Personal test skill fixture created"
+else
+ echo " [FAIL] Personal test skill fixture not found"
+ exit 1
+fi
+
+echo ""
+echo "=== All plugin loading tests passed ==="