mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
Add comprehensive tests for API input handling and concurrent writes
Add tests for API v1/v3 and WebSocket input handling, and improve concurrent write test coverage. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 2501b04e-77c8-4f06-a13c-75c232bafd47 Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Event-Id: a5480f95-14f0-4de9-84d1-41c5d1a69aed Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7ea4278b-5c6c-4065-9cb8-f1013771318d/2501b04e-77c8-4f06-a13c-75c232bafd47/rAsiAu1 Replit-Helium-Checkpoint-Created: true
This commit is contained in:
@@ -67,6 +67,35 @@ Key insights from schema documentation:
|
||||
- The `eventType` field is essentially free-form - controllers can send any value
|
||||
- Report plugins serve as implicit schema documentation by revealing which fields are actually used
|
||||
|
||||
## Shape Handling Test Coverage
|
||||
|
||||
Comprehensive test coverage for single document vs array input handling across all APIs. See `docs/test-specs/shape-handling-spec.md` for full specification.
|
||||
|
||||
### Test Files
|
||||
| File | Coverage Area |
|
||||
|------|---------------|
|
||||
| `tests/api.shape-handling.test.js` | API v1 treatments, devicestatus, entries - single/array input, response shapes |
|
||||
| `tests/api3.shape-handling.test.js` | API v3 all collections - single object only (arrays rejected) |
|
||||
| `tests/storage.shape-handling.test.js` | Storage layer direct tests, MongoDB insertOne vs insertMany |
|
||||
| `tests/websocket.shape-handling.test.js` | WebSocket dbAdd/dbUpdate/dbRemove operations |
|
||||
| `tests/concurrent-writes.test.js` | Race conditions, concurrent access, MongoDB 5.x compatibility |
|
||||
|
||||
### API Behavior Summary
|
||||
| Interface | Single Object | Array Input | Response Format |
|
||||
|-----------|---------------|-------------|-----------------|
|
||||
| API v1 `/api/treatments/` | Supported | Supported | Always Array |
|
||||
| API v1 `/api/devicestatus/` | Supported | Supported | Always Array |
|
||||
| API v1 `/api/entries/` | Supported | Supported | Always Array |
|
||||
| API v3 `/api/v3/{collection}` | Supported | Rejected (400) | Single Object |
|
||||
| WebSocket `dbAdd` | Supported | Supported | Always Array |
|
||||
|
||||
### Running Shape Handling Tests
|
||||
```bash
|
||||
npm test -- --grep "Shape Handling"
|
||||
npm test -- tests/api.shape-handling.test.js
|
||||
npm test -- tests/concurrent-writes.test.js
|
||||
```
|
||||
|
||||
## External Dependencies
|
||||
- **MongoDB:** Primary database for data storage.
|
||||
- **Socket.IO:** For real-time data communication.
|
||||
|
||||
Reference in New Issue
Block a user