mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-18 08:02:12 +00:00
Merge branch 'feat/cap-s11-pulse' into release/v1.29.0
# Conflicts: # messages/de.json # messages/en.json # messages/es.json # messages/fr.json # messages/it.json # messages/pl.json # src/lib/daily/__tests__/digest.test.ts # src/lib/daily/digest.ts # src/lib/daily/load-digest.ts
This commit is contained in:
commit
2f1423fa09
17 files changed
+1289
-6
No files matched your search
@@ -59,6 +59,7 @@ function input(over: Partial<DailyDigestInput> = {}): DailyDigestInput {
|
||||
syncIssues: [],
|
||||
preventiveDue: [],
|
||||
coachPlans: [],
|
||||
tensionWindow: null,
|
||||
...over,
|
||||
};
|
||||
}
|
||||
@@ -481,3 +482,55 @@ describe("S12 — the milestone reward card", () => {
|
||||
expect(item?.body ?? "").not.toMatch(forbidden);
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildDailyDigest — S11 tension_window item", () => {
|
||||
function tension(d: ReturnType<typeof buildDailyDigest>) {
|
||||
return d.worthALook.find((i) => i.kind === "tension_window");
|
||||
}
|
||||
|
||||
it("emits a calm, non-diagnostic tension card when a window is present", () => {
|
||||
const d = buildDailyDigest(
|
||||
input({ tensionWindow: { partOfDay: "afternoon" } }),
|
||||
t,
|
||||
);
|
||||
const item = tension(d);
|
||||
expect(item).toBeDefined();
|
||||
expect(item?.status).toBe("info");
|
||||
expect(item?.actions[0].intent).toBe("pulse.view");
|
||||
expect(item?.actions[0].href).toBe("/insights/pulse");
|
||||
expect(item?.body).toContain("afternoon");
|
||||
});
|
||||
|
||||
it("emits nothing when there is no window (honest-absent)", () => {
|
||||
const d = buildDailyDigest(input({ tensionWindow: null }), t);
|
||||
expect(tension(d)).toBeUndefined();
|
||||
});
|
||||
|
||||
it("stays silent when the insights module is off", () => {
|
||||
const d = buildDailyDigest(
|
||||
input({
|
||||
modules: { insights: false },
|
||||
tensionWindow: { partOfDay: "morning" },
|
||||
}),
|
||||
t,
|
||||
);
|
||||
expect(tension(d)).toBeUndefined();
|
||||
});
|
||||
|
||||
it("yields the bounded rail to time-sensitive actions first", () => {
|
||||
const d = buildDailyDigest(
|
||||
input({
|
||||
medsToday: meds({ nextDueOverdue: true, nextDueMedicationName: "X" }),
|
||||
syncIssues: [
|
||||
{ integration: "withings", state: "error_reauth" },
|
||||
{ integration: "moodlog", state: "parked" },
|
||||
],
|
||||
tensionWindow: { partOfDay: "evening" },
|
||||
}),
|
||||
t,
|
||||
);
|
||||
// dose + 2 sync fill the cap; the calm tension marker waits.
|
||||
expect(d.worthALook).toHaveLength(MAX_WORTH_A_LOOK);
|
||||
expect(tension(d)).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user