mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 14:16:12 +00:00
fix(insights): plot the trends row and log fevers in the reader's units
Two more surfaces carried a fixed unit. The insights trends row labelled weight in kg and body temperature in °C for every reader, and plotted walking distance as raw metres under a km label; its trend caption said the same. A single transformed series there now takes unit, scale and offset from the preference, and the caption describes the converted series against a converted noise floor. The illness day sheet and timeline showed and took a fever in °C. The fever is now seeded, typed and shown in the reader's temperature unit and stored in °C as before. Refs #1067
This commit is contained in:
1 parent
d6f79c8bef
commit
bc2d60cce8
16 files changed
+229
-38
No files matched your search
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* A logged fever reads in the reader's temperature unit. The timeline and the
|
||||
* day sheet printed a hardcoded °C, so an imperial account read its own
|
||||
* fever in Celsius.
|
||||
*/
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
|
||||
const account = vi.hoisted(() => ({
|
||||
user: { unitPreference: "imperial", glucoseUnit: null } as Record<
|
||||
string,
|
||||
unknown
|
||||
>,
|
||||
}));
|
||||
|
||||
vi.mock("@/hooks/use-auth", () => ({
|
||||
useAuth: () => ({ user: account.user, isAuthenticated: true }),
|
||||
useAccountOnceMounted: () => account.user,
|
||||
}));
|
||||
|
||||
vi.mock("@/hooks/use-record-capabilities", () => ({
|
||||
useRecordCapabilities: () => ({ canManageDomain: () => true }),
|
||||
}));
|
||||
|
||||
vi.mock("../use-illness", () => ({
|
||||
useIllnessDayLogList: () => ({
|
||||
isLoading: false,
|
||||
isError: false,
|
||||
data: {
|
||||
dayLogs: [
|
||||
{
|
||||
id: "d1",
|
||||
episodeId: "e1",
|
||||
date: "2026-09-30",
|
||||
functionalImpact: null,
|
||||
feverC: 38.5,
|
||||
symptoms: [],
|
||||
note: null,
|
||||
updatedAt: "2026-09-30T08:00:00.000Z",
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
}));
|
||||
|
||||
import { I18nProvider } from "@/lib/i18n/context";
|
||||
import { IllnessDayTimeline } from "../illness-day-timeline";
|
||||
|
||||
function render(): string {
|
||||
return renderToStaticMarkup(
|
||||
<I18nProvider initialLocale="en">
|
||||
<IllnessDayTimeline episodeId="e1" onLogDay={() => {}} />
|
||||
</I18nProvider>,
|
||||
);
|
||||
}
|
||||
|
||||
describe("<IllnessDayTimeline> fever unit", () => {
|
||||
it("shows the fever in °F for an imperial reader", () => {
|
||||
account.user = { unitPreference: "imperial", glucoseUnit: null };
|
||||
const html = render();
|
||||
// 38.5 °C = 101.3 °F.
|
||||
expect(html).toContain("Temperature: 101.3 °F");
|
||||
expect(html).not.toContain("°C");
|
||||
});
|
||||
|
||||
it("keeps °C for a metric reader", () => {
|
||||
account.user = { unitPreference: "metric", glucoseUnit: null };
|
||||
expect(render()).toContain("Temperature: 38.5 °C");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user