| | @@ -205,6 +205,19 @@ |
| 205 | 205 | expect(srv.requests.length).toBe(before); |
| 206 | 206 | }); |
| 207 | 207 | |
| 208 | + it("pr view shows auto-merge and, for an agent, what is left before it lands", async () => { |
| 209 | + const detail = { mergeable: false, mergeable_state: "blocked", merge_blockers: ["needs 1 more approving review(s)", "required check 'ci' is in_progress"], approvals: 0, required_approvals: 1, checks: [] }; |
| 210 | + srv.on("GET", "/api/v3/repos/o/r/pulls/3", { body: { ...pull(3), ...detail, auto_merge: { merge_method: "squash" }, auto_merge_blockers: ["required check 'ci' is in_progress"] } }); |
| 211 | + srv.on("GET", "/api/v3/repos/o/r/pulls/4", { body: { ...pull(4), ...detail, auto_merge: { merge_method: "merge" }, auto_merge_blockers: [] } }); |
| 212 | + srv.on("GET", "/api/v3/repos/o/r/pulls/5", { body: { ...pull(5), ...detail, auto_merge: { merge_method: "rebase" } } }); |
| 213 | + srv.on("GET", "/api/v3/repos/o/r/pulls/6", { body: { ...pull(6), ...detail, auto_merge: null } }); |
| 214 | + const agent = (await run(["pr", "view", "3", "-R", "o/r"], { env })).stdout; |
| 215 | + expect(agent).toContain("auto-merge: on (squash), it merges by itself once these are done:\n • required check 'ci' is in_progress\n"); |
| 216 | + expect((await run(["pr", "view", "4", "-R", "o/r"], { env })).stdout).toContain("auto-merge: on (merge), nothing is left, it merges now"); |
| 217 | + expect((await run(["pr", "view", "5", "-R", "o/r"], { env })).stdout).toContain("auto-merge: on (rebase), it merges by itself once every requirement is met"); |
| 218 | + expect((await run(["pr", "view", "6", "-R", "o/r"], { env })).stdout).not.toContain("auto-merge"); |
| 219 | + }); |
| 220 | + |
| 208 | 221 | it("without a number, fails clearly when there is no current branch or no open pull request for it", async () => { |
| 209 | 222 | srv.on("GET", "/api/v3/repos/acme/widgets/pulls", { body: [] }); |
| 210 | 223 | const cwd = gitRepo(env, `${srv.url}/acme/widgets.git`, "lonely"); |