Skip to content

Commit 631eecc

Browse files
test: cover pr-outcomes CLI edge branches and fix draft-pr-body fixture
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 2d62b06 commit 631eecc

3 files changed

Lines changed: 43 additions & 1 deletion

File tree

test/unit/mcp-cli-draft-pr-body.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ describe("loopover_draft_pr_body stdio mirror (#6741)", () => {
142142
const data = structured(result);
143143
expect(data).toMatchObject({
144144
title: "Local branch preflight",
145-
repoFullName: "JSONbored/gittensory",
145+
repoFullName: "JSONbored/loopover",
146146
sourceUploadDisabled: true,
147147
});
148148
expect(typeof data.markdown).toBe("string");

test/unit/mcp-cli-pr-outcomes.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,26 @@ describe("loopover-mcp pr-outcomes CLI (#6747)", () => {
124124
});
125125
expect(badLimit.status).toBe(1);
126126
expect(`${badLimit.stdout}${badLimit.stderr}`).toMatch(/integer between 1 and 100/);
127+
128+
const bareLimit = runExpectingFailure(["pr-outcomes", "--login", "JSONbored", "--limit", "101"], {
129+
LOOPOVER_API_URL: apiUrl,
130+
LOOPOVER_TOKEN: "session-token",
131+
});
132+
expect(bareLimit.status).toBe(1);
133+
});
134+
135+
it("falls back when the API omits summary and prints null pull numbers / empty attributions", async () => {
136+
await closeFixtureServer();
137+
const sparseUrl = await startFixtureServer({
138+
prOutcomes: {
139+
summary: " ",
140+
outcomes: [{ repoFullName: "a/b", pullNumber: null, outcome: "merged", attribution: "", deeplink: "https://x", recordedAt: "t" }],
141+
},
142+
});
143+
const env = { LOOPOVER_API_URL: sparseUrl, LOOPOVER_TOKEN: "session-token" };
144+
const plain = await runAsync(["pr-outcomes", "--login", "JSONbored"], env);
145+
expect(plain).toContain("LoopOver post-merge outcomes for JSONbored.");
146+
expect(plain).toContain("a/b#? [merged]");
127147
});
128148

129149
it("strips ANSI escapes from API-chosen text on the plain-text path but not from --json", async () => {
@@ -142,6 +162,15 @@ describe("loopover-mcp pr-outcomes CLI (#6747)", () => {
142162
expect(JSON.parse(asJson).summary).toBe("\u001b[31mFAKE PASS\u001b[0m");
143163
});
144164

165+
it("ignores a bare --limit flag (no value) and still returns outcomes", async () => {
166+
const out = await runAsync(["pr-outcomes", "--login", "JSONbored", "--limit", "--json"], {
167+
LOOPOVER_API_URL: apiUrl,
168+
LOOPOVER_TOKEN: "session-token",
169+
});
170+
expect(JSON.parse(out)).toEqual(prOutcomesFixture());
171+
expect(capturedRequests.at(-1)?.url).not.toContain("limit=");
172+
});
173+
145174
it("documents itself in --help and in the shell-completion command list", () => {
146175
expect(run(["--help"])).toContain("loopover-mcp pr-outcomes --login <github-login> [--limit N] [--json]");
147176
expect(run(["pr-outcomes", "--help"])).toContain("Mirrors the loopover_pr_outcome MCP tool");

test/unit/routes-pr-outcomes.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,19 @@ describe("GET /v1/contributors/:login/pr-outcomes (#6747)", () => {
6464
expect(notInt.status).toBe(400);
6565
});
6666

67+
it("returns an empty outcomes list when the contributor has no merged-PR deliveries", async () => {
68+
const app = createApp();
69+
const env = createTestEnv();
70+
const response = await app.request("/v1/contributors/miner/pr-outcomes", { headers: apiHeaders(env) }, env);
71+
expect(response.status).toBe(200);
72+
await expect(response.json()).resolves.toEqual({
73+
login: "miner",
74+
count: 0,
75+
summary: "LoopOver post-merge outcomes for miner: 0 merged PR(s).",
76+
outcomes: [],
77+
});
78+
});
79+
6780
it("rejects unauthenticated callers", async () => {
6881
const app = createApp();
6982
const env = createTestEnv();

0 commit comments

Comments
 (0)