# 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 := 120 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 # ── 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 .