|
| 1 | +import { describe, expect, test } from "bun:test"; |
| 2 | + |
| 3 | +type Workflow = { |
| 4 | + on?: { |
| 5 | + issue_comment?: { types?: string[] }; |
| 6 | + }; |
| 7 | + jobs?: Record< |
| 8 | + string, |
| 9 | + { |
| 10 | + if?: string; |
| 11 | + steps?: Array<{ |
| 12 | + name?: string; |
| 13 | + with?: Record<string, string>; |
| 14 | + }>; |
| 15 | + } |
| 16 | + >; |
| 17 | +}; |
| 18 | + |
| 19 | +describe("CodeRabbit readiness revalidation", () => { |
| 20 | + test("CodeRabbit PR status comments can rerun the findings gate", async () => { |
| 21 | + const text = await Bun.file( |
| 22 | + new URL("../.github/workflows/enforce-pr-target.yml", import.meta.url), |
| 23 | + ).text(); |
| 24 | + const workflow = Bun.YAML.parse(text) as Workflow; |
| 25 | + |
| 26 | + expect(workflow.on?.issue_comment?.types).toEqual(["created", "edited"]); |
| 27 | + |
| 28 | + const job = workflow.jobs?.["enforce-target"]; |
| 29 | + expect(job).toBeDefined(); |
| 30 | + expect(job?.if).toContain("github.event.issue.pull_request != null"); |
| 31 | + expect(job?.if).toContain("github.event.comment.user.login == 'coderabbitai[bot]'"); |
| 32 | + |
| 33 | + const gateStep = job?.steps?.find( |
| 34 | + step => step.name === "Enforce PR target, ancestry, and description", |
| 35 | + ); |
| 36 | + const script = gateStep?.with?.script ?? ""; |
| 37 | + |
| 38 | + expect(script).toContain('const CODE_RABBIT_LOGIN = "coderabbitai[bot]"'); |
| 39 | + expect(script).toContain("const isCodeRabbit = commenter === CODE_RABBIT_LOGIN"); |
| 40 | + expect(script).toContain("!isCodeRabbit"); |
| 41 | + expect(script).toContain("isCanonicalMaintainer"); |
| 42 | + expect(script).toContain("unresolvedFindingsClaim"); |
| 43 | + }); |
| 44 | +}); |
0 commit comments