mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
fix(treatments): correct UUID handling scope (only _id field)
REQ-SYNC-072 scope correction: normalizeTreatmentId() should ONLY handle UUID values in the _id field, not copy syncIdentifier or uuid fields to identifier. Changes: - normalizeTreatmentId(): Only extract UUID from _id to identifier - normalizeEntryId(): Same fix for entries collection - upsertQueryFor(): Add syncIdentifier and uuid as dedup fallbacks (fields are preserved, not copied to identifier) - Batch POST: Fetch _id for docs deduped by syncIdentifier/uuid Test updates: - TEST-ID-003, TEST-V1-ID-004: Updated to expect identifier NOT copied from syncIdentifier (scope fix) Affected clients: - Loop overrides (UUID _id → identifier): Still works - Loop carbs/doses (syncIdentifier): Dedup works, no identifier copy - xDrip+ (uuid): Dedup works, no identifier copy - AAPS (identifier): Unchanged Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -146,16 +146,17 @@ describe('Identity Field Test Matrix', function() {
|
||||
|
||||
const created = res.body[0];
|
||||
|
||||
// syncIdentifier preserved
|
||||
// syncIdentifier preserved (not touched by server)
|
||||
created.syncIdentifier.should.equal(syncId);
|
||||
|
||||
// _id generated as ObjectId
|
||||
created._id.should.match(/^[0-9a-f]{24}$/);
|
||||
|
||||
// identifier should also be set from syncIdentifier
|
||||
created.identifier.should.equal(syncId);
|
||||
// identifier should NOT be set from syncIdentifier (scope fix)
|
||||
// Server only handles UUID _id, not syncIdentifier field
|
||||
should.not.exist(created.identifier);
|
||||
|
||||
console.log(' ✓ syncIdentifier → identifier, ObjectId generated');
|
||||
console.log(' ✓ syncIdentifier preserved, identifier NOT copied (scope fix)');
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -362,7 +363,7 @@ describe('Identity Field Test Matrix', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('TEST-V1-ID-004: syncIdentifier copied to identifier', function(done) {
|
||||
it('TEST-V1-ID-004: syncIdentifier NOT copied to identifier (scope fix)', function(done) {
|
||||
const syncId = 'sync-id-' + Date.now();
|
||||
|
||||
const treatment = {
|
||||
@@ -383,16 +384,17 @@ describe('Identity Field Test Matrix', function() {
|
||||
|
||||
const created = res.body[0];
|
||||
|
||||
// syncIdentifier preserved
|
||||
// syncIdentifier preserved (not touched by server)
|
||||
created.syncIdentifier.should.equal(syncId);
|
||||
|
||||
// identifier should match
|
||||
created.identifier.should.equal(syncId);
|
||||
// identifier should NOT be set from syncIdentifier (scope fix)
|
||||
// Server only handles UUID _id, not syncIdentifier field
|
||||
should.not.exist(created.identifier);
|
||||
|
||||
// _id generated
|
||||
created._id.should.match(/^[0-9a-f]{24}$/);
|
||||
|
||||
console.log(' ✓ syncIdentifier → identifier');
|
||||
console.log(' ✓ syncIdentifier preserved, identifier NOT copied (scope fix)');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user