Add comprehensive test suite infrastructure

- Create backend xUnit test project with Moq and FluentAssertions
- Add test utilities: TestDataFactory, MockHttpContext, TestUserClaims
- Create AuthControllerTests with comprehensive auth scenarios
- Install Jest and React Testing Library for frontend
- Configure jest.config.ts and jest.setup.ts with Next.js support
- Add test scripts to package.json
This commit is contained in:
Denis Urs Rudolph
2026-04-05 22:16:44 +02:00
parent 32bfbcadb1
commit 571fe5bc7c
19 changed files with 11224 additions and 1 deletions
@@ -0,0 +1,37 @@
## ADDED Requirements
### Requirement: Backend test project exists
The system SHALL have a dedicated .NET test project named `backend.Tests` that references the main `backend` project.
#### Scenario: Test project references main project
- **WHEN** the test project is built
- **THEN** it SHALL have a project reference to the main backend API project
### Requirement: Controllers can be unit tested
The system SHALL provide the ability to unit test API Controllers with mocked dependencies.
#### Scenario: Controller with mocked service
- **WHEN** a controller action is invoked with a mocked service
- **THEN** the test SHALL verify the correct HTTP response is returned
#### Scenario: Controller input validation
- **WHEN** invalid input is passed to a controller action
- **THEN** the test SHALL verify validation errors are returned
### Requirement: Services can be unit tested
The system SHALL provide the ability to unit test business logic in Services with mocked dependencies.
#### Scenario: Service with mocked repository
- **WHEN** a service method is called with a mocked data repository
- **THEN** the test SHALL verify the expected business logic is executed
### Requirement: Test utilities are available
The system SHALL provide common test utilities for setup, teardown, and assertions.
#### Scenario: Mock data factories
- **WHEN** tests require test data
- **THEN** factory classes SHALL generate consistent mock entities
#### Scenario: HTTP context mocking
- **WHEN** tests need to simulate HTTP requests
- **THEN** utilities SHALL provide mocked HttpContext and User claims