Files
TimeTracker/docs/TESTING_QUICK_REFERENCE.md
Dries Peeters e4789cc26e feat: Add telemetry and analytics infrastructure with observability stack
Implement comprehensive analytics and monitoring system with PostHog integration,
complete observability stack (Prometheus, Grafana, Loki, Promtail), and CI/CD
workflows for automated builds.

Features:
- Add PostHog telemetry integration with privacy-focused event tracking
- Implement installation flow for opt-in telemetry configuration
- Add telemetry management UI in admin panel with detailed transparency
- Track key user events across all major features (projects, tasks, timer, etc.)

Infrastructure:
- Set up Prometheus for metrics collection
- Configure Grafana for visualization dashboards
- Integrate Loki and Promtail for log aggregation
- Add separate analytics docker-compose configuration

CI/CD:
- Add GitHub Actions workflows for building and publishing Docker images
- Implement separate dev and production build pipelines
- Configure automated image publishing to registry

Documentation:
- Restructure documentation into organized docs/ directory
- Add comprehensive guides for telemetry, analytics, and local development
- Create transparency documentation for tracked events
- Add CI/CD and build configuration guides

Code improvements:
- Integrate telemetry hooks across all route handlers
- Add feature flags and configuration management
- Refactor test suite for analytics functionality
- Clean up root directory by moving docs and removing test artifacts

Breaking changes:
- Requires new environment variables for PostHog configuration
- Docker compose setup now supports analytics stack

Changes: 73 files changed, 955 insertions(+), 14126 deletions(-)
2025-10-20 14:38:57 +02:00

1.8 KiB

Testing Quick Reference

TL;DR - Fix for Coverage Error

If you're getting:

FAIL Required test coverage of 50% not reached. Total coverage: 27.81%

The Fix:

# Don't run coverage on route tests alone
pytest -m routes -v

# Instead, run coverage on ALL tests
pytest --cov=app --cov-report=html --cov-fail-under=50

Or use the Makefile:

# Run route tests (no coverage)
make test-routes

# Run full coverage test
make test-coverage

Why?

Route tests only exercise ~28% of your codebase (which is correct!). The other 72% is tested by:

  • Model tests
  • Utility tests
  • Integration tests
  • Business logic tests

Coverage should be measured across ALL tests, not individual test suites.

Common Commands

Development Testing

make test-routes          # Test routes only
make test-models          # Test models only
make test-unit           # Test unit tests only
make test-integration    # Test integration only
make test-api            # Test API endpoints

Coverage Analysis

make test-coverage        # All tests with 50% requirement
make test-coverage-report # All tests, no requirement

CI/CD Testing

make test-smoke          # Quick validation (< 1 min)
pytest --cov=app --cov-report=xml --cov-fail-under=50  # Full CI test

View Coverage Report

make test-coverage-report
# Then open htmlcov/index.html in your browser

Test Markers

Run specific test types:

pytest -m smoke          # Smoke tests
pytest -m unit           # Unit tests
pytest -m integration    # Integration tests
pytest -m routes         # Route tests
pytest -m api            # API tests
pytest -m models         # Model tests
pytest -m database       # Database tests
pytest -m security       # Security tests

Full Documentation

See docs/TESTING_COVERAGE_GUIDE.md for complete guide.