mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 13:01:00 +00:00
Merge remote-tracking branch 'origin/main' into fix/v1398-polish
This commit is contained in:
commit
ba426706be
7 files changed
+131
-5
No files matched your search
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* The manual-entry form offers the resting heart rate (#1079).
|
||||
*
|
||||
* Resting heart rate has its own chart and series, separate from spot pulse.
|
||||
* A value read off a watch or taken on waking had no row in the form, so it
|
||||
* could only be logged as a pulse, which feeds a different chart.
|
||||
*/
|
||||
import { describe, it, expect } from "vitest";
|
||||
|
||||
import { VALUE_RANGES, getUnitForType } from "@/lib/validations/measurement";
|
||||
import {
|
||||
MEASUREMENT_FORM_TYPE_VALUES,
|
||||
MEASUREMENT_TYPES,
|
||||
} from "@/components/measurements/measurement-form";
|
||||
import en from "../../../../messages/en.json";
|
||||
|
||||
describe("manual entry of the resting heart rate", () => {
|
||||
it("offers it as its own type, next to pulse", () => {
|
||||
expect(MEASUREMENT_FORM_TYPE_VALUES).toContain("RESTING_HEART_RATE");
|
||||
const values = MEASUREMENT_TYPES.map((t) => t.value);
|
||||
expect(values.indexOf("RESTING_HEART_RATE")).toBe(
|
||||
values.indexOf("PULSE") + 1,
|
||||
);
|
||||
});
|
||||
|
||||
it("uses the server's unit, a labelled row and a plausible placeholder", () => {
|
||||
const row = MEASUREMENT_TYPES.find((t) => t.value === "RESTING_HEART_RATE");
|
||||
expect(row).toBeDefined();
|
||||
expect(row && "unit" in row ? row.unit : undefined).toBe(
|
||||
getUnitForType("RESTING_HEART_RATE"),
|
||||
);
|
||||
expect(
|
||||
(en as { measurements: Record<string, string> }).measurements
|
||||
.typeRestingHeartRate,
|
||||
).toBeTruthy();
|
||||
const range = VALUE_RANGES.RESTING_HEART_RATE;
|
||||
const placeholder = Number(
|
||||
row && "placeholder" in row ? row.placeholder : NaN,
|
||||
);
|
||||
if (range) {
|
||||
expect(placeholder).toBeGreaterThanOrEqual(range.min);
|
||||
expect(placeholder).toBeLessThanOrEqual(range.max);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -67,6 +67,14 @@ export const MEASUREMENT_TYPES = [
|
||||
unit: "bpm",
|
||||
placeholder: "72",
|
||||
},
|
||||
// The resting heart rate has its own chart and series; a value read off a
|
||||
// watch or taken on waking belongs there rather than among spot pulses.
|
||||
{
|
||||
value: "RESTING_HEART_RATE",
|
||||
labelKey: "measurements.typeRestingHeartRate",
|
||||
unit: "bpm",
|
||||
placeholder: "58",
|
||||
},
|
||||
{
|
||||
value: "BODY_FAT",
|
||||
labelKey: "measurements.typeBodyFat",
|
||||
|
||||
Reference in new issue
Block a user