Commit Graph
6456 Commits
Author SHA1 Message Date
Ben WestandCopilot 81393a4c1f docs: update Node.js requirements and add test documentation
- README.md: Update from Node 14/16 to Node 20+ (v22, v24 supported)
- README.md: Update MongoDB from 4.2/4.4 to 4.4+ (5.0, 6.0 supported)
- CONTRIBUTING.md: Add 'Running Tests Locally' section
- Document NODE_ENV=test requirement for safety
- Document npm scripts: test:unit, test:integration

Addresses DOC-NODE-001 and DOC-ENV-001 from release-15.0.7-documentation.md

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-17 13:02:12 -07:00
Andy LowandGitHub cdef1e7c2c Merge pull request #8421 from bewest/wip/bewest/mongodb-5x
Wip/bewest/mongodb 5x
2026-03-16 19:37:34 +00:00
Ben WestandCopilot 96f9697866 test: add retry to AAPS entry dedup test for CI flakiness
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>
2026-03-12 14:16:21 -07:00
Ben WestandCopilot b76fb3e18a test: remove completed MongoDB 5.x array investigation tests
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>
2026-03-12 14:09:36 -07:00
Ben WestandCopilot ee3e6af76e ci: temporarily allow Node 20 for branch protection compliance
GitHub deprecated Node 20 on runners (2025-09-19), but branch protection
rules still require Node 20 tests to pass. Set ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true
only for the test job, not publish.

Reverts node-version matrix to [20, 22] to match master.

Ref: https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-12 12:49:43 -07:00
Ben WestandCopilot e12cf3d2e2 fix(tests): make NODE_ENV=test check a hard failure (GAP-SYNC-046)
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>
2026-03-12 12:39:01 -07:00
Ben WestandCopilot 61501cac3a feat(tests): add NODE_ENV=test safety check (GAP-SYNC-046)
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>
2026-03-12 12:24:15 -07:00
Ben WestandCopilot b88155057c fix(entries): handle UUID _id in CGM entries (GAP-SYNC-045)
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>
2026-03-11 14:36:23 -07:00
Ben West 3758b6e339 github deprecates node 20 on runners 2026-03-10 16:35:16 -07:00
Ben WestandCopilot abd89f7935 test: add v3 API identifier generation tests (REQ-SYNC-072)
TEST-V3-ID-001: Null identifier generates ObjectId, copies to identifier
TEST-V3-ID-002: ObjectId string as identifier uses it directly
TEST-V3-ID-003: UUID string identifier preserved as-is

Validates Option G behavior extends to v3 API endpoints.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-10 16:13:51 -07:00
Ben WestandCopilot 02eec1b5a7 test: add identifier field tests for AAPS pattern (REQ-SYNC-072)
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>
2026-03-10 15:26:39 -07:00
Ben WestandCopilot 595219f9c4 Add Loop SGV entry and DeviceStatus upload tests
SGV Entry Tests (TEST-SGV-001 to 005):
- Single SGV with required fields
- All direction values
- Loop device identifier preserved
- Dexcom device with filtered/unfiltered/noise
- SGV deduplication by date+device
- Different devices create separate entries
- MBG (manual BG check) entries

DeviceStatus Tests (TEST-DS-001 to 005):
- Loop status with IOB/COB
- Loop predicted values array
- Loop enacted temp basal
- Pump reservoir and battery
- Omnipod specific fields
- Override in deviceStatus
- Override with insulinNeedsScaleFactor
- Complete Loop deviceStatus

17 new tests, all passing (716 total).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-10 15:03:48 -07:00
Ben WestandCopilot 16191f9c99 Add Loop carb and dose upload tests
Carb Tests (TEST-CARB-001 to 004):
- Create carb with syncIdentifier and absorptionTime
- Create carb with fat/protein (Warsaw FPU method)
- Create carb with cached _id
- Update carb via cached _id
- Delete carb via cached _id

Dose Tests (TEST-DOSE-001 to 005):
- Bolus with syncIdentifier
- Meal bolus with carbs and insulin
- Temp basal with rate and duration
- Suspend (zero rate) temp basal
- Update dose via cached _id
- Hex string syncIdentifier (pump events)
- Mixed dose batch maintains order

13 new tests, all passing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-10 15:00:16 -07:00
Ben WestandCopilot d12bebe303 Add identity field test matrix for AID clients
Client Pattern Tests:
- TEST-ID-001: Loop Override UUID _id → identifier
- TEST-ID-002: Loop Override identifier field
- TEST-ID-003: Loop Carb syncIdentifier
- TEST-ID-004: AAPS identifier: null
- TEST-ID-005: AAPS identifier: ObjectId
- TEST-ID-006: xDrip+ uuid + _id fields

v1 API Identity Tests:
- TEST-V1-ID-001: No id field
- TEST-V1-ID-002: Valid ObjectId
- TEST-V1-ID-003: UUID string (REQ-SYNC-072)
- TEST-V1-ID-004: syncIdentifier field

Deduplication Tests:
- Duplicate identifier handling
- Unique identifiers create separate docs

12 new tests, all passing.

