Files
raceplanner/openspec/changes/add-tests/specs/test-automation/spec.md
T
Denis Urs Rudolph 571fe5bc7c 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
2026-04-05 22:16:44 +02:00

59 lines
2.2 KiB
Markdown

## ADDED Requirements
### Requirement: NPM scripts exist for test execution
The system SHALL provide npm scripts to run different test suites.
#### Scenario: Run all tests
- **WHEN** the command `npm test` or `npm run test` is executed
- **THEN** all unit and integration tests SHALL execute
#### Scenario: Run backend tests only
- **WHEN** the command `npm run test:backend` is executed
- **THEN** only the backend unit tests SHALL run
#### Scenario: Run frontend tests only
- **WHEN** the command `npm run test:frontend` is executed
- **THEN** only the frontend unit tests SHALL run
#### Scenario: Run integration tests only
- **WHEN** the command `npm run test:integration` is executed
- **THEN** only the integration tests SHALL run
### Requirement: Tests run in watch mode for development
The system SHALL support watch mode for iterative development.
#### Scenario: Watch mode runs tests on file changes
- **WHEN** the command `npm run test:watch` is executed
- **THEN** tests SHALL re-run automatically when source or test files change
#### Scenario: Watch mode can filter by test pattern
- **WHEN** a test pattern is specified (e.g., `npm run test:watch -- Auth`)
- **THEN** only matching tests SHALL run in watch mode
### Requirement: Gitea Actions workflow exists
The system SHALL have a Gitea Actions workflow that runs tests on pull requests.
#### Scenario: Tests run on PR creation
- **WHEN** a pull request is opened
- **THEN** the Gitea Actions workflow SHALL trigger and run all tests
#### Scenario: Tests run on PR update
- **WHEN** new commits are pushed to an open pull request
- **THEN** the Gitea Actions workflow SHALL re-run tests
#### Scenario: PR is blocked on test failure
- **WHEN** tests fail in the PR
- **THEN** the PR SHALL show failed status and optionally block merging
#### Scenario: Backend tests run in CI
- **WHEN** the CI workflow executes
- **THEN** backend unit tests SHALL run after the project builds successfully
#### Scenario: Frontend tests run in CI
- **WHEN** the CI workflow executes
- **THEN** frontend unit tests SHALL run after dependencies are installed
#### Scenario: Integration tests run in CI
- **WHEN** the CI workflow executes
- **THEN** integration tests SHALL run with test infrastructure (backend + database) available