|
| 1 | +#!/usr/bin/env bash |
| 2 | +# tests/skills/test-bug-close-reason-guidance.sh |
| 3 | +# Validates that agent-facing documentation includes --reason flag guidance |
| 4 | +# when closing bug tickets. |
| 5 | +# |
| 6 | +# Bug: 42c6-7dc0 — Agents attempt to close bug tickets without --reason flag. |
| 7 | +# |
| 8 | +# Usage: bash tests/skills/test-bug-close-reason-guidance.sh |
| 9 | + |
| 10 | +set -uo pipefail |
| 11 | + |
| 12 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 13 | +REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" |
| 14 | + |
| 15 | +source "$REPO_ROOT/tests/lib/assert.sh" |
| 16 | + |
| 17 | +CLAUDE_MD="$REPO_ROOT/CLAUDE.md" |
| 18 | +FIX_BUG_SKILL="$REPO_ROOT/plugins/dso/skills/fix-bug/SKILL.md" |
| 19 | +END_SESSION_SKILL="$REPO_ROOT/plugins/dso/skills/end-session/SKILL.md" |
| 20 | + |
| 21 | +# ============================================================================= |
| 22 | +# Test 1: CLAUDE.md mentions --reason for bug ticket closure |
| 23 | +# The primary agent instruction file must mention that bug tickets require |
| 24 | +# --reason when closing. |
| 25 | +# ============================================================================= |
| 26 | +echo "" |
| 27 | +echo "--- test_claude_md_mentions_reason_for_bug_close ---" |
| 28 | +_snapshot_fail |
| 29 | + |
| 30 | +_CMD_HAS_REASON="not_found" |
| 31 | +grep -q '\-\-reason.*Fixed\|Fixed.*\-\-reason\|bug.*--reason\|--reason.*bug' "$CLAUDE_MD" 2>/dev/null && _CMD_HAS_REASON="found" |
| 32 | +assert_eq "test_claude_md_mentions_reason_for_bug_close" "found" "$_CMD_HAS_REASON" |
| 33 | + |
| 34 | +assert_pass_if_clean "test_claude_md_mentions_reason_for_bug_close" |
| 35 | + |
| 36 | +# ============================================================================= |
| 37 | +# Test 2: fix-bug SKILL.md Step 8 includes --reason in close command |
| 38 | +# The fix-bug skill's commit/close step must use --reason="Fixed: ..." |
| 39 | +# ============================================================================= |
| 40 | +echo "" |
| 41 | +echo "--- test_fix_bug_step8_includes_reason ---" |
| 42 | +_snapshot_fail |
| 43 | + |
| 44 | +_FB_HAS_REASON="not_found" |
| 45 | +grep -q 'transition.*closed.*--reason\|--reason.*Fixed' "$FIX_BUG_SKILL" 2>/dev/null && _FB_HAS_REASON="found" |
| 46 | +assert_eq "test_fix_bug_step8_includes_reason" "found" "$_FB_HAS_REASON" |
| 47 | + |
| 48 | +assert_pass_if_clean "test_fix_bug_step8_includes_reason" |
| 49 | + |
| 50 | +# ============================================================================= |
| 51 | +# Test 3: end-session SKILL.md mentions --reason for bug closure |
| 52 | +# The end-session skill closes issues in Step 2 and must mention --reason |
| 53 | +# for bug tickets. |
| 54 | +# ============================================================================= |
| 55 | +echo "" |
| 56 | +echo "--- test_end_session_mentions_reason_for_bugs ---" |
| 57 | +_snapshot_fail |
| 58 | + |
| 59 | +_ES_HAS_REASON="not_found" |
| 60 | +grep -q '\-\-reason.*Fixed\|Fixed.*\-\-reason\|bug.*--reason\|--reason.*bug' "$END_SESSION_SKILL" 2>/dev/null && _ES_HAS_REASON="found" |
| 61 | +assert_eq "test_end_session_mentions_reason_for_bugs" "found" "$_ES_HAS_REASON" |
| 62 | + |
| 63 | +assert_pass_if_clean "test_end_session_mentions_reason_for_bugs" |
| 64 | + |
| 65 | +# ============================================================================= |
| 66 | +# Test 4: CLAUDE.md Task Completion Workflow includes --reason |
| 67 | +# The Task Completion section (step 4) must show --reason for bug tickets. |
| 68 | +# ============================================================================= |
| 69 | +echo "" |
| 70 | +echo "--- test_claude_md_completion_workflow_includes_reason ---" |
| 71 | +_snapshot_fail |
| 72 | + |
| 73 | +# The task completion workflow section should mention --reason near the |
| 74 | +# ticket transition close command |
| 75 | +_CW_HAS_REASON="not_found" |
| 76 | +# Look for --reason within the Task Completion Workflow section (lines ~155-165) |
| 77 | +sed -n '155,170p' "$CLAUDE_MD" | grep -q '\-\-reason' 2>/dev/null && _CW_HAS_REASON="found" |
| 78 | +assert_eq "test_claude_md_completion_workflow_includes_reason" "found" "$_CW_HAS_REASON" |
| 79 | + |
| 80 | +assert_pass_if_clean "test_claude_md_completion_workflow_includes_reason" |
| 81 | + |
| 82 | +# ============================================================================= |
| 83 | +print_summary |
0 commit comments