Skip to content

Commit a95cc31

Browse files
committed
Address Copilot feedback on input validation and acceptance criteria
1 parent eedc772 commit a95cc31

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,14 @@ export function generateIssueBody(finding: Finding, screenshotRepo: string): str
2525
}, not a hard WCAG failure.\n\n`
2626
: ''
2727

28+
const standardsLine =
29+
finding.category && finding.category !== 'wcag'
30+
? '- [ ] The fix MUST meet the accessibility standards specified by the repository or organization (WCAG 2.1 if applicable).'
31+
: '- [ ] The fix MUST meet WCAG 2.1 guidelines OR the accessibility standards specified by the repository or organization.'
32+
2833
const acceptanceCriteria = `## Acceptance Criteria
2934
- [ ] The specific violation reported in this issue is no longer reproducible.
30-
- [ ] The fix MUST meet WCAG 2.1 guidelines OR the accessibility standards specified by the repository or organization.
35+
${standardsLine}
3136
- [ ] A test SHOULD be added to ensure this specific violation does not regress.
3237
- [ ] This PR MUST NOT introduce any new accessibility issues or regressions.`
3338

.github/actions/file/src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ import {updateFilingsWithNewFindings} from './updateFilingsWithNewFindings.js'
1616
import {OctokitResponse} from '@octokit/types'
1717
const OctokitWithThrottling = Octokit.plugin(throttling)
1818

19-
// core.getBooleanInput throws when an input is missing, so default unset switches.
19+
// core.getBooleanInput throws when an input is unset, so this defaults unset
20+
// switches while still rejecting values that aren't a valid boolean.
2021
function getBooleanInputWithDefault(name: string, defaultValue: boolean): boolean {
2122
const raw = core.getInput(name)
2223
if (!raw) return defaultValue
23-
return raw.toLowerCase() === 'true'
24+
const normalized = raw.trim().toLowerCase()
25+
if (normalized === 'true') return true
26+
if (normalized === 'false') return false
27+
throw new TypeError(`Invalid boolean input '${name}': '${raw}'. Expected 'true' or 'false'.`)
2428
}
2529

2630
export default async function () {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ describe('generateIssueBody', () => {
2626
expect(body).toContain('## What')
2727
expect(body).toContain('## Acceptance Criteria')
2828
expect(body).toContain('The specific violation reported in this issue is no longer reproducible.')
29+
expect(body).toContain('The fix MUST meet WCAG 2.1 guidelines OR')
2930
expect(body).not.toContain('Specifically:')
3031
})
3132

@@ -90,6 +91,8 @@ describe('generateIssueBody', () => {
9091
expect(body).toContain('**Note:**')
9192
expect(body).toContain('best-practice recommendation')
9293
expect(body).toContain('not a hard WCAG failure')
94+
expect(body).toContain('WCAG 2.1 if applicable')
95+
expect(body).not.toContain('The fix MUST meet WCAG 2.1 guidelines OR')
9396
})
9497

9598
it('includes an experimental notice for experimental findings', () => {
@@ -98,5 +101,7 @@ describe('generateIssueBody', () => {
98101
expect(body).toContain('**Note:**')
99102
expect(body).toContain('an experimental check')
100103
expect(body).toContain('not a hard WCAG failure')
104+
expect(body).toContain('WCAG 2.1 if applicable')
105+
expect(body).not.toContain('The fix MUST meet WCAG 2.1 guidelines OR')
101106
})
102107
})

0 commit comments

Comments
 (0)