fix(backups): address restore review findings

This commit is contained in:
Marc-André Bombeck committed 2026-07-20 13:42:38 +02:00
1 parent 7eb3b91925
commit e9507a0c93
8 files changed
+29 -15

No files matched your search

@@ -100,7 +100,7 @@ const handler = apiHandler(
details: { reason: "missing_confirmation", backupId: id },
});
return apiError(
"Confirmation token missing — body must include confirm: 'RESTORE'",
"Confirmation token missing — restoring user data and included instance-wide settings requires confirm: 'RESTORE'",
422,
);
}
@@ -403,13 +403,11 @@ const handler = apiHandler(
unit: measurement.unit,
source: measurement.source ?? "MANUAL",
measuredAt: new Date(measurement.measuredAt),
notes: measurement.notes ?? null,
notes: null,
notesEncrypted:
measurement.notesEncrypted !== undefined
? measurement.notesEncrypted === null
? null
: decodeEncryptedBytes(measurement.notesEncrypted)
: encryptNote(measurement.notes ?? null),
measurement.notesEncrypted == null
? encryptNote(measurement.notes ?? null)
: decodeEncryptedBytes(measurement.notesEncrypted),
externalId: measurement.externalId ?? null,
externalSourceVersion: measurement.externalSourceVersion ?? null,
glucoseContext: (measurement.glucoseContext ?? null) as never,
@@ -421,7 +421,7 @@ describe("GET /api/export/full-backup", () => {
expect(res.headers.get("content-disposition")).toMatch(/\.json"/);
const json = await res.json();
expect(json).toMatchObject({
schemaVersion: "1",
schemaVersion: "2",
userId: "user-1",
measurements: [],
medications: [],
@@ -1,5 +1,7 @@
import { describe, expect, it, vi } from "vitest";
import { renderToStaticMarkup } from "react-dom/server";
import de from "../../../../messages/de.json";
import en from "../../../../messages/en.json";
/**
* v1.4.15 phase-C5 — `/admin/backups` empty state.
@@ -76,4 +78,13 @@ describe("BackupsSection — empty state", () => {
const matches = (html.match(/Backup now/g) ?? []).length;
expect(matches).toBeGreaterThanOrEqual(2);
});
it("warns in both catalogs that restore overwrites instance-wide settings", () => {
expect(de.admin.section.backups.restoreDescription).toMatch(
/instanzweite Einstellungen/i,
);
expect(en.admin.section.backups.restoreDescription).toMatch(
/instance-wide settings/i,
);
});
});
@@ -76,7 +76,7 @@ const appSettings = {
assistantHealthScoreExplainerEnabled: false,
moduleAvailabilityJson: { nutrients: false, insights: true },
documentMaxFileBytes: 12_345_678,
documentQuotaBytes: 9_876_543_210n,
documentQuotaBytes: BigInt("9876543210"),
};
function makePrisma() {