From 832a9da98a4915b7dd14119d2752279ac824f718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Thu, 22 Oct 2026 01:12:17 +0200 Subject: [PATCH] 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. --- .../__tests__/account-settings-backup.test.ts | 35 +++++++++++++++++++ tests/integration/backup-round-trip.test.ts | 3 ++ 2 files changed, 38 insertions(+) diff --git a/src/lib/export/__tests__/account-settings-backup.test.ts b/src/lib/export/__tests__/account-settings-backup.test.ts index 09b105b6f..4784869d2 100644 --- a/src/lib/export/__tests__/account-settings-backup.test.ts +++ b/src/lib/export/__tests__/account-settings-backup.test.ts @@ -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 () => { diff --git a/tests/integration/backup-round-trip.test.ts b/tests/integration/backup-round-trip.test.ts index fcf557ca4..408ed1b73 100644 --- a/tests/integration/backup-round-trip.test.ts +++ b/tests/integration/backup-round-trip.test.ts @@ -4239,6 +4239,9 @@ const USER_FILL_OVERRIDES: Readonly> = { "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));