Skip to main content

Testing Guide

Comprehensive guide for testing the JPD-to-GitHub Connector, including automated tests, manual testing, and debugging.

๐Ÿš€ Quick Startโ€‹

Run All Testsโ€‹

# Full integration test suite (includes sub-issues)
./tests/scripts/test-sync-integration.sh

# Dry-run mode (no actual changes)
pnpm run dev -- --dry-run

# Cleanup old test data
./tests/scripts/test-sync-integration.sh --cleanup-only

Run Specific Testsโ€‹

# Comment sync test
./tests/scripts/test-comment-sync.sh

# GitHub to JPD creation test
./tests/scripts/test-github-to-jpd-creation.sh

# Quick smoke test
./tests/scripts/test-quick.sh

๐Ÿ“‹ Test Suitesโ€‹

1. Integration Tests (test-sync-integration.sh)โ€‹

What it tests:

  • โœ… JPD โ†’ GitHub sync (create issues)
  • โœ… JPD โ†’ GitHub sync (update issues)
  • โœ… JPD โ†’ GitHub sync (priority changes)
  • โœ… GitHub โ†’ JPD sync (status updates)
  • โœ… NEW: Epic โ†’ Story โ†’ Task hierarchy with sub-issues
  • โœ… NEW: Task list creation and checkbox auto-update

Run it:

./tests/scripts/test-sync-integration.sh

What happens:

  1. Cleans up old [TEST-AUTO] issues (idempotency)
  2. Creates test issues in JPD with different categories/priorities
  3. Syncs to GitHub and verifies creation
  4. Updates issues and verifies sync
  5. Creates parent-child hierarchies and verifies sub-issues
  6. Closes issues and verifies checkbox updates
  7. Offers to clean up test data

Expected output:

โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
TEST 1: JPD โ†’ GitHub (Create)
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
โœ“ Created JPD issue: MTT-100
โœ“ GitHub issue #10 created for MTT-100
โœ“ Title synced correctly: [TEST-AUTO] Story Title
โœ“ Labels synced correctly: story,high

โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
TEST 5: Sub-Issues & Hierarchy (Epic โ†’ Story โ†’ Task)
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
โœ“ Epic GitHub issue #11 created
โœ“ Epic task list contains Story as sub-issue: - [ ] #12
โœ“ Story task list shows Task as completed: - [x] #13

See also: Sub-Issues Test Guide for detailed test breakdown


2. Comment Sync Tests (test-comment-sync.sh)โ€‹

What it tests:

  • โœ… Bidirectional comment synchronization
  • โœ… Comment deduplication
  • โœ… Markdown โ†’ ADF conversion

Run it:

./tests/scripts/test-comment-sync.sh

3. GitHub to JPD Creation Tests (test-github-to-jpd-creation.sh)โ€‹

What it tests:

  • โœ… Creating JPD issues from unsynced GitHub issues
  • โœ… Label-to-category mapping
  • โœ… Default priority assignment
  • โœ… Metadata injection

Run it:

./tests/scripts/test-github-to-jpd-creation.sh

๐Ÿงช Manual Testingโ€‹

Test Sub-Issues Manuallyโ€‹

1. Create Hierarchy in JPDโ€‹

# Create Epic
EPIC_KEY=$(curl -u "${JPD_EMAIL}:${JPD_API_KEY}" \
-H "Content-Type: application/json" \
-X POST "${JPD_BASE_URL}/rest/api/3/issue" \
-d '{
"fields": {
"project": {"key": "MTT"},
"summary": "[MANUAL] Epic: Mobile Redesign",
"issuetype": {"name": "Idea"},
"customfield_14385": {"value": "Epic"}
}
}' | jq -r '.key')

echo "Epic created: $EPIC_KEY"

# Create Story
STORY_KEY=$(curl -u "${JPD_EMAIL}:${JPD_API_KEY}" \
-H "Content-Type: application/json" \
-X POST "${JPD_BASE_URL}/rest/api/3/issue" \
-d '{
"fields": {
"project": {"key": "MTT"},
"summary": "[MANUAL] Story: Login Updates",
"issuetype": {"name": "Idea"},
"customfield_14385": {"value": "Story"}
}
}' | jq -r '.key')

echo "Story created: $STORY_KEY"

# Link Story to Epic
curl -u "${JPD_EMAIL}:${JPD_API_KEY}" \
-H "Content-Type: application/json" \
-X POST "${JPD_BASE_URL}/rest/api/3/issueLink" \
-d "{
\"type\": {\"name\": \"relates to\"},
\"inwardIssue\": {\"key\": \"${STORY_KEY}\"},
\"outwardIssue\": {\"key\": \"${EPIC_KEY}\"}
}"

echo "Linked $STORY_KEY to $EPIC_KEY"

2. Run Syncโ€‹

pnpm run dev

3. Verify in GitHubโ€‹

  1. Find the Epic issue (search for "[MANUAL] Epic: Mobile Redesign")
  2. Check the issue body for:
    ## ๐Ÿ“‹ Subtasks

    - [ ] #XX Login Updates (MTT-XXX)
  3. Click the sub-issue link to verify it exists
  4. Check the Story issue for parent reference:
    ## ๐Ÿ”— Parent
    - GitHub: #YY
    - JPD: [MTT-YYY](...)

4. Test Checkbox Updateโ€‹

  1. Close the Story issue in GitHub (via UI or API)
  2. Run sync: pnpm run dev
  3. Check Epic issue - checkbox should be checked:
    - [x] #XX Login Updates (MTT-XXX) โœ…