Refs: REQ-SYNC-072, GAP-TREAT-012

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-10 14:58:05 -07:00
Ben WestandCopilot 8ba8bbb18e Add ObjectIdCache workflow tests for Loop sync patterns
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>
2026-03-10 14:56:01 -07:00
Ben WestandCopilot 4af34767c2 Add GAP-TREAT-012 test suite for Loop override UUID handling
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>
2026-03-10 14:54:00 -07:00
Ben WestandCopilot e78a5bc6e7 fix(treatments): implement REQ-SYNC-072 server-controlled ID with transparent promotion
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>
2026-03-10 13:36:34 -07:00
Andy Low 1231ec6b65 Handle UUID treatment ids in v1 API 2026-03-08 01:01:57 +00:00
Andy Low 505e375efc Fix mmol BG display in OpenAPS tooltips 2026-03-06 23:42:58 +00:00
Andy Low eb105949d4 Enable Traditional Chinese localization 2026-03-06 23:24:50 +00:00
Andy Low 1cab4909ef Fix Spanish translation JSON 2026-03-06 22:29:36 +00:00
Andy Low c77097abd8 Merge remote-tracking branch 'origin/dev' into pr-8421
# Conflicts:
#	package-lock.json
2026-03-06 21:51:52 +00:00
Andy Low faf578c08e Add MongoDB 8 compatibility follow-up fixes 2026-03-06 21:35:16 +00:00
Ben West 13d314119d new dev area for 15.0.7
This initializes development after releasing 15.0.6.
2026-03-03 15:07:43 -08:00
Ben WestandGitHub 9cd304f78a Merge pull request #8442 from nightscout/dev
release for 15.0.6
2026-03-03 14:57:48 -08:00
Ben West 797df9bdda Update bridge deps to 0.2.12/1.5.8
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.
2026-03-03 12:20:47 -08:00
Ben West 6852e550a8 cut new dev for 15.0.6
Post release 15.0.5, we will develop branch for 15.0.6.
2026-03-03 11:32:05 -08:00
Ben WestandGitHub f988ed9869 Merge pull request #8436 from nightscout/dev
Release 15.0.5
2026-03-01 13:17:22 -08:00
Ben WestandGitHub 743506a6a0 Merge pull request #8438 from nightscout/fix/docker-force
Dockerfile: Add --force to bypass platform check
2026-03-01 12:56:59 -08:00
Ben West aa13913093 Dockerfile: Add --force to bypass platform check
npm ci fails with EBADPLATFORM when lockfile contains darwin-only
packages (fsevents), even with --omit=optional. The --force flag
bypasses this check.
2026-03-01 12:53:32 -08:00
Ben WestandGitHub ee2bfa4fe7 Merge pull request #8437 from nightscout/fix/heroku-fsevents
Fix/heroku fsevents
2026-03-01 12:40:30 -08:00
Ben West b8aec4429c CI: Test only Node 20 and 22
Node 16 EOL was September 2023. Docker image uses Node 22.
Reduces CI matrix from 9 to 6 jobs.
2026-03-01 12:30:27 -08:00
Ben West 4130f325c5 Update bridge deps to 0.2.11/1.5.7 (fsevents fix)
Both bridge packages now have clean shrinkwraps without devDependencies,
eliminating the fsevents (darwin-only) entries that caused Heroku build failures.
2026-03-01 12:28:29 -08:00
Ben West ecafd4782c Fix Docker/Heroku builds with --omit=optional
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.
2026-03-01 12:25:55 -08:00
Ben West a5ada47d32 first commit to cut new 15.0.5 dev branch 2026-03-01 12:02:54 -08:00
Ben WestandGitHub b03c604643 Merge pull request #8352 from nightscout/dev
release 15.0.4
2026-02-28 09:00:37 -08:00
Ben WestandGitHub 7ae17b13f5 Merge pull request #8433 from nightscout/test/node22-pr
Test/node22 pr
2026-02-27 15:07:57 -08:00
Ben WestandCopilot 0fb628e1c4 Update CI matrix to test Node 16, 20, 22
- Remove lts/* (redundant with explicit versions)
- Add Node 16 for backwards compatibility testing
- Skip Node 18 (flaky tests, will be fixed in MongoDB PR)
- Keep MongoDB 4.4, 5.0, 6.0 matrix

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-27 14:53:30 -08:00
Ben WestandCopilot e0cc9ff5df Relax Node version constraints to >=16.x
- 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>
2026-02-27 14:52:56 -08:00
Ben West 019fa51cff Merge PR #8357 (Node 22 upgrade) 2026-02-27 14:06:32 -08:00
Ben WestandGitHub 535b50e9e0 Merge pull request #8432 from nightscout/wip/bewest/update-bridge-deps
Wip/bewest/update bridge deps
2026-02-27 14:03:03 -08:00
Ben WestandCopilot d81d6854c0 Update bridge dependencies to final deprecated versions
- 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>
2026-02-27 13:36:08 -08:00
Ben WestandCopilot 6a48ea89cf Update bridge dependencies to final deprecated versions
- 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>
2026-02-27 13:16:04 -08:00
Ben West f441d6a6fa ensure AUTH_FAIL_DELAY for ci 2026-01-19 19:07:19 -08:00
Ben West 93945b749e ensure auth tests have a proper delay set
It needs a small delay to test with.
2026-01-19 18:50:11 -08:00
Ben West 7a2d345491 move workflow out of way 2026-01-20 02:40:50 +00:00
bewest 58ad1d7b69 Update project documentation to reflect recent changes
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
2026-01-20 02:14:59 +00:00
bewest 6e4ff939f8 Add optional concurrent write stress tests to CI workflow
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
2026-01-20 02:14:20 +00:00
bewest ba95c1e054 Transitioned from Plan to Build mode
Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 605cec52-e52a-4520-8af0-466d9c971344
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 052f1302-557b-4bfe-a808-973d737e88b1
Replit-Helium-Checkpoint-Created: true
2026-01-20 02:12:03 +00:00
bewest 17d3a74f91 Saved progress at the end of the loop
Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 605cec52-e52a-4520-8af0-466d9c971344
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: b141af6b-dc36-41d1-9b8c-70b60b2798e6
Replit-Helium-Checkpoint-Created: true
2026-01-20 02:05:46 +00:00