mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 13:01:00 +00:00
Emit the strain device block on every wellness read
The published WellnessScoreValue lists every field the engine sends, and the contract test holds the two sets equal. The computed path now sends device: null like anchor and components, and the device path has its own contract case.
This commit is contained in:
1 parent
2b91953cc9
commit
aa3049a14c
2 files changed
+26
No files matched your search
@@ -112,4 +112,29 @@ describe("published WellnessScoreValue", () => {
|
||||
Object.keys(derived.value as unknown as Record<string, unknown>).sort(),
|
||||
);
|
||||
});
|
||||
|
||||
it("accepts the strain value served from the device's day strain", async () => {
|
||||
findMany.mockImplementation(async (args: { where: { type: string } }) =>
|
||||
args.where.type === "DAY_STRAIN"
|
||||
? [
|
||||
{
|
||||
value: 12.6,
|
||||
measuredAt: new Date("2026-06-01T04:00:00Z"),
|
||||
source: "WHOOP",
|
||||
},
|
||||
]
|
||||
: [],
|
||||
);
|
||||
const derived = await computeWellnessScore("STRAIN_SCORE", "u1", PROFILE, {
|
||||
now: NOW,
|
||||
});
|
||||
expect(derived.status).toBe("ok");
|
||||
if (derived.status !== "ok") return;
|
||||
const parsed = wellnessScoreValue.safeParse(derived.value);
|
||||
expect(parsed.error?.issues ?? []).toEqual([]);
|
||||
expect(Object.keys(wellnessScoreValue.shape).sort()).toEqual(
|
||||
Object.keys(derived.value as unknown as Record<string, unknown>).sort(),
|
||||
);
|
||||
findMany.mockReset();
|
||||
});
|
||||
});
|
||||
@@ -287,6 +287,7 @@ export async function computeWellnessScore(
|
||||
.reverse(),
|
||||
anchor,
|
||||
components,
|
||||
device: null,
|
||||
},
|
||||
coverage: {
|
||||
requiredInputs: 1,
|
||||
|
||||
Reference in new issue
Block a user