docs: document testing and coverage requirements
This commit is contained in:
@ -43,8 +43,15 @@ The system allows you to:
|
|||||||
Run unit tests using Jest:
|
Run unit tests using Jest:
|
||||||
```bash
|
```bash
|
||||||
npm test
|
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
|
## Project Structure
|
||||||
|
|
||||||
- `src/`: Source code (TypeScript)
|
- `src/`: Source code (TypeScript)
|
||||||
|
|||||||
@ -87,13 +87,20 @@ A dedicated side panel provides visibility into the background queue system.
|
|||||||
- Provides controls to globally enable/disable processing.
|
- Provides controls to globally enable/disable processing.
|
||||||
- Allows manual intervention (delete/push) for individual items.
|
- 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.
|
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.
|
- **`ISpreadsheetService`**: Interface for all sheet interactions.
|
||||||
- **`GASSpreadsheetService`**: Production implementation wrapping `SpreadsheetApp`.
|
- **`GASSpreadsheetService`**: Production implementation wrapping `SpreadsheetApp`.
|
||||||
- **`MockSpreadsheetService`**: In-memory implementation for tests.
|
- **`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.
|
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.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user