mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
feat(measurements): accept restingHeartRate, hrv, vo2max in the series enum
The iOS app surfaces these as series-capable, but the kind enum on /api/measurements/series did not accept them — opening the detail or trend view returned 422. The underlying MeasurementType enum already carries the values; this commit extends the route-side enum so the wire shape matches the data shape. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
26f13c5064
commit
19cfd69ff1
2 files changed
+26
No files matched your search
@@ -133,6 +133,21 @@ describe("GET /api/measurements/series", () => {
|
||||
const res = await GET(req("kind=weight&days=3651"));
|
||||
expect(res.status).toBe(422);
|
||||
});
|
||||
|
||||
it.each(["restingHeartRate", "heartRateVariability", "vo2Max"])(
|
||||
"accepts kind=%s (v1.5.5)",
|
||||
async (kind) => {
|
||||
// v1.5.5 — the iOS app surfaces these as series-capable; the
|
||||
// previous enum rejected them with 422 even though the
|
||||
// underlying MeasurementType already carried the values.
|
||||
vi.mocked(getSession).mockResolvedValue(SESSION_OK as never);
|
||||
vi.mocked(prisma.measurement.findMany).mockResolvedValue([] as never);
|
||||
const res = await GET(req(`kind=${kind}&days=30`));
|
||||
expect(res.status).toBe(200);
|
||||
const body = (await res.json()) as { data: { kind: string } };
|
||||
expect(body.data.kind).toBe(kind);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe("GET /api/measurements/series — 422 multi-issue (v1.4.43 W6)", () => {
|
||||
|
||||
@@ -34,6 +34,14 @@ const kindEnum = z.enum([
|
||||
"totalBodyWater",
|
||||
"boneMass",
|
||||
"oxygenSaturation",
|
||||
// v1.5.5 — the iOS app surfaces these as series-capable, but
|
||||
// the route used to reject the trend/detail view request with a
|
||||
// 422. The underlying MeasurementType enum already carries each
|
||||
// value; this list extends the camelCase wire shape so the route
|
||||
// matches the data it can serve.
|
||||
"restingHeartRate",
|
||||
"heartRateVariability",
|
||||
"vo2Max",
|
||||
]);
|
||||
|
||||
const querySchema = z.object({
|
||||
@@ -58,6 +66,9 @@ const KIND_TO_TYPE: Record<z.infer<typeof kindEnum>, MeasurementType> = {
|
||||
totalBodyWater: "TOTAL_BODY_WATER",
|
||||
boneMass: "BONE_MASS",
|
||||
oxygenSaturation: "OXYGEN_SATURATION",
|
||||
restingHeartRate: "RESTING_HEART_RATE",
|
||||
heartRateVariability: "HEART_RATE_VARIABILITY",
|
||||
vo2Max: "VO2_MAX",
|
||||
};
|
||||
|
||||
interface SeriesPoint {
|
||||
|
||||
Reference in new issue
Block a user