# ss-tools test suite # ───────────────────────────────────────────────────────────── # Tiered test targets designed for agent-driven development: # Tier 1 (fast, <30s): make test # Tier 2 (slow, <5min): make test-integration # Tier 3 (e2e, <10min): make test-e2e # # Smart selection: make test-related F=path/to/file.py # Coverage: make coverage # ───────────────────────────────────────────────────────────── ROOT := $(CURDIR) BACKEND := $(ROOT)/backend FRONTEND := $(ROOT)/frontend VENV := $(BACKEND)/.venv/bin/activate TIMEOUT_FAST := 600 TIMEOUT_SLOW := 600 .PHONY: help test test-unit test-frontend test-related test-integration test-e2e test-all .PHONY: coverage coverage-backend coverage-frontend .PHONY: lint lint-backend lint-frontend .PHONY: docs-doxygen docs-doxygen-check # ── Help ─────────────────────────────────────────────────── help: ## Show this help message @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \ awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-22s\033[0m %s\n", $$1, $$2}' # ── Tier 1: Fast tests (no Docker, SQLite + jsdom) ───────── test: test-unit test-frontend ## Run fast unit tests (backend + frontend, <30s) @echo " ✅ All fast tests passed" test-unit: ## Run backend unit tests (SQLite, no Docker) @echo " ▶ Backend unit tests (SQLite)..." @cd $(BACKEND) && . $(VENV) && timeout $(TIMEOUT_FAST) python -m pytest tests/ --ignore=tests/integration/ -v --tb=short test-frontend: ## Run frontend vitest tests @echo " ▶ Frontend vitest tests..." @cd $(FRONTEND) && npx vitest run # ── Tier 2: Smart selection ──────────────────────────────── test-related: ## Run tests related to a changed file (make test-related F=path/to/file.py) @if [ -z "$(F)" ]; then echo "Usage: make test-related F=path/to/file.py"; exit 1; fi @echo " ▶ Finding related tests for $(F)..." @python3 $(ROOT)/scripts/find-related-tests.py --file "$(F)" --run # ── Tier 3: Slow tests (requires Docker) ─────────────────── test-integration: ## Run backend integration tests (Docker + testcontainers) @echo " ▶ Backend integration tests (Docker)..." @cd $(BACKEND) && . $(VENV) && timeout $(TIMEOUT_SLOW) python -m pytest tests/integration/ --run-integration -v --tb=short test-e2e: ## Run Playwright E2E tests (requires running app) @echo " ▶ Playwright E2E tests..." @cd $(FRONTEND) && npx playwright test # ── Full suite ───────────────────────────────────────────── test-all: ## Run full suite: fast tests + integration (skip installs) @$(MAKE) test @echo "" @echo " ▶ Integration tests (may take several minutes)..." @cd $(BACKEND) && . $(VENV) && timeout $(TIMEOUT_SLOW) python -m pytest tests/integration/ --run-integration -v --tb=short || echo " ⚠ Integration tests skipped (Docker not available or timed out)" @echo "" @echo " ✅ Full test suite complete" # ── Coverage ─────────────────────────────────────────────── coverage: coverage-backend coverage-frontend ## Generate coverage (backend + frontend) @echo " ✅ Coverage reports ready" @echo " Backend: $(BACKEND)/htmlcov/index.html" @echo " Frontend: $(FRONTEND)/coverage/index.html" coverage-backend: ## Backend coverage (unit tests + --cov) @echo " ▶ Backend coverage..." @cd $(BACKEND) && . $(VENV) && timeout $(TIMEOUT_FAST) python -m pytest tests/ --ignore=tests/integration/ \ --cov=src --cov-report=term-missing --cov-report=html coverage-frontend: ## Frontend coverage (vitest --coverage) @echo " ▶ Frontend coverage..." @cd $(FRONTEND) && npx vitest run --coverage # ── Linting ──────────────────────────────────────────────── lint: lint-backend lint-frontend ## Run all linters lint-backend: ## Backend ruff check @cd $(BACKEND) && . $(VENV) && python -m ruff check . lint-frontend: ## Frontend eslint @cd $(FRONTEND) && npx eslint . # ── Documentation ─────────────────────────────────────────── docs-doxygen: ## Generate Doxygen XML and HTML documentation @if ! command -v doxygen >/dev/null 2>&1; then \ echo " ✗ doxygen not found."; \ echo " Debian/Ubuntu: sudo apt-get install -y doxygen"; \ echo " macOS: brew install doxygen"; \ exit 1; \ fi @echo " ▶ Generating Doxygen XML + HTML..." @rm -rf "$(ROOT)/docs/api/build" @cd "$(ROOT)" && { cat docs/api/Doxyfile; printf '\nSTRIP_FROM_PATH = %s\n' "$(ROOT)"; } | doxygen - @test -f "$(ROOT)/docs/api/build/xml/index.xml" @echo " ✅ XML: docs/api/build/xml/index.xml" @echo " ✅ HTML: docs/api/build/html/index.html" docs-doxygen-check: ## Validate Doxygen configuration and generated XML @if ! command -v doxygen >/dev/null 2>&1; then \ echo " ✗ doxygen not found."; \ echo " Debian/Ubuntu: sudo apt-get install -y doxygen"; \ echo " macOS: brew install doxygen"; \ exit 1; \ fi @if rg -n '/home/|/Users/' "$(ROOT)/docs/api/Doxyfile" >/dev/null; then \ echo " ✗ Doxyfile contains an absolute user path"; \ exit 1; \ fi @test -f "$(ROOT)/docs/api/build/xml/index.xml" || { \ echo " ✗ Doxygen XML is missing; run make docs-doxygen"; \ exit 1; \ } @if rg -n 'filename="/home/|/home/|/home/' "$(ROOT)/docs/api/build/xml" >/dev/null; then \ echo " ✗ Doxygen XML contains an absolute source filename"; \ exit 1; \ fi @echo " ✅ Doxygen configuration and XML artifact are present"