This test passes locally in ~50ms but occasionally times out at 30s
in constrained GitHub runners. Adding retries(2) allows it to recover
from transient CI resource contention.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The 'WebSocket dbAdd Array Handling Investigation' block was R&D to
understand insertOne behavior with arrays. The investigation concluded:
- MongoDB's insertOne([a,b]) creates single doc (not multiple)
- Fix: sequential processing via processNextItem() in websocket.js
Production tests now cover this behavior:
- 'dbAdd with array input for treatments - current behavior test'
- 'dbAdd with array input for devicestatus - current behavior test'
- 'dbAdd with array input for entries - current behavior test'
Removes 2 flaky investigative tests, keeps 729 production tests passing.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Change from warning to process.exit(1) to prevent any possibility of
running destructive test operations against a production database.
Tests now fail immediately if NODE_ENV !== 'test', with clear instructions
on how to fix.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
SAFETY-001: Fix tests/ci.test.env to use NODE_ENV=test instead of production
SAFETY-002: Add NODE_ENV check to tests/hooks.js with warning
SAFETY-003: Create tests/fixtures/test-guard.js with guarded deleteMany/drop helpers
This prevents deleteMany({}) from accidentally running against production
databases if test environment is misconfigured.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Trio/Loop upload CGM entries with UUID strings as _id field.
This caused MongoDB errors when re-uploading with different UUID
at same timestamp: "immutable field '_id'" error.
Fix:
- Add normalizeEntryId() to extract UUID from _id to identifier field
- Add upsertQueryFor() to strip non-ObjectId _id before $set
- Maintain sysTime+type as primary dedup key for CGM data integrity
- Add identifier to indexed fields
Tests:
- 3 baseline tests document current sysTime+type dedup behavior
- 6 UUID handling tests including the previously-failing scenario
Refs: GAP-SYNC-045, REQ-SYNC-072
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add 3 new tests for explicit identifier field handling:
- supports identifier field for AAPS-style treatments
- deduplicates by identifier on re-upload
- supports batch upload with identifiers
These complement existing UUID _id tests (Loop pattern) to cover
both AID client sync patterns.
Refs: REQ-SYNC-072, GAP-TREAT-012
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
TEST-CACHE-001: POST carb → cache syncIdentifier → PUT with id
TEST-CACHE-002: POST dose → cache syncIdentifier → DELETE with id
TEST-CACHE-003: Cache miss (24hr expiry) → POST same syncIdentifier
TEST-CACHE-004: App restart (cache empty) → POST existing syncIdentifier
TEST-CACHE-005: Batch POST → verify response order → cache mapping
7 new tests validating Loop's ObjectIdCache behavior:
- syncIdentifier → ObjectId mapping
- Response order for batch operations
- Deduplication by syncIdentifier
- Hex string syncIdentifier handling
All 7 tests passing.
Refs: Loop ObjectIdCache.swift analysis
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
TEST-GAP-001: Loop override POST with UUID _id
TEST-GAP-002: Loop override DELETE by UUID
TEST-GAP-003: Loop override UPDATE by UUID
TEST-GAP-004: Loop override re-POST (upsert)
12 new tests validating REQ-SYNC-072 behavior:
- UUID _id promoted to identifier field
- Server generates valid ObjectId for _id
- Updates/deletes work via identifier lookup
- Duplicate detection via identifier
- Batch and edge case handling
New fixtures:
- loop-override.js: Real Loop override payload patterns
All 12 tests passing.
Refs: GAP-TREAT-012, REQ-SYNC-072
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Fixes#8450 - Loop Temporary Override sync breaks due to UUID _id handling
Option G Implementation:
- Extract client sync identity (identifier) from any source:
- Loop overrides: UUID in _id field → moved to identifier
- Loop carbs/doses: syncIdentifier → copied to identifier
- AAPS: identifier already present
- xDrip+: uuid → copied to identifier
- Server generates proper ObjectId for _id field
- Deduplication uses identifier (not _id) as primary key
- No database migration needed - gradual adoption
Changes:
- normalizeTreatmentId(): extracts client identity to identifier field
- upsertQueryFor(): identifier-first lookup, strips UUID _id for upsert
- create()/upsert()/save(): fetch _id from DB after update by identifier
- Added 'identifier' to indexedFields for efficient querying
- Updated UUID treatment test with full workflow coverage
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
These changes remove shrinkwrap from including dev dependencies for production
use. This is intended to solve errors in production environments like heroku
incorrectly pulling in darwin based chokidar and related mocha dependencies.
npm ci fails with EBADPLATFORM when lockfile contains darwin-only
packages (fsevents), even with --omit=optional. The --force flag
bypasses this check.
Both bridge packages now have clean shrinkwraps without devDependencies,
eliminating the fsevents (darwin-only) entries that caused Heroku build failures.
Use npm ci with --omit=optional to skip optional dependencies like
fsevents (darwin-only) that were causing build failures on Linux
platforms including Heroku and local Docker builds on Mac.
- Change engines.node from '^22.x || ^20.x' to '>=16.x'
- Change engines.npm from '>=10.x' to '>=8.x'
- Update runtime checkNodeVersion to allow Node 16+
- Creates overlap with previous release (^16.x || ^14.x)
This allows users on Node 16/18 to upgrade smoothly while
recommending Node 20 or 22 LTS for best support.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- share2nightscout-bridge: 0.2.9 → 0.2.10 (Node 22 support)
- minimed-connect-to-nightscout: 1.5.5 → 1.5.6 (Node 22 support)
Both packages now allow Node 18/20/22+ in their engines field.
This is a prerequisite for the Node 22 upgrade (PR #8357).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- share2nightscout-bridge: 0.2.9 → 0.2.10 (Node 22 support)
- minimed-connect-to-nightscout: 1.5.5 → 1.5.6 (Node 22 support)
Both packages now allow Node 18/20/22+ in their engines field.
This is a prerequisite for the Node 22 upgrade (PR #8357).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Update replit.md to document new stress test scripts and reorganize test descriptions.
Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 605cec52-e52a-4520-8af0-466d9c971344
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: dfcb132d-cfe2-469f-8659-b15111592030
Replit-Helium-Checkpoint-Created: true
Updates package.json to include `test:stress` scripts and adds an optional `stress-tests` job to the GitHub Actions CI workflow for concurrent write tests.
Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 605cec52-e52a-4520-8af0-466d9c971344
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Event-Id: fde695de-720c-4bfb-b5f1-ea6710172a09
Replit-Helium-Checkpoint-Created: true