Skip to content

Commit 7a0716b

Browse files
committed
Surface finding category in issue body and label
1 parent d830830 commit 7a0716b

5 files changed

Lines changed: 60 additions & 1 deletion

File tree

.github/actions/file/src/generateIssueBody.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,20 @@ export function generateIssueBody(finding: Finding, screenshotRepo: string): str
1818
`
1919
}
2020

21+
const categoryNotice =
22+
finding.category && finding.category !== 'wcag'
23+
? `**Note:** This is ${
24+
finding.category === 'experimental' ? 'an experimental check' : 'a best-practice recommendation'
25+
}, not a hard WCAG failure.\n\n`
26+
: ''
27+
2128
const acceptanceCriteria = `## Acceptance Criteria
2229
- [ ] The specific violation reported in this issue is no longer reproducible.
2330
- [ ] The fix MUST meet WCAG 2.1 guidelines OR the accessibility standards specified by the repository or organization.
2431
- [ ] A test SHOULD be added to ensure this specific violation does not regress.
2532
- [ ] This PR MUST NOT introduce any new accessibility issues or regressions.`
2633

27-
const body = `## What
34+
const body = `${categoryNotice}## What
2835
An accessibility scan ${finding.html ? `flagged the element \`${finding.html}\`` : `found an issue on ${finding.url}`} because ${finding.problemShort}. Learn more about why this was flagged by visiting ${finding.problemUrl}.
2936
3037
${screenshotSection ?? ''}

.github/actions/file/src/openIssue.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export async function openIssue(octokit: Octokit, repoWithOwner: string, finding
2626
if (finding.ruleId) {
2727
labels.push(`${finding.scannerType} rule: ${finding.ruleId}`)
2828
}
29+
// Flag non-WCAG findings so they can be filtered or triaged separately
30+
if (finding.category && finding.category !== 'wcag') {
31+
labels.push(finding.category)
32+
}
2933

3034
const title = truncateWithEllipsis(
3135
`Accessibility issue: ${finding.problemShort[0].toUpperCase() + finding.problemShort.slice(1)} on ${new URL(finding.url).pathname}`,

.github/actions/file/src/types.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
export type FindingCategory = 'wcag' | 'best-practice' | 'experimental'
2+
13
export type Finding = {
24
scannerType: string
5+
category?: FindingCategory
36
ruleId?: string
47
url: string
58
html?: string

.github/actions/file/tests/generateIssueBody.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,27 @@ describe('generateIssueBody', () => {
7676
expect(body).toContain(`found an issue on ${findingWithEmptyOptionalFields.url}`)
7777
expect(body).not.toContain('flagged the element')
7878
})
79+
80+
it('omits the category notice for WCAG findings', () => {
81+
expect(generateIssueBody(baseFinding, 'github/accessibility-scanner')).not.toContain('**Note:**')
82+
expect(generateIssueBody({...baseFinding, category: 'wcag'}, 'github/accessibility-scanner')).not.toContain(
83+
'**Note:**',
84+
)
85+
})
86+
87+
it('includes a best-practice notice for best-practice findings', () => {
88+
const body = generateIssueBody({...baseFinding, category: 'best-practice'}, 'github/accessibility-scanner')
89+
90+
expect(body).toContain('**Note:**')
91+
expect(body).toContain('best-practice recommendation')
92+
expect(body).toContain('not a hard WCAG failure')
93+
})
94+
95+
it('includes an experimental notice for experimental findings', () => {
96+
const body = generateIssueBody({...baseFinding, category: 'experimental'}, 'github/accessibility-scanner')
97+
98+
expect(body).toContain('**Note:**')
99+
expect(body).toContain('an experimental check')
100+
expect(body).toContain('not a hard WCAG failure')
101+
})
79102
})

.github/actions/file/tests/openIssue.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,28 @@ describe('openIssue', () => {
6565
)
6666
})
6767

68+
it('adds a category label for non-WCAG findings', async () => {
69+
const octokit = mockOctokit()
70+
await openIssue(octokit, 'org/repo', {...baseFinding, category: 'best-practice'})
71+
72+
expect(octokit.request).toHaveBeenCalledWith(
73+
expect.any(String),
74+
expect.objectContaining({
75+
labels: ['axe-scanning-issue', 'axe rule: color-contrast', 'best-practice'],
76+
}),
77+
)
78+
})
79+
80+
it('does not add a category label for WCAG findings', async () => {
81+
const octokit = mockOctokit()
82+
await openIssue(octokit, 'org/repo', {...baseFinding, category: 'wcag'})
83+
84+
const labels = octokit.request.mock.calls[0][1].labels
85+
expect(labels).not.toContain('wcag')
86+
expect(labels).not.toContain('best-practice')
87+
expect(labels).not.toContain('experimental')
88+
})
89+
6890
it('truncates long titles with ellipsis', async () => {
6991
const octokit = mockOctokit()
7092
const longFinding = {

0 commit comments

Comments
 (0)