Files
headquarter/openspec/changes/archive/2025-05-18-test-infrastructure-improvements/proposal.md
T
Fusion 4e2edb1d93 feat: implement git repository management
- Add backend API for git repository CRUD (create, list, delete)
- Support bare repository initialization and mirror cloning
- Add cascade delete for repositories when project is deleted
- Add frontend page for repository management per project
- Update project page with link to repositories
- Add repo_base_path to config
- Quality gates: ruff, mypy, typecheck, lint, build all pass
2026-05-18 15:47:42 +02:00

2.4 KiB

Why

The current test infrastructure has several issues that slow development and reduce confidence:

  1. Mixed test types in single directory: Unit, integration, and system tests are all mixed together in apps/api/tests/, making it hard to run fast unit tests independently.
  2. Duplicate fixture code: Database setup/teardown is duplicated across multiple test files instead of using a shared conftest.py.
  3. Inconsistent test patterns: 4 different patterns exist for database setup (sync helpers, async fixtures, module reloads, autouse env vars).
  4. No test database isolation: Tests truncate tables manually instead of using transaction rollback, leading to potential data leakage.
  5. Backend tests require live PostgreSQL: Unit tests that test pure logic still connect to a real database.
  6. No E2E/system tests: There's no automated way to test the full stack (frontend + API + database) together.
  7. Import errors in local environment: Tests depend on packages not in dev dependencies (e.g., python-jose).

What Changes

  • Restructure backend tests into unit/, integration/, and system/ directories.
  • Create shared fixtures in conftest.py for database sessions, test client, and authentication.
  • Add SQLite in-memory support for fast unit tests that don't need PostgreSQL.
  • Implement transaction rollback isolation using begin_nested() for integration tests.
  • Add missing test dependencies to pyproject.toml.
  • Create E2E test setup using Playwright for critical user journeys.
  • Add test markers (@pytest.mark.unit, @pytest.mark.integration, @pytest.mark.system) to enable selective test runs.
  • Update Makefile with test-unit, test-integration, test-system, and test-e2e targets.

Capabilities

New Capabilities

  • test-organization: Structured test directories with clear separation of concerns.
  • test-isolation: Transaction rollback and SQLite support for fast, isolated tests.
  • e2e-testing: Playwright-based end-to-end tests for critical user journeys.

Modified Capabilities

  • docker-infrastructure: Add test database service and test runner configuration.

Impact

  • apps/api/tests/: Restructured into subdirectories.
  • apps/api/pyproject.toml: New test dependencies added.
  • apps/api/conftest.py: New shared fixtures file.
  • Makefile: New test targets.
  • New e2e/ directory for Playwright tests.
  • CI pipeline may need updates to run new test categories.