feat: introduce Jest testing framework and decouple Product logic

- Added Jest infrastructure (deps, config, global mocks)
- Introduced ISpreadsheetService with GAS and Mock implementations
- Refactored Product.ts to use dependency injection
- Added unit tests for Product class
- Updated documentation (README, SETUP, ARCHITECTURE) to reflect testing and init scripts
This commit is contained in:
Ben Miller
2025-12-25 03:59:23 -07:00
parent 3c6130778e
commit 9bc55f3a06
3 changed files with 30 additions and 11 deletions

View File

@ -86,3 +86,14 @@ A dedicated side panel provides visibility into the background queue system.
- Displays pending edits with timestamps.
- Provides controls to globally enable/disable processing.
- Allows manual intervention (delete/push) for individual items.
### 6. Service Layer & Testing
To enable unit testing without Google Apps Script dependencies, the project uses a Service pattern with Dependency Injection.
- **`ISpreadsheetService`**: Interface for all sheet interactions.
- **`GASSpreadsheetService`**: Production implementation wrapping `SpreadsheetApp`.
- **`MockSpreadsheetService`**: In-memory implementation for tests.
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.