Derive score-version fixtures from the SCORE_VERSION constant

Eight test and fixture files hardcoded scoreVersion: 2, a value the
constant has not held since v1.35.0. Now they import SCORE_VERSION and
use it, so a future bump cannot leave a fixture pinned to a stale
number.

The one genuinely historical case (record.test.ts, proving the input
fingerprint moves when the algorithm version moves) now derives both
its "previous" and "current" markers from SCORE_VERSION instead of two
unrelated literals, so the pair keeps its meaning after the next bump.
This commit is contained in:
Marc-André Bombeck committed 2026-08-02 00:15:29 +02:00
1 parent 7df25a6d92
commit af35346687
8 files changed
+35 -19

No files matched your search

@@ -22,6 +22,8 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
import { NextRequest } from "next/server";
import { Buffer } from "node:buffer";
import { SCORE_VERSION } from "@/lib/analytics/score/types";
process.env.ENCRYPTION_KEY =
"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
@@ -269,7 +271,7 @@ function sourceClient() {
timezone: "Europe/Berlin",
composite: 76,
band: "yellow",
scoreVersion: 2,
scoreVersion: SCORE_VERSION,
composition: ["BLOOD_PRESSURE", "SLEEP", "ADIPOSITY"],
pillarScores: { BLOOD_PRESSURE: 86, SLEEP: 100, ADIPOSITY: 42 },
inputFingerprint: "a".repeat(64),
@@ -629,7 +631,7 @@ describe("backup round trip — export, wire schema, restore", () => {
timezone: "Europe/Berlin",
composite: 76,
band: "yellow",
scoreVersion: 2,
scoreVersion: SCORE_VERSION,
inputFingerprint: "a".repeat(64),
});
// The composition and the per-pillar scores are what keep the stored day