test(backup): give the activity goals a valid fill in the settings round trip

The restore admits activity goals key by key against the goals schema,
so the generic { roundTrip } JSON fill was refused as an unknown goal
rather than carried. Fill the column with real goals and pin the
per-goal admission (valid goals kept, unknown keys and out-of-bounds
goals named) in the unit suite.
This commit is contained in:
Marc-André Bombeck committed 2026-10-22 01:12:17 +02:00
1 parent 455e92c5a5
commit 832a9da98a
2 files changed
+38

No files matched your search

@@ -198,6 +198,41 @@ describe("admitAccountSettings", () => {
]);
});
it("keeps the valid activity goals and names the ones it drops", () => {
const { data, refused } = admitAccountSettings(
{
activityGoalsJson: {
workoutsPerWeek: 4,
activeMinutesPerWeek: 150,
stepsPerWeek: 70_000,
stepsPerMonth: 300_000,
stepsPerDay: 10_000,
workoutsPerWeekTypo: "four",
},
},
ctx,
);
expect(data.activityGoalsJson).toEqual({
workoutsPerWeek: 4,
activeMinutesPerWeek: 150,
stepsPerWeek: 70_000,
stepsPerMonth: 300_000,
});
expect(refused.sort()).toEqual([
"activityGoalsJson.stepsPerDay",
"activityGoalsJson.workoutsPerWeekTypo",
]);
});
it("refuses an activity goal outside its bounds and keeps the rest", () => {
const { data, refused } = admitAccountSettings(
{ activityGoalsJson: { workoutsPerWeek: 0, stepsPerWeek: 50_000 } },
ctx,
);
expect(data.activityGoalsJson).toEqual({ stepsPerWeek: 50_000 });
expect(refused).toEqual(["activityGoalsJson.workoutsPerWeek"]);
});
// #1126 — the reasoning setting lives on the provider chain entries, so
// the chain column carries it through a backup unchanged.
it("carries the provider chain's reasoning settings through a round trip", async () => {
@@ -4239,6 +4239,9 @@ const USER_FILL_OVERRIDES: Readonly<Record<string, unknown>> = {
"User.aiBaseUrl": "https://llm.example.com/v1",
"User.aiCompatBaseUrl": "https://gateway.example.com/v1",
"User.thresholdsJson": { WEIGHT: { min: 60, max: 80 } },
// The restore admits goal by goal against the goals schema, so the generic
// `{ roundTrip }` blob would be refused as an unknown key, not carried.
"User.activityGoalsJson": { workoutsPerWeek: 4, stepsPerMonth: 250_000 },
"User.globalExcludedInjectionSites": ["THIGH_LEFT"],
"User.avatarBytes": () => {
const bytes = new Uint8Array(new ArrayBuffer(AVATAR_PNG.byteLength));