Files
headquarter/openspec/changes/test-infrastructure-improvements/specs/test-isolation/spec.md
T
Fusion 3ccd94f661 feat: restructure test infrastructure with unit/integration/system separation
Test Organization:
- Create tests/unit/, tests/integration/, tests/system/ directories
- Move existing tests into appropriate categories
- Add pytest markers (@pytest.mark.unit, @pytest.mark.integration)

Shared Fixtures:
- Create conftest.py with SQLite engine (for unit tests)
- Add PostgreSQL session fixture with transaction rollback
- Add TestClient fixture for API tests

Configuration:
- Update pyproject.toml with asyncio_mode=auto
- Add test markers and default addopts
- Add aiosqlite dependency for SQLite support

E2E Testing:
- Initialize Playwright in e2e/ directory
- Add playwright.config.ts
- Create login flow E2E test

Build:
- Add test-unit, test-integration, test-system, test-e2e to Makefile
- Update test target to run all categories
- Add testing documentation to README

Note: Some tests have import issues due to missing python-jose
package in dev environment. This needs to be addressed separately.
2026-05-18 15:00:33 +02:00

1.3 KiB

ADDED Requirements

Requirement: Shared Test Fixtures

The system SHALL provide shared fixtures in conftest.py for common test needs.

Scenario: Database session fixture

  • GIVEN an integration test
  • WHEN using the db_session fixture
  • THEN it SHALL provide an async SQLAlchemy session
  • AND the session SHALL use transaction rollback for isolation

Scenario: Test client fixture

  • GIVEN an API integration test
  • WHEN using the client fixture
  • THEN it SHALL provide an authenticated TestClient instance
  • AND the client SHALL have valid access and refresh tokens

Scenario: SQLite unit test database

  • GIVEN a unit test
  • WHEN the test uses the db_engine fixture
  • THEN it SHALL provide an in-memory SQLite engine
  • AND no PostgreSQL connection SHALL be required

Requirement: Transaction Isolation

The system SHALL ensure integration tests don't pollute the database.

Scenario: Rollback after test

  • GIVEN an integration test creates data
  • WHEN the test completes
  • THEN all database changes SHALL be rolled back
  • AND subsequent tests SHALL see a clean database state

Scenario: Parallel test safety

  • GIVEN multiple integration tests run concurrently
  • WHEN each test uses transaction isolation
  • THEN tests SHALL not interfere with each other