mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 07:42:23 +00:00
fix(documents): file an undated document under the reader's upload day
The archive grouped a document without a stated date by the UTC day of its upload, so an upload late on the last evening of a month west of UTC opened next month's section (and early on the first morning east of UTC, last month's). The upload day is now read in the profile time zone for the month sections and the year filter.
This commit is contained in:
1 parent
9ecdda6358
commit
cfddf097c7
5 files changed
+52
-14
No files matched your search
@@ -16,6 +16,7 @@ function render(uploadItems: UploadQueueItem[]) {
|
||||
return renderToStaticMarkup(
|
||||
<I18nProvider initialLocale="en">
|
||||
<DocumentTimeline
|
||||
timezone="UTC"
|
||||
documents={[]}
|
||||
uploadItems={uploadItems}
|
||||
onDismissUpload={() => {}}
|
||||
|
||||
@@ -133,7 +133,7 @@ describe("timeline items", () => {
|
||||
doc({ id: "c", documentDate: "2026-03-10" }),
|
||||
doc({ id: "d", documentDate: "2026-02-28" }),
|
||||
];
|
||||
const items = buildTimelineItems(docs, 2);
|
||||
const items = buildTimelineItems(docs, 2, "UTC");
|
||||
expect(items.map((i) => i.type)).toEqual([
|
||||
"month",
|
||||
"row",
|
||||
@@ -149,16 +149,37 @@ describe("timeline items", () => {
|
||||
|
||||
it("files an undated document under its upload day", () => {
|
||||
const d = doc({ documentDate: null, createdAt: "2026-01-05T10:00:00Z" });
|
||||
expect(documentDateKey(d)).toBe("2026-01-05");
|
||||
const items = buildTimelineItems([d], 3);
|
||||
expect(documentDateKey(d, "UTC")).toBe("2026-01-05");
|
||||
const items = buildTimelineItems([d], 3, "UTC");
|
||||
expect(items[0]).toEqual({ type: "month", key: "2026-01" });
|
||||
});
|
||||
|
||||
it("files an undated upload under the reader's day, not the UTC day", () => {
|
||||
// 22:30 on 31 January in Los Angeles is already 1 February in UTC.
|
||||
const d = doc({ documentDate: null, createdAt: "2026-02-01T06:30:00Z" });
|
||||
expect(documentDateKey(d, "America/Los_Angeles")).toBe("2026-01-31");
|
||||
expect(buildTimelineItems([d], 3, "America/Los_Angeles")[0]).toEqual({
|
||||
type: "month",
|
||||
key: "2026-01",
|
||||
});
|
||||
// And 1 March at 00:30 in Kiritimati is still 28 February in UTC.
|
||||
const e = doc({ documentDate: null, createdAt: "2026-02-28T10:30:00Z" });
|
||||
expect(documentDateKey(e, "Pacific/Kiritimati")).toBe("2026-03-01");
|
||||
});
|
||||
|
||||
it("keeps a stated document date whatever the zone", () => {
|
||||
const d = doc({
|
||||
documentDate: "2026-01-31",
|
||||
createdAt: "2026-02-01T06:30:00Z",
|
||||
});
|
||||
expect(documentDateKey(d, "Pacific/Kiritimati")).toBe("2026-01-31");
|
||||
});
|
||||
|
||||
it("keeps the DOM bounded: item count scales with rows, not documents", () => {
|
||||
const docs = Array.from({ length: 1000 }, (_, i) =>
|
||||
doc({ id: `d${i}`, documentDate: "2026-03-01" }),
|
||||
);
|
||||
const items = buildTimelineItems(docs, 4);
|
||||
const items = buildTimelineItems(docs, 4, "UTC");
|
||||
// 1 month header + 250 rows — the virtualizer then windows over these.
|
||||
expect(items).toHaveLength(251);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user