test-document-review-system.sh 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. #!/usr/bin/env bash
  2. # Integration Test: Document Review System
  3. # Actually runs spec/plan review and verifies reviewers catch issues
  4. set -euo pipefail
  5. SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
  6. source "$SCRIPT_DIR/test-helpers.sh"
  7. echo "========================================"
  8. echo " Integration Test: Document Review System"
  9. echo "========================================"
  10. echo ""
  11. echo "This test verifies the document review system by:"
  12. echo " 1. Creating a spec with intentional errors"
  13. echo " 2. Running the spec document reviewer"
  14. echo " 3. Verifying the reviewer catches the errors"
  15. echo ""
  16. # Create test project
  17. TEST_PROJECT=$(create_test_project)
  18. echo "Test project: $TEST_PROJECT"
  19. # Trap to cleanup
  20. trap "cleanup_test_project $TEST_PROJECT" EXIT
  21. cd "$TEST_PROJECT"
  22. # Create directory structure
  23. mkdir -p docs/superpowers/specs
  24. # Create a spec document WITH INTENTIONAL ERRORS for the reviewer to catch
  25. cat > docs/superpowers/specs/test-feature-design.md <<'EOF'
  26. # Test Feature Design
  27. ## Overview
  28. This is a test feature that does something useful.
  29. ## Requirements
  30. 1. The feature should work correctly
  31. 2. It should be fast
  32. 3. TODO: Add more requirements here
  33. ## Architecture
  34. The feature will use a simple architecture with:
  35. - A frontend component
  36. - A backend service
  37. - Error handling will be specified later once we understand the failure modes better
  38. ## Data Flow
  39. Data flows from the frontend to the backend.
  40. ## Testing Strategy
  41. Tests will be written to cover the main functionality.
  42. EOF
  43. # Initialize git repo
  44. git init --quiet
  45. git config user.email "test@test.com"
  46. git config user.name "Test User"
  47. git add .
  48. git commit -m "Initial commit with test spec" --quiet
  49. echo ""
  50. echo "Created test spec with intentional errors:"
  51. echo " - TODO placeholder in Requirements section"
  52. echo " - 'specified later' deferral in Architecture section"
  53. echo ""
  54. echo "Running spec document reviewer..."
  55. echo ""
  56. # Run Claude to review the spec
  57. OUTPUT_FILE="$TEST_PROJECT/claude-output.txt"
  58. PROMPT="You are testing the spec document reviewer.
  59. Read the spec-document-reviewer-prompt.md template in skills/brainstorming/ to understand the review format.
  60. Then review the spec at $TEST_PROJECT/docs/superpowers/specs/test-feature-design.md using the criteria from that template.
  61. Look for:
  62. - TODOs, placeholders, 'TBD', incomplete sections
  63. - Sections saying 'to be defined later' or 'will spec when X is done'
  64. - Sections noticeably less detailed than others
  65. Output your review in the format specified in the template."
  66. echo "================================================================================"
  67. cd "$SCRIPT_DIR/../.." && timeout 120 claude -p "$PROMPT" --permission-mode bypassPermissions 2>&1 | tee "$OUTPUT_FILE" || {
  68. echo ""
  69. echo "================================================================================"
  70. echo "EXECUTION FAILED (exit code: $?)"
  71. exit 1
  72. }
  73. echo "================================================================================"
  74. echo ""
  75. echo "Analyzing reviewer output..."
  76. echo ""
  77. # Verification tests
  78. FAILED=0
  79. echo "=== Verification Tests ==="
  80. echo ""
  81. # Test 1: Reviewer found the TODO
  82. echo "Test 1: Reviewer found TODO..."
  83. if grep -qi "TODO" "$OUTPUT_FILE" && grep -qi "requirements\|Requirements" "$OUTPUT_FILE"; then
  84. echo " [PASS] Reviewer identified TODO in Requirements section"
  85. else
  86. echo " [FAIL] Reviewer did not identify TODO"
  87. FAILED=$((FAILED + 1))
  88. fi
  89. echo ""
  90. # Test 2: Reviewer found the "specified later" deferral
  91. echo "Test 2: Reviewer found 'specified later' deferral..."
  92. if grep -qi "specified later\|later\|defer\|incomplete\|error handling" "$OUTPUT_FILE"; then
  93. echo " [PASS] Reviewer identified deferred content"
  94. else
  95. echo " [FAIL] Reviewer did not identify deferred content"
  96. FAILED=$((FAILED + 1))
  97. fi
  98. echo ""
  99. # Test 3: Reviewer output includes Issues section
  100. echo "Test 3: Review output format..."
  101. if grep -qi "issues\|Issues" "$OUTPUT_FILE"; then
  102. echo " [PASS] Review includes Issues section"
  103. else
  104. echo " [FAIL] Review missing Issues section"
  105. FAILED=$((FAILED + 1))
  106. fi
  107. echo ""
  108. # Test 4: Reviewer did NOT approve (found issues)
  109. echo "Test 4: Reviewer verdict..."
  110. if grep -qi "Issues Found\|❌\|not approved\|issues found" "$OUTPUT_FILE"; then
  111. echo " [PASS] Reviewer correctly found issues (not approved)"
  112. elif grep -qi "Approved\|✅" "$OUTPUT_FILE" && ! grep -qi "Issues Found\|❌" "$OUTPUT_FILE"; then
  113. echo " [FAIL] Reviewer incorrectly approved spec with errors"
  114. FAILED=$((FAILED + 1))
  115. else
  116. echo " [PASS] Reviewer identified problems (ambiguous format but found issues)"
  117. fi
  118. echo ""
  119. # Summary
  120. echo "========================================"
  121. echo " Test Summary"
  122. echo "========================================"
  123. echo ""
  124. if [ $FAILED -eq 0 ]; then
  125. echo "STATUS: PASSED"
  126. echo "All verification tests passed!"
  127. echo ""
  128. echo "The spec document reviewer correctly:"
  129. echo " ✓ Found TODO placeholder"
  130. echo " ✓ Found 'specified later' deferral"
  131. echo " ✓ Produced properly formatted review"
  132. echo " ✓ Did not approve spec with errors"
  133. exit 0
  134. else
  135. echo "STATUS: FAILED"
  136. echo "Failed $FAILED verification tests"
  137. echo ""
  138. echo "Output saved to: $OUTPUT_FILE"
  139. echo ""
  140. echo "Review the output to see what went wrong."
  141. exit 1
  142. fi