diff --git a/README.md b/README.md index f3b6e04..217afe8 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 1e8d82e..13b73a8 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -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.