docs: document testing and coverage requirements

This commit is contained in:
Ben Miller
2025-12-25 04:13:09 -07:00
parent 3a184154db
commit 2672d47203
2 changed files with 15 additions and 1 deletions

View File

@ -43,8 +43,15 @@ The system allows you to:
Run unit tests using Jest:
```bash
npm test
```bash
npm test
```
### Code Quality Enforcement
This project uses **Husky** to enforce code quality locally.
- **Pre-commit Hook**: Runs tests on changed files before every commit.
- **Coverage Requirement**: Modified files must maintain **80% code coverage**. Commits will be blocked if this threshold is not met.
## Project Structure
- `src/`: Source code (TypeScript)

View File

@ -87,13 +87,20 @@ A dedicated side panel provides visibility into the background queue system.
- Provides controls to globally enable/disable processing.
- Allows manual intervention (delete/push) for individual items.
### 6. Service Layer & Testing
### 6. Service Layer, Testing & Quality
To enable unit testing without Google Apps Script dependencies, the project uses a Service pattern with Dependency Injection.
#### Architecture
- **`ISpreadsheetService`**: Interface for all sheet interactions.
- **`GASSpreadsheetService`**: Production implementation wrapping `SpreadsheetApp`.
- **`MockSpreadsheetService`**: In-memory implementation for tests.
#### Quality Assurance
We use **Husky** and **lint-staged** to enforce quality standards at the commit level:
1. **Pre-commit Hook**: Automatically runs `npm test -- --onlyChanged --coverage`.
2. **Coverage Policy**: Any file modified in a commit must meet an **80% line coverage** threshold. This ensures the codebase quality improves monotonically ("Boy Scout Rule").
Classes (like `Product`) should accept an `ISpreadsheetService` in their constructor. This allows providing the Mock service during tests to verify logic without touching real Google Sheets.