fix(rules): review and harden rule-history editing

This commit is contained in:
Lucas Winther
2026-09-29 19:01:57 +02:00
parent 8c3dbafc86
commit c93ff9908c
6 changed files with 154 additions and 41 deletions
+13
View File
@@ -230,6 +230,19 @@ describe("rule versions on import", () => {
data.posts[0].rules = [{ from: "2026-01", rule: { kind: "everySecondTuesday" } }];
expect(() => parseDatasetJson(JSON.stringify(data))).toThrow(/everySecondTuesday/);
});
test.each([
["missing percent", { kind: "percentOfIncome" }],
["string percent", { kind: "percentOfIncome", percent: "10" }],
["null percent", { kind: "percentOfIncome", percent: null }],
["missing fixed amount", { kind: "fixed", amount: { currency: "DKK" } }],
["string fixed amount", { kind: "fixed", amount: { amount: "500", currency: "DKK" } }],
["null fixed amount", { kind: "fixed", amount: { amount: null, currency: "DKK" } }],
])("rejects a %s before it can corrupt the fold", (_label, rule) => {
const data = populated() as any;
data.posts[0].rules = [{ from: "2026-01", rule }];
expect(() => parseDatasetJson(JSON.stringify(data))).toThrow(ImportValidationError);
});
});
describe("the decimal-places setting on import", () => {