Skip to content

Commit 1024857

Browse files
committed
Use GFM note alert, WCAG 2.2, and core.getBooleanInput
1 parent f898bda commit 1024857

3 files changed

Lines changed: 17 additions & 22 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ export function generateIssueBody(finding: Finding, screenshotRepo: string): str
2020

2121
const categoryNotice =
2222
finding.category && finding.category !== 'wcag'
23-
? `**Note:** This is ${
23+
? `> [!NOTE]\n> This is ${
2424
finding.category === 'experimental' ? 'an experimental check' : 'a best-practice recommendation'
2525
}, not a definite WCAG failure.\n\n`
2626
: ''
2727

2828
const standardsLine =
2929
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.'
30+
? '- [ ] The fix MUST meet the accessibility standards specified by the repository or organization (WCAG 2.2 if applicable).'
31+
: '- [ ] The fix MUST meet WCAG 2.2 guidelines OR the accessibility standards specified by the repository or organization.'
3232

3333
const acceptanceCriteria = `## Acceptance Criteria
3434
- [ ] The specific violation reported in this issue is no longer reproducible.

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

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

19-
// Throws when an input is unset, so this defaults unset
20-
// switches while still rejecting values that aren't a valid boolean.
19+
// core.getBooleanInput throws on unset inputs, so apply the default first.
2120
function getBooleanInputWithDefault(name: string, defaultValue: boolean): boolean {
22-
const raw = core.getInput(name)
23-
if (!raw) return defaultValue
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'.`)
21+
if (!core.getInput(name)) return defaultValue
22+
return core.getBooleanInput(name)
2823
}
2924

3025
export default async function () {

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +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')
29+
expect(body).toContain('The fix MUST meet WCAG 2.2 guidelines OR')
3030
expect(body).not.toContain('Specifically:')
3131
})
3232

@@ -79,29 +79,29 @@ describe('generateIssueBody', () => {
7979
})
8080

8181
it('omits the category notice for WCAG findings', () => {
82-
expect(generateIssueBody(baseFinding, 'github/accessibility-scanner')).not.toContain('**Note:**')
82+
expect(generateIssueBody(baseFinding, 'github/accessibility-scanner')).not.toContain('> [!NOTE]')
8383
expect(generateIssueBody({...baseFinding, category: 'wcag'}, 'github/accessibility-scanner')).not.toContain(
84-
'**Note:**',
84+
'> [!NOTE]',
8585
)
8686
})
8787

8888
it('includes a best-practice notice for best-practice findings', () => {
8989
const body = generateIssueBody({...baseFinding, category: 'best-practice'}, 'github/accessibility-scanner')
9090

91-
expect(body).toContain('**Note:**')
91+
expect(body).toContain('> [!NOTE]')
9292
expect(body).toContain('best-practice recommendation')
93-
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')
93+
expect(body).toContain('not a definite WCAG failure')
94+
expect(body).toContain('WCAG 2.2 if applicable')
95+
expect(body).not.toContain('The fix MUST meet WCAG 2.2 guidelines OR')
9696
})
9797

9898
it('includes an experimental notice for experimental findings', () => {
9999
const body = generateIssueBody({...baseFinding, category: 'experimental'}, 'github/accessibility-scanner')
100100

101-
expect(body).toContain('**Note:**')
101+
expect(body).toContain('> [!NOTE]')
102102
expect(body).toContain('an experimental check')
103-
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')
103+
expect(body).toContain('not a definite WCAG failure')
104+
expect(body).toContain('WCAG 2.2 if applicable')
105+
expect(body).not.toContain('The fix MUST meet WCAG 2.2 guidelines OR')
106106
})
107107
})

0 commit comments

Comments
 (0)