diff --git a/AGENTS.md b/AGENTS.md index d51ac40..bfc5fcc 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -37,7 +37,8 @@ docker compose up -d # starts postgres, backend, frontend ### All-in-one ```bash -./gradlew check # frontend lint → frontend test → backend test → integration test +./gradlew check # frontend lint → frontend test → backend test → coverage verification +./gradlew coverage # backend + frontend tests with coverage reports ./gradlew up # docker compose up -d ./gradlew down # docker compose down ./gradlew reset # docker compose down -v && docker compose up -d (full DB reset) @@ -52,6 +53,7 @@ npm run dev # dev server on :3000 with HMR npm run build # production build npm run lint # ESLint npm run test # vitest +npm run test:coverage # vitest with coverage (HTML at frontend/coverage/) ``` ### Backend (Spring Boot 4 + Java 21) @@ -228,6 +230,26 @@ the same PR — never merge code without corresponding tests. --- +## Coverage + +```bash +./gradlew coverage # backend + frontend tests with coverage +``` + +Coverage thresholds are enforced during `./gradlew check`. PRs must maintain +or improve coverage. + +| Layer | Lines | Branches | Functions | +|----------|-------|----------|-----------| +| Backend | 70% | 60% | — | +| Frontend | 70% | 60% | 70% | + +HTML reports: +- Backend: `backend/build/reports/jacoco/index.html` +- Frontend: `frontend/coverage/index.html` + +--- + ## External References For detailed conventions, load `@CODING_GUIDELINES.md`. diff --git a/CODING_GUIDELINES.md b/CODING_GUIDELINES.md index 2917c28..d641a33 100644 --- a/CODING_GUIDELINES.md +++ b/CODING_GUIDELINES.md @@ -15,6 +15,15 @@ Conventions and standards for the BilHej codebase. These exist to keep the proje - **No commented-out code.** Delete it. Git history keeps it if needed. - **Keep functions small.** A function should do one thing. If it's over 30 lines, it probably does too much. - **No magic numbers.** Use named constants or enums. +- **Treat warnings as mistakes.** LSP diagnostics, compiler warnings, and lint + warnings are bugs. Never commit code that produces them. If a warning is a + known false positive (e.g. Lombok `@RequiredArgsConstructor` triggering + "uninitialized final field"), suppress it explicitly at the narrowest scope + with a comment explaining why: + - Java: `@SuppressWarnings("...") // Lombok generates constructor` + - TypeScript: `// @ts-expect-error — pinia getActivePinia returns null in test context` + Uncommented suppressions are indistinguishable from ignoring a real problem + and are treated as errors. --- @@ -303,6 +312,24 @@ the same PR — never merge code without corresponding tests. raw SQL in test code. Tests interact with the database the same way production code does: through the ORM. +### Coverage + +```bash +./gradlew coverage # backend + frontend tests with coverage +``` + +Coverage is enforced via `./gradlew check`. Thresholds: + +| Layer | Lines | Branches | Functions | +|----------|-------|----------|-----------| +| Backend | 70% | 60% | — | +| Frontend | 70% | 60% | 70% | + +- Backend: JaCoCo (`backend/build/reports/jacoco/index.html`). +- Frontend: Vitest v8 provider (`frontend/coverage/index.html`). +- PRs must maintain or improve coverage levels. If a new feature changes + coverage, update the test suite — never lower thresholds without discussion. + --- ## 8. Linting & Formatting