4e2edb1d93
- 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
2.5 KiB
2.5 KiB
Context
Current test infrastructure has ~50 backend tests and 12 frontend tests. Backend tests are mixed in a single directory with inconsistent patterns. Some tests require a running PostgreSQL instance even when testing pure logic. There's no E2E test coverage.
Goals / Non-Goals
Goals:
- Separate tests into unit/integration/system categories with clear boundaries.
- Create shared fixtures to eliminate duplication.
- Enable fast unit tests without PostgreSQL (SQLite in-memory).
- Implement proper transaction isolation for integration tests.
- Add E2E tests for critical user journeys (login, project creation).
- Make tests runnable both locally and in Docker.
Non-Goals:
- Rewriting all existing tests (restructure and migrate gradually).
- Adding tests for features that don't exist yet.
- Complex test parallelization setup.
- Performance benchmarking.
Decisions
-
Use SQLite for unit tests, PostgreSQL for integration/system tests
- Rationale: Unit tests should be fast and not require external services.
- SQLite runs in-memory, no Docker needed.
-
Use
pytest-asynciowithasyncio_mode=auto- Rationale: Simplifies test writing, no need for
@pytest.mark.asyncioon every test.
- Rationale: Simplifies test writing, no need for
-
Shared
conftest.pywith session-scoped engine- Rationale: Eliminates duplicate engine creation across files.
- Integration tests use
begin_nested()for transaction rollback.
-
Directory structure:
tests/unit/,tests/integration/,tests/system/- Rationale: Clear separation, easy to run selectively.
pytest -m unitruns all unit tests regardless of location.
-
Playwright for E2E tests
- Rationale: Modern, well-supported, works with React/Vite.
- Tests run against the actual deployed application.
Risks / Trade-offs
- [SQLite vs PostgreSQL behavior differences] -> Document known differences (e.g., JSON operators, asyncpg-specific features).
- [Migration effort for existing tests] -> Migrate gradually, prioritize new tests over rewriting old ones.
- [E2E tests are slower] -> Run them selectively (not on every commit), maybe only in CI or nightly.
Migration Plan
- Create new directory structure.
- Implement shared fixtures in
conftest.py. - Add SQLite support for unit tests.
- Migrate 2-3 existing tests as examples.
- Add Playwright setup and 1-2 E2E tests.
- Update Makefile targets.
- Document testing strategy.
Open Questions
- Should we use
pytest-xdistfor parallel test execution? - Should E2E tests run against the Docker compose setup or a staging environment?