Skip to content

Commit d5125b3

Browse files
committed
test(review): cover gateConfigToJson's mode-only/minScore-only copycat round-trip
gate.copycat.mode and gate.copycat.minScore are independently optional in the source YML, but every existing gateConfigToJson round-trip test set both together (or left both null), leaving the "only one of the two is set" branch inside gateConfigToJson's copycat block uncovered.
1 parent 890c2c4 commit d5125b3

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

test/unit/focus-manifest.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,20 @@ describe("parseFocusManifest gate config", () => {
12031203
expect(bad.warnings.some((w) => /gate\.copycat/.test(w))).toBe(true);
12041204
});
12051205

1206+
it("gateConfigToJson round-trips gate.copycat with only ONE of mode/minScore set (#1969)", () => {
1207+
// Each field is independently optional in the source YML, so gateConfigToJson must not assume they always
1208+
// arrive together -- mode-only and minScore-only must each serialize without the other key present.
1209+
const modeOnly = parseFocusManifest({ gate: { copycat: { mode: "label" } } });
1210+
const modeOnlyJson = gateConfigToJson(modeOnly.gate) as Record<string, Record<string, unknown>>;
1211+
expect(modeOnlyJson).toMatchObject({ copycat: { mode: "label" } });
1212+
expect(modeOnlyJson.copycat).not.toHaveProperty("minScore");
1213+
1214+
const minScoreOnly = parseFocusManifest({ gate: { copycat: { minScore: 42 } } });
1215+
const minScoreOnlyJson = gateConfigToJson(minScoreOnly.gate) as Record<string, Record<string, unknown>>;
1216+
expect(minScoreOnlyJson).toMatchObject({ copycat: { minScore: 42 } });
1217+
expect(minScoreOnlyJson.copycat).not.toHaveProperty("mode");
1218+
});
1219+
12061220
it("accepts every gate.copycat.mode tier (off/warn/label/block) and warns on an unknown one (#1969)", () => {
12071221
for (const mode of ["off", "warn", "label", "block"] as const) {
12081222
expect(parseFocusManifest({ gate: { copycat: { mode } } }).gate.copycatMode).toBe(mode);

0 commit comments

Comments
 (0)