๐Ÿ” Debugging Testsโ€‹

Enable Debug Loggingโ€‹

# Set log level to debug
export LOG_LEVEL=debug
pnpm run dev

Inspect Issue Metadataโ€‹

# Get GitHub issue and check sync metadata
curl -H "Authorization: token ${GITHUB_TOKEN}" \
"https://api.github.com/repos/${GITHUB_OWNER}/${GITHUB_REPO}/issues/11" | \
jq -r '.body' | grep -A 20 'jpd-sync-metadata'

Check Task Listsโ€‹

# Get parent issue and check task list
curl -H "Authorization: token ${GITHUB_TOKEN}" \
"https://api.github.com/repos/${GITHUB_OWNER}/${GITHUB_REPO}/issues/10" | \
jq -r '.body' | grep -A 10 'Subtasks'
# Get JPD issue and check issue links
curl -u "${JPD_EMAIL}:${JPD_API_KEY}" \
"${JPD_BASE_URL}/rest/api/3/issue/MTT-100?fields=issuelinks" | \
jq '.fields.issuelinks'

๐Ÿ› ๏ธ Test Utilitiesโ€‹

Cleanup Commandsโ€‹

# Delete all [TEST-AUTO] issues from JPD and GitHub
./tests/scripts/test-sync-integration.sh --cleanup-only

# Clear all GitHub labels (use with caution!)
./clear-all-labels.sh

# Cleanup old labels (deprecated ones)
./cleanup-old-labels.sh

Quick Validationโ€‹

# Validate configuration
pnpm run validate-config

# Test API connections
pnpm run health-check

# Discover JPD fields
pnpm run discover-fields MTT

๐Ÿ“Š Test Coverageโ€‹

FeatureAutomatedManualIntegration
Sync: JPD โ†’ GitHubโœ…โœ…โœ…
Sync: GitHub โ†’ JPDโœ…โœ…โœ…
Sub-Issuesโœ…โœ…โœ…
Task Listsโœ…โœ…โœ…
Checkbox Auto-Updateโœ…โœ…โœ…
Comment Syncโœ…โœ…โš ๏ธ
Label Auto-Creationโš ๏ธโœ…โš ๏ธ
Field Validationโš ๏ธโœ…โš ๏ธ
Rate Limit Handlingโš ๏ธโœ…โš ๏ธ

Legend:

  • โœ… Full coverage
  • โš ๏ธ Partial coverage
  • โŒ No coverage

๐Ÿ› Common Test Issuesโ€‹

Test Fails: Rate Limit Hitโ€‹

Problem: JPD returns 429 errors

Fix:

# Increase wait times in test script
# Or run cleanup and try again later
./tests/scripts/test-sync-integration.sh --cleanup-only

Test Fails: Old Issues Foundโ€‹

Problem: Previous test run didn't clean up

Fix:

# Force cleanup
./tests/scripts/test-sync-integration.sh --cleanup-only

# Then re-run tests
./tests/scripts/test-sync-integration.sh

Test Fails: Missing Fieldsโ€‹

Problem: Custom field IDs don't match your JPD instance

Fix:

  1. Discover your field IDs:
    pnpm run discover-fields MTT
  2. Update test script with correct field IDs:
    # Edit tests/scripts/test-sync-integration.sh
    # Update customfield_XXXXX values

Test Fails: Wrong Project Keyโ€‹

Problem: Tests use MTT but your project is different

Fix:

# Set your project key
export JPD_PROJECT_KEY=YOUR_KEY

# Or edit test script to use your key

๐Ÿ“ Writing New Testsโ€‹

Test Script Templateโ€‹

#!/usr/bin/env bash
set -euo pipefail

# Load environment
source .env

# Test configuration
TEST_NAME="My New Test"
TEST_PASSED=0
TEST_FAILED=0

# Utility functions
log_success() {
echo "โœ“ $1"
((TEST_PASSED++))
}

log_error() {
echo "โœ— $1"
((TEST_FAILED++))
}

# Your test logic here
test_my_feature() {
log_success "Test passed!"
}

# Run test
test_my_feature

# Summary
echo ""
echo "โœ“ Passed: $TEST_PASSED"
echo "โœ— Failed: $TEST_FAILED"

# Exit code
[ "$TEST_FAILED" -eq 0 ] && exit 0 || exit 1

Best Practicesโ€‹

  1. Idempotency - Clean up before and after tests
  2. Rate Limits - Add sleep between API calls
  3. Clear Output - Use colored logs and sections
  4. Error Handling - Capture and display API errors
  5. Cleanup - Offer to delete test data after run

๐ŸŽฏ CI/CD Integrationโ€‹

GitHub Actionsโ€‹

name: Integration Tests

on:
push:
branches: [main]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install pnpm
run: npm install -g pnpm

- name: Install dependencies
run: pnpm install

- name: Run integration tests
env:
JPD_EMAIL: ${{ secrets.JPD_EMAIL }}
JPD_API_KEY: ${{ secrets.JPD_API_KEY }}
JPD_BASE_URL: ${{ secrets.JPD_BASE_URL }}
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
GITHUB_OWNER: ${{ secrets.GITHUB_OWNER }}
GITHUB_REPO: ${{ secrets.GITHUB_REPO }}
run: |
./tests/scripts/test-sync-integration.sh
# Auto-cleanup in CI
./tests/scripts/test-sync-integration.sh --cleanup-only

๐Ÿ“š Additional Resourcesโ€‹


๐Ÿงช Happy Testing! If you encounter issues, check the debug commands above or open an issue on GitHub.