Skip to content

Commit 0a076df

Browse files
committed
test(review): cover composeAdvisoryNotes' null fallthrough end-to-end (Codecov branch gap)
The composeAdvisoryNotes(...) ?? composeFallbackAdvisoryNotes(fallbackNotes) line's right-hand branch was never exercised through runLoopOverAiReview -- the prior score-terms tests only ever hit composeAdvisoryNotes' own internal non-null fallback text, never this outer nullish-coalescing fallthrough. Mirrors the existing "composeAdvisoryNotes returns null when no assessment or finding is public-safe" unit fixture, driven end-to-end instead.
1 parent f60a14c commit 0a076df

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

test/unit/ai-review.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3605,6 +3605,24 @@ describe("pure helpers", () => {
36053605
expect(deniedResult.status === "ok" ? deniedResult.advisoryNotes : undefined).not.toContain("filters results by their score");
36063606
});
36073607

3608+
it("REGRESSION (#public-score-terms-scoping, branch coverage): runLoopOverAiReview falls through to composeFallbackAdvisoryNotes when composeAdvisoryNotes itself returns null (every field unsafe)", async () => {
3609+
// Mirrors the "composeAdvisoryNotes returns null when no assessment or finding is public-safe" unit
3610+
// fixture, but driven end-to-end through runLoopOverAiReview so the `composeAdvisoryNotes(...) ??
3611+
// composeFallbackAdvisoryNotes(fallbackNotes)` line's right-hand branch is actually exercised (the
3612+
// score-terms tests above only ever hit composeAdvisoryNotes' own internal non-null fallback text, never
3613+
// this outer `??`).
3614+
const run = vi.fn(async () => ({
3615+
response: reviewJson({ assessment: "reward payout farming", suggestions: ["payout"], nits: ["reward"], blockers: [] }),
3616+
}));
3617+
const env = createTestEnv({
3618+
AI: { run } as unknown as Ai,
3619+
AI_SUMMARIES_ENABLED: "true",
3620+
AI_PUBLIC_COMMENTS_ENABLED: "true",
3621+
});
3622+
const result = await runLoopOverAiReview(env, baseInput);
3623+
expect(result.status).toBe("ok");
3624+
});
3625+
36083626
it("parseModelReview parses well-formed inline findings, including a trimmed optional suggestion; severity defaults to nit unless exactly 'blocker' (#inline-comments)", () => {
36093627
const json = JSON.stringify({
36103628
assessment: "ok",

0 commit comments

Comments
 (0)