|
| 1 | +# Manual Testing Guide - Slack Notification Module |
| 2 | + |
| 3 | +This guide provides curl-based tests so you can verify your implementation without setting up a full GitHub repository and Actions workflow. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +1. MCP server running: `uv run server.py` |
| 8 | +2. Webhook server running: `python webhook_server.py` |
| 9 | +3. Slack webhook URL set: `export SLACK_WEBHOOK_URL="https://hooks.slack.com/services/..."` |
| 10 | + |
| 11 | +## Test 1: Direct Slack Tool Test |
| 12 | + |
| 13 | +Test your `send_slack_notification` tool directly via Claude Code: |
| 14 | + |
| 15 | +```bash |
| 16 | +# Start your MCP server and connect with Claude Code, then ask: |
| 17 | +# "Send a test message to Slack: 'Hello from MCP Course Module 3!'" |
| 18 | +``` |
| 19 | + |
| 20 | +Expected result: Message appears in your Slack channel. |
| 21 | + |
| 22 | +## Test 2: Simulate GitHub Webhook Events |
| 23 | + |
| 24 | +### 2a. Simulate CI Failure Event |
| 25 | + |
| 26 | +Send a fake GitHub Actions failure event to your webhook server: |
| 27 | + |
| 28 | +```bash |
| 29 | +curl -X POST http://localhost:8080/webhook/github \ |
| 30 | + -H "Content-Type: application/json" \ |
| 31 | + -H "X-GitHub-Event: workflow_run" \ |
| 32 | + -d '{ |
| 33 | + "action": "completed", |
| 34 | + "workflow_run": { |
| 35 | + "id": 123456789, |
| 36 | + "name": "CI", |
| 37 | + "status": "completed", |
| 38 | + "conclusion": "failure", |
| 39 | + "run_number": 42, |
| 40 | + "created_at": "2024-01-15T10:30:00Z", |
| 41 | + "updated_at": "2024-01-15T10:35:00Z", |
| 42 | + "html_url": "https://github.com/user/repo/actions/runs/123456789", |
| 43 | + "head_branch": "feature/slack-integration", |
| 44 | + "head_sha": "abc123f456789", |
| 45 | + "repository": { |
| 46 | + "name": "mcp-course", |
| 47 | + "full_name": "user/mcp-course", |
| 48 | + "html_url": "https://github.com/user/mcp-course" |
| 49 | + }, |
| 50 | + "pull_requests": [{ |
| 51 | + "number": 42, |
| 52 | + "url": "https://api.github.com/repos/user/mcp-course/pulls/42", |
| 53 | + "html_url": "https://github.com/user/mcp-course/pull/42" |
| 54 | + }] |
| 55 | + } |
| 56 | + }' |
| 57 | +``` |
| 58 | + |
| 59 | +### 2b. Simulate CI Success Event |
| 60 | + |
| 61 | +```bash |
| 62 | +curl -X POST http://localhost:8080/webhook/github \ |
| 63 | + -H "Content-Type: application/json" \ |
| 64 | + -H "X-GitHub-Event: workflow_run" \ |
| 65 | + -d '{ |
| 66 | + "action": "completed", |
| 67 | + "workflow_run": { |
| 68 | + "id": 123456790, |
| 69 | + "name": "Deploy", |
| 70 | + "status": "completed", |
| 71 | + "conclusion": "success", |
| 72 | + "run_number": 43, |
| 73 | + "created_at": "2024-01-15T11:30:00Z", |
| 74 | + "updated_at": "2024-01-15T11:35:00Z", |
| 75 | + "html_url": "https://github.com/user/repo/actions/runs/123456790", |
| 76 | + "head_branch": "main", |
| 77 | + "head_sha": "def456g789012", |
| 78 | + "repository": { |
| 79 | + "name": "mcp-course", |
| 80 | + "full_name": "user/mcp-course", |
| 81 | + "html_url": "https://github.com/user/mcp-course" |
| 82 | + }, |
| 83 | + "pull_requests": [{ |
| 84 | + "number": 43, |
| 85 | + "url": "https://api.github.com/repos/user/mcp-course/pulls/43", |
| 86 | + "html_url": "https://github.com/user/mcp-course/pull/43" |
| 87 | + }] |
| 88 | + } |
| 89 | + }' |
| 90 | +``` |
| 91 | + |
| 92 | +## Test 3: End-to-End Workflow Tests |
| 93 | + |
| 94 | +After sending the webhook events above, test the complete workflow via Claude Code: |
| 95 | + |
| 96 | +### 3a. Test Failure Alert Workflow |
| 97 | + |
| 98 | +Ask Claude Code: |
| 99 | +``` |
| 100 | +"Check recent CI events, find any failures, format them as a Slack alert, and send to the team" |
| 101 | +``` |
| 102 | + |
| 103 | +Expected workflow: |
| 104 | +1. Claude calls `get_recent_actions_events()` → finds failure event |
| 105 | +2. Claude calls `format_ci_failure_alert()` → generates formatted message |
| 106 | +3. Claude calls `send_slack_notification()` → sends to Slack |
| 107 | + |
| 108 | +Expected Slack message: |
| 109 | +``` |
| 110 | +❌ *CI Failed* - mcp-course |
| 111 | +
|
| 112 | +> CI workflow failed on feature/slack-integration |
| 113 | +
|
| 114 | +*Details:* |
| 115 | +• Workflow: `CI` |
| 116 | +• Branch: `feature/slack-integration` |
| 117 | +• Commit: `abc123f` |
| 118 | +
|
| 119 | +*Next Steps:* |
| 120 | +• <https://github.com/user/mcp-course/pull/42|View Pull Request> |
| 121 | +• <https://github.com/user/repo/actions/runs/123456789|Check Action Logs> |
| 122 | +``` |
| 123 | + |
| 124 | +### 3b. Test Success Summary Workflow |
| 125 | + |
| 126 | +Ask Claude Code: |
| 127 | +``` |
| 128 | +"Check recent CI events, find any successful deployments, format them as a celebration message, and send to the team" |
| 129 | +``` |
| 130 | + |
| 131 | +Expected workflow: |
| 132 | +1. Claude calls `get_recent_actions_events()` → finds success event |
| 133 | +2. Claude calls `format_ci_success_summary()` → generates formatted message |
| 134 | +3. Claude calls `send_slack_notification()` → sends to Slack |
| 135 | + |
| 136 | +Expected Slack message: |
| 137 | +``` |
| 138 | +✅ *Deployment Successful* - mcp-course |
| 139 | +
|
| 140 | +> Deploy workflow completed successfully on main |
| 141 | +
|
| 142 | +*Changes:* |
| 143 | +• Module 3 Slack integration added |
| 144 | +• Team notification system implemented |
| 145 | +
|
| 146 | +*Links:* |
| 147 | +• <https://github.com/user/mcp-course/pull/43|View Changes> |
| 148 | +• <https://github.com/user/mcp-course|Visit Repository> |
| 149 | +``` |
| 150 | + |
| 151 | +## Test 4: Error Handling Tests |
| 152 | + |
| 153 | +### 4a. Test Missing Webhook URL |
| 154 | + |
| 155 | +```bash |
| 156 | +# Temporarily unset the environment variable |
| 157 | +unset SLACK_WEBHOOK_URL |
| 158 | + |
| 159 | +# Ask Claude Code to send a message |
| 160 | +# Expected: Error message about missing environment variable |
| 161 | +``` |
| 162 | + |
| 163 | +### 4b. Test Invalid Webhook URL |
| 164 | + |
| 165 | +```bash |
| 166 | +# Set invalid webhook URL |
| 167 | +export SLACK_WEBHOOK_URL="https://invalid-webhook-url.com/test" |
| 168 | + |
| 169 | +# Ask Claude Code to send a message |
| 170 | +# Expected: Error message about connection failure |
| 171 | +``` |
| 172 | + |
| 173 | +### 4c. Restore Valid Webhook URL |
| 174 | + |
| 175 | +```bash |
| 176 | +export SLACK_WEBHOOK_URL="https://hooks.slack.com/services/YOUR/ACTUAL/URL" |
| 177 | +``` |
| 178 | + |
| 179 | +## Test 5: Prompt-Only Tests |
| 180 | + |
| 181 | +Test the formatting prompts without sending to Slack: |
| 182 | + |
| 183 | +### 5a. Test Failure Alert Prompt |
| 184 | + |
| 185 | +Ask Claude Code: |
| 186 | +``` |
| 187 | +"Use the format_ci_failure_alert prompt to create a failure message for the recent CI failure, but don't send it to Slack yet" |
| 188 | +``` |
| 189 | + |
| 190 | +### 5b. Test Success Summary Prompt |
| 191 | + |
| 192 | +Ask Claude Code: |
| 193 | +``` |
| 194 | +"Use the format_ci_success_summary prompt to create a success message for the recent deployment, but don't send it to Slack yet" |
| 195 | +``` |
| 196 | + |
| 197 | +## Test 6: Integration with Previous Modules |
| 198 | + |
| 199 | +Test that all previous module functionality still works: |
| 200 | + |
| 201 | +### 6a. Module 1 Integration |
| 202 | + |
| 203 | +Ask Claude Code: |
| 204 | +``` |
| 205 | +"Analyze current file changes, suggest a PR template, then create a Slack message about the PR status" |
| 206 | +``` |
| 207 | + |
| 208 | +### 6b. Module 2 Integration |
| 209 | + |
| 210 | +Ask Claude Code: |
| 211 | +``` |
| 212 | +"Check workflow status, analyze the CI results, and create a comprehensive team update for Slack" |
| 213 | +``` |
| 214 | + |
| 215 | +## Verification Checklist |
| 216 | + |
| 217 | +After running these tests, verify: |
| 218 | + |
| 219 | +- [ ] Direct Slack tool works (Test 1) |
| 220 | +- [ ] Webhook server receives and stores events (Test 2) |
| 221 | +- [ ] Failure alert workflow works end-to-end (Test 3a) |
| 222 | +- [ ] Success summary workflow works end-to-end (Test 3b) |
| 223 | +- [ ] Error handling works properly (Test 4) |
| 224 | +- [ ] Prompts work independently (Test 5) |
| 225 | +- [ ] Integration with previous modules works (Test 6) |
| 226 | +- [ ] Slack messages display with proper formatting |
| 227 | +- [ ] All tools and prompts are accessible to Claude Code |
| 228 | + |
| 229 | +## Troubleshooting |
| 230 | + |
| 231 | +### Webhook Server Issues |
| 232 | +```bash |
| 233 | +# Check if webhook server is running |
| 234 | +curl http://localhost:8080/health |
| 235 | + |
| 236 | +# Check stored events |
| 237 | +cat github_events.json |
| 238 | +``` |
| 239 | + |
| 240 | +### MCP Server Issues |
| 241 | +```bash |
| 242 | +# Check if MCP server is responding |
| 243 | +# Should see server startup messages when running uv run server.py |
| 244 | +``` |
| 245 | + |
| 246 | +### Slack Issues |
| 247 | +```bash |
| 248 | +# Test webhook URL directly |
| 249 | +curl -X POST -H 'Content-type: application/json' \ |
| 250 | + --data '{"text":"Direct webhook test"}' \ |
| 251 | + $SLACK_WEBHOOK_URL |
| 252 | +``` |
| 253 | + |
| 254 | +This testing approach lets you validate your implementation without needing to set up a real GitHub repository with Actions workflows! |
0 commit comments