Skip to content

Commit 48eb24c

Browse files
committed
test(review): cover extractReviewSummary suggestions-merge + sole-reviewer consensus (#6634)
extractReviewSummary folds each reviewer's free-form `suggestions` into the rendered `nits` (unified-comment.ts:136) and treats a sole reviewer's blocker as a consensus blocker (unified-comment.ts:140) — both already-shipped branches were unexercised: the shared test helper only ever passed the default `suggestions: []`, and the closest single-reviewer-blocker case never asserted `.consensusBlocker`. Adds three cases through the sole entry point `buildUnifiedReviewInput`: - a non-empty `suggestions` array surfaces in `nits`, deduped case-insensitively against explicit nits - a sole reviewer's blocker → `consensusBlocker: true` (and derived status `blocked`) - a sole reviewer with no blocker → `consensusBlocker: false` No production code change — this closes a coverage gap on documented behavior. Closes #6634
1 parent 2ef93c0 commit 48eb24c

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

test/unit/unified-comment.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,38 @@ describe("buildUnifiedReviewInput", () => {
727727
expect(deriveUnifiedStatus(input)).toBe("held");
728728
});
729729

730+
it("a SOLE reviewer's blocker still counts as a consensus blocker (#6634)", () => {
731+
// The one-reviewer case exercises the `valid.length === 1 && reviewersWithBlockers === 1` arm of
732+
// consensusBlocker — a lone blocker in a DUAL review is a split (above), but the sole reviewer IS the
733+
// consensus, so its blocker hard-blocks.
734+
const input = buildUnifiedReviewInput({ changedFiles: 1, reviews: [reviewNote("request_changes", { blockers: ["Real defect"] })] });
735+
expect(input.consensusBlocker).toBe(true);
736+
expect(deriveUnifiedStatus(input)).toBe("blocked");
737+
});
738+
739+
it("a sole reviewer with no blocker is not a consensus blocker (#6634)", () => {
740+
const input = buildUnifiedReviewInput({ changedFiles: 1, reviews: [reviewNote("merge")] });
741+
expect(input.consensusBlocker).toBe(false);
742+
});
743+
744+
it("merges a reviewer's free-form suggestions into the rendered nits, deduped alongside explicit nits (#6634)", () => {
745+
// extractReviewSummary folds each reviewer's non-blocking `suggestions` into `nits` (both are non-blocking).
746+
// The shared helper defaults `suggestions: []`, so this is the first case to push a non-empty array through.
747+
const input = buildUnifiedReviewInput({
748+
changedFiles: 1,
749+
reviews: [
750+
reviewNote("merge", { nits: ["Document the new property."], suggestions: ["Consider extracting a helper.", "document the new property."] }),
751+
reviewNote("merge", { suggestions: ["Add a changeset entry."] }),
752+
],
753+
});
754+
// The free-form suggestions surface in nits...
755+
const nits = input.nits ?? [];
756+
expect(nits).toContain("Consider extracting a helper.");
757+
expect(nits).toContain("Add a changeset entry.");
758+
// ...alongside the explicit nit, and the case-insensitive duplicate of it is deduped away (only one survives).
759+
expect(nits.filter((n) => n.toLowerCase() === "document the new property.")).toEqual(["Document the new property."]);
760+
});
761+
730762
it("counts reviewers that produced no verdict (partial review)", () => {
731763
const input = buildUnifiedReviewInput({ changedFiles: 1, reviews: [reviewNote("merge"), { model: "m2", notes: null }] });
732764
expect(input.failedCount).toBe(1);

0 commit comments

Comments
 (0)