test(measurements,whoop): the workout fall-through test reaches its path again

Ladder reconciliation ranks every enum source, so the unranked
fall-through needs out-of-enum fixtures now; a stored single-source
ladder resolving one canonical row is pinned as the new contract. The
body-sync test sheds the import its retired weight path used.
This commit is contained in:
Marc-André Bombeck committed 2026-06-12 22:56:03 +02:00
1 parent 97822e9e6d
commit 550f314a54
2 files changed
+34 -13

No files matched your search

@@ -185,8 +185,36 @@ describe("pickCanonicalWorkoutRows", () => {
it("falls through to keeping every row when sources aren't on the ladder at all", () => {
// Theoretical safety net — no real source emits a value outside
// the canonical enum, but the picker MUST NEVER drop signal it
// can't classify. Forcing a ladder of a single source the bucket
// doesn't carry exercises the fallback path.
// can't classify. Since v1.16.11 the resolver reconciles every
// stored ladder against the defaults, so ANY enum source is always
// ranked — the only unrankable rows carry a source outside the
// enum entirely (a future source reaching an old reader).
const rows = [
{
id: "a",
startedAt: new Date("2026-05-16T08:00:00Z"),
sportType: "running",
source: "SOMETHING_NEW" as never,
},
{
id: "b",
startedAt: new Date("2026-05-16T08:01:00Z"),
sportType: "running",
source: "SOMETHING_ELSE" as never,
},
] as RowFixture[];
expect(
pickCanonicalWorkoutRows(rows, null)
.map((r) => r.id)
.sort(),
).toEqual(["a", "b"]);
});
it("a stored single-source ladder still resolves a canonical row (reconciled defaults rank the rest)", () => {
// The pre-v1.16.11 contract for this input was "nothing ranked →
// keep both"; reconciliation now appends the default ladder after
// the stored entry, so the bucket resolves one canonical row like
// every ranked pick.
const rows: RowFixture[] = [
{
id: "a",
@@ -201,15 +229,9 @@ describe("pickCanonicalWorkoutRows", () => {
source: "WITHINGS",
},
];
const oddPriority = {
metricPriority: {
steps: ["IMPORT"],
},
};
expect(
pickCanonicalWorkoutRows(rows, oddPriority)
.map((r) => r.id)
.sort(),
).toEqual(["a", "b"]);
const picked = pickCanonicalWorkoutRows(rows, {
metricPriority: { steps: ["IMPORT"] },
}).map((r) => r.id);
expect(picked).toHaveLength(1);
});
});
@@ -8,7 +8,6 @@
*/
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { WhoopApiError } from "../response-classifier";
import type { WhoopMeasurementUpsert } from "../sync";
// ── Module mocks ────────────────────────────────────────────────
const {