|
| 1 | +import { describe, it, expect } from "vitest"; |
| 2 | +import { generateIssueBody } from "../.github/actions/file/src/generateIssueBody.ts"; |
| 3 | + |
| 4 | +const baseFinding = { |
| 5 | + scannerType: "axe", |
| 6 | + ruleId: "color-contrast", |
| 7 | + url: "https://example.com/page", |
| 8 | + html: "<span>Low contrast</span>", |
| 9 | + problemShort: "elements must meet minimum color contrast ratio thresholds", |
| 10 | + problemUrl: "https://dequeuniversity.com/rules/axe/4.10/color-contrast?application=playwright", |
| 11 | + solutionShort: "ensure the contrast between foreground and background colors meets WCAG thresholds", |
| 12 | +}; |
| 13 | + |
| 14 | +describe("generateIssueBody", () => { |
| 15 | + it("includes acceptance criteria and omits the Specifically section when solutionLong is missing", () => { |
| 16 | + const body = generateIssueBody(baseFinding, "github/accessibility-scanner"); |
| 17 | + |
| 18 | + expect(body).toContain("## What"); |
| 19 | + expect(body).toContain("## Acceptance Criteria"); |
| 20 | + expect(body).toContain("The specific axe violation reported in this issue is no longer reproducible."); |
| 21 | + expect(body).not.toContain("Specifically:"); |
| 22 | + }); |
| 23 | + |
| 24 | + it("formats solutionLong lines into bullets while preserving Fix any/Fix all lines", () => { |
| 25 | + const body = generateIssueBody( |
| 26 | + { |
| 27 | + ...baseFinding, |
| 28 | + solutionLong: [ |
| 29 | + "Use a darker foreground color.", |
| 30 | + "Fix any of the following:", |
| 31 | + "Increase font weight.", |
| 32 | + "Fix all of the following:", |
| 33 | + "Add a non-color visual indicator.", |
| 34 | + "", |
| 35 | + ].join("\n"), |
| 36 | + }, |
| 37 | + "github/accessibility-scanner", |
| 38 | + ); |
| 39 | + |
| 40 | + expect(body).toContain("Specifically:"); |
| 41 | + expect(body).toContain("- Use a darker foreground color."); |
| 42 | + expect(body).toContain("Fix any of the following:"); |
| 43 | + expect(body).toContain("- Increase font weight."); |
| 44 | + expect(body).toContain("Fix all of the following:"); |
| 45 | + expect(body).toContain("- Add a non-color visual indicator."); |
| 46 | + |
| 47 | + expect(body).not.toContain("- Fix any of the following:"); |
| 48 | + expect(body).not.toContain("- Fix all of the following:"); |
| 49 | + }); |
| 50 | +}); |
0 commit comments