This PR implements two critical features for AstroML:
- GitHub Discussions API Integration (#309) - Community forum/discussion integration with real-time fetching, caching, search, and user reputation tracking
- End-to-End API Test Suite (#337) - Comprehensive E2E tests covering critical user journeys with Docker containerization, CI/CD integration, and flaky test detection
Closes #309 Closes #337
-
New Router:
api/routers/discussions.py- GitHub GraphQL API integration for fetching discussions
- Real-time discussion fetching with intelligent 5-minute caching
- Discussion category management endpoint
- Discussion search functionality (text-based filtering)
- User reputation tracking system based on GitHub contributions
- Error handling with logging
-
Endpoints Added:
GET /api/v1/discussions/recent- Fetch recent discussions with optional category filtering (limit: 1-100)GET /api/v1/discussions/categories- Retrieve available discussion categoriesPOST /api/v1/discussions/search- Search discussions by query stringGET /api/v1/discussions/user-reputation/{username}- Calculate user reputation score
-
API Registration:
- Updated
api/routers/__init__.pyto export discussions_router - Registered router in
api/app.py
- Updated
-
New React Component:
web/src/components/Discussions/Discussions.tsx- Display recent discussions with category filtering
- Search functionality with live query input
- User reputation modal with detailed metrics
- Direct links to GitHub discussions and profiles
- Responsive design for mobile and desktop
- Loading and error states
-
Styling:
web/src/components/Discussions/Discussions.css- Professional UI with category badges
- Modal dialog for user reputation display
- Responsive grid layout
- Hover effects and transitions
- New Test Suite:
api/tests/test_discussions.py- Tests for all endpoints (recent, categories, search, reputation)
- Cache validation
- Limit parameter validation
- Error handling verification
- New Test Suite:
tests/e2e/test_api_e2e.py(321 lines)- 15+ test classes covering critical user journeys
- 40+ individual test methods
- Coverage areas:
- Health checks and API status
- Authentication flows (register/login)
- Transaction management and filtering
- Fraud detection endpoints
- Account operations
- Loyalty points system (summary, redemption, history)
- Monitoring and metrics
- Community discussions
- Contributors dashboard
- Notifications management
- Error handling (404, invalid JSON, missing fields)
- Concurrent request handling
- Response format consistency
- Rate limiting behavior
- CORS headers validation
- Performance benchmarks (sub-5-second response time, 20 concurrent requests < 30s)
-
Configuration:
tests/e2e/config.py- Environment variable management
- Test paths and report directories
- GitHub API configuration
- Timeout and retry settings
-
Fixtures:
tests/e2e/conftest.py- Test client setup with FastAPI TestClient
- Authenticated client fixture
- API base URL configuration
- Auth token management
-
Reporting:
tests/e2e/reporter.py- JSON report generation with metadata
- HTML report generation with styled tables and metrics
- Flaky test detection (identifies timeout/connection errors)
- Pass rate calculation
- Test duration tracking and aggregation
- Error analysis and categorization
-
Pytest Plugin:
tests/e2e/plugin.py- Auto-generates reports on session finish
- Captures test metadata and timing
- Integrates with pytest lifecycle
- Docker Compose:
docker-compose.e2e.yml- PostgreSQL 15 service with health checks
- Redis 7 service with persistent volumes
- FastAPI application service
- Pytest runner service with test result mounting
- Isolated network for E2E testing
- Volume management for reports and coverage
- GitHub Actions Workflow:
.github/workflows/e2e-tests.yml- Triggers on push to main/develop and all PRs
- Daily scheduled runs (2 AM UTC)
- Matrix setup with PostgreSQL and Redis services
- Automatic dependency caching for faster runs
- API server health check before test execution
- Test execution with coverage reporting
- JUnit XML result generation
- Test result artifacts upload
- PR comment automation with test summary
- Flaky test detection and reporting
- E2E Testing Guide:
E2E_TESTING_GUIDE.md- Prerequisites and setup instructions
- Local test execution examples
- Docker-based testing instructions
- CI/CD integration details
- Flaky test detection explanation
- Performance benchmark documentation
- Troubleshooting guide
- Contributing guidelines
- Documentation:
IMPLEMENTATION_SUMMARY_309_337.md- Detailed breakdown of all changes
- File-by-file implementation details
- Test statistics and coverage summary
- Quality assurance checklist
- ✅ API health and status
- ✅ User authentication (registration/login)
- ✅ Transaction management
- ✅ Fraud detection
- ✅ Account operations
- ✅ Loyalty points flows
- ✅ Monitoring and metrics
- ✅ Community discussions
- ✅ Contributors dashboard
- ✅ Notification management
- ✅ Error handling and validation
- ✅ Concurrent request handling (20 parallel requests)
- ✅ Response format consistency
- ✅ Rate limiting
- ✅ CORS headers
- ✅ Performance benchmarks
api/routers/discussions.py- Discussions API implementation (291 lines)api/tests/test_discussions.py- Discussions endpoint testsweb/src/components/Discussions/Discussions.tsx- React component (216 lines)web/src/components/Discussions/Discussions.css- Component styling (397 lines)web/src/components/Discussions/index.ts- Component exporttests/e2e/test_api_e2e.py- E2E test suite (321 lines)tests/e2e/config.py- E2E configurationtests/e2e/conftest.py- Pytest fixturestests/e2e/reporter.py- Test reporting (162 lines)tests/e2e/plugin.py- Pytest plugintests/e2e/__init__.py- Package marker.github/workflows/e2e-tests.yml- CI/CD workflow (140+ lines)docker-compose.e2e.yml- Test containers (95+ lines)E2E_TESTING_GUIDE.md- Testing documentationIMPLEMENTATION_SUMMARY_309_337.md- Implementation summaryPR_MESSAGE.md- This message
api/routers/__init__.py- Added discussions_router importapi/app.py- Registered discussions_router
- ✅ Python syntax validation passed
- ✅ Code compiles without errors
- ✅ Line length within limits (< 120 chars)
- ✅ Consistent import ordering
- ✅ Type hints included
- ✅ Comprehensive docstrings
- ✅ Error handling implemented
- ✅ Logging configured
pip install -r requirements.txt
pip install pytest pytest-asyncio pytest-covpytest api/tests/test_discussions.py -vdocker-compose -f docker-compose.e2e.yml up -d
docker-compose -f docker-compose.e2e.yml run pytest-e2e- JSON Report:
test-results/e2e-report.json - HTML Report:
test-results/e2e-report.html - Coverage:
htmlcov/index.html
For GitHub Discussions integration:
GITHUB_TOKEN=<your-github-token>
GITHUB_OWNER=Traqora
GITHUB_REPO=astromlFor E2E tests:
DATABASE_URL=postgresql://test:test@localhost:5432/astroml_test
REDIS_URL=redis://localhost:6379
API_BASE_URL=http://localhost:8000The E2E test workflow:
- Checks out code
- Sets up Python environment with cached dependencies
- Starts PostgreSQL and Redis services
- Builds and starts API server
- Waits for API health check
- Runs E2E tests with coverage
- Generates test reports (XML, JSON, HTML)
- Uploads artifacts to GitHub
- Publishes results to PR comment
- Detects and reports flaky tests
None - all changes are additive and backward compatible.
c40b49f- feat(#309): Add GitHub Discussions API integration89ff036- feat(#337): Add end-to-end API test suitedfeeec7- docs: Add implementation summary for issues #309 and #3370241a5d- refactor: Fix line length in test reporter
- Closes #309: Community forum/discussion integration
- Closes #337: End-to-end API tests
- Code compiles without errors
- Tests pass locally
- Code follows project style guidelines
- Documentation is complete
- No breaking changes
- New tests cover changes
- CI/CD workflow validated
- Commits are logical and well-organized
- PR title and description are clear