Files
memind/health-extraction.test.mjs
T
john f96fdcb3b9 feat(health): add P0 health channel kernel and encrypted health zone.
Lock health recording behind confirm-only state machines, reject public publishes for the health category, and ship the 14-day experiment Page Data templates with tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-09 18:04:26 +08:00

49 lines
1.4 KiB
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import { validateExtractionResult } from './health-extraction.mjs';
test('accepts a high-confidence blood pressure extraction', () => {
const result = validateExtractionResult({
metric_set: 'blood_pressure',
systolic: 137,
diastolic: 82,
pulse: 72,
confidence: { systolic: 0.97, diastolic: 0.95, pulse: 0.96 },
});
assert.equal(result.ok, true);
assert.equal(result.requireConfirm, true);
assert.deepEqual(result.lowConfidence, []);
});
test('rejects out-of-range values instead of committing', () => {
const result = validateExtractionResult({
metric_set: 'blood_pressure',
systolic: 300,
diastolic: 82,
confidence: { systolic: 0.99, diastolic: 0.99 },
});
assert.equal(result.ok, false);
assert.equal(result.unreadable, true);
});
test('rejects inverted systolic/diastolic without guessing a swap', () => {
const result = validateExtractionResult({
metric_set: 'blood_pressure',
systolic: 80,
diastolic: 120,
confidence: { systolic: 0.99, diastolic: 0.99 },
});
assert.equal(result.ok, false);
assert.equal(result.error, 'systolic_not_greater');
});
test('low confidence fields stay pending', () => {
const result = validateExtractionResult({
metric_set: 'weight',
weight: 67.2,
confidence: { weight: 0.4 },
});
assert.equal(result.ok, true);
assert.deepEqual(result.lowConfidence, ['weight']);
});