mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-13 06:32:03 +00:00
fix(visits): cap the window before a visit at the longest report
The window before a booked visit started at the last matching visit however far back it lay, while the health-report export covers 730 days and fell back to its 90-day default for anything longer. The card then offered a report the export did not build. The window now stops at the export's limit, read from one shared constant, and preparation.capped says when it did; the web says "The last two years" for it. The export clamps an over-long explicit range to the last 730 days before its end instead of falling back to 90 days, so a custom range or a linked window cannot shrink silently either, and its day count forgives the hour a clock change adds, so two years of local days count as 730.
This commit is contained in:
1 parent
f39598f2e7
commit
da3d29424d
22 files changed
+282
-32
No files matched your search
@@ -127,6 +127,7 @@ describe("<ReportVisitOffer>", () => {
|
||||
practitionerName: "Former skin practice",
|
||||
specialty: "Dermatology",
|
||||
},
|
||||
capped: false,
|
||||
},
|
||||
}),
|
||||
]);
|
||||
@@ -144,6 +145,7 @@ describe("<ReportVisitOffer>", () => {
|
||||
to: "2026-12-01",
|
||||
basis: "default",
|
||||
since: null,
|
||||
capped: false,
|
||||
},
|
||||
}),
|
||||
]);
|
||||
@@ -153,6 +155,31 @@ describe("<ReportVisitOffer>", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("says the last two years on a window capped at the longest report", () => {
|
||||
const html = render([
|
||||
visit({
|
||||
id: "derm",
|
||||
preparation: {
|
||||
from: "2024-12-02",
|
||||
to: "2026-12-01",
|
||||
basis: "practitioner",
|
||||
since: {
|
||||
id: "old-derm",
|
||||
occurredAt: "2022-03-02T09:00:00.000Z",
|
||||
kind: "SPECIALIST",
|
||||
practitionerName: "Skin practice",
|
||||
specialty: "Dermatology",
|
||||
},
|
||||
capped: true,
|
||||
},
|
||||
}),
|
||||
]);
|
||||
expect(html).toContain("The last two years");
|
||||
expect(html).toContain("a report covers two years at most");
|
||||
// Not "since your last visit", which would promise the whole stretch.
|
||||
expect(html).not.toContain("Since your last visit");
|
||||
});
|
||||
|
||||
it("applies the server's start and the appointment's day on a press", () => {
|
||||
const at = new Date(Date.now() + 5 * DAY_MS);
|
||||
const window = visitReportWindow(
|
||||
@@ -164,6 +191,7 @@ describe("<ReportVisitOffer>", () => {
|
||||
to: "2026-12-01",
|
||||
basis: "default",
|
||||
since: null,
|
||||
capped: false,
|
||||
},
|
||||
}),
|
||||
"Europe/Berlin",
|
||||
@@ -188,6 +216,7 @@ describe("<ReportVisitOffer>", () => {
|
||||
to: "2026-11-12",
|
||||
basis: "default",
|
||||
since: null,
|
||||
capped: false,
|
||||
},
|
||||
});
|
||||
expect(visitReportWindow(early, "America/New_York")).toEqual({
|
||||
|
||||
Reference in new issue
Block a user