diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 6d0ffa6462..c905f0bede 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -36,6 +36,7 @@ Changelog * Allow changing available privacy options per page model (Shlomo Markowitz) * Add concurrent editing notifications for pages and snippets (Matt Westcott, Sage Abdullah) * Add "soft" client-side validation for `StreamBlock` / `ListBlock` `min_num` / `max_num` (Matt Westcott) + * Log accessibility checker results in the console to help developers with troubleshooting (Thibaud Colas) * Fix: Make `WAGTAILIMAGES_CHOOSER_PAGE_SIZE` setting functional again (Rohit Sharma) * Fix: Enable `richtext` template tag to convert lazy translation values (Benjamin Bach) * Fix: Ensure permission labels on group permissions page are translated where available (Matt Westcott) diff --git a/client/src/includes/a11y-result.test.ts b/client/src/includes/a11y-result.test.ts index fb184d4ceb..c81582c0a1 100644 --- a/client/src/includes/a11y-result.test.ts +++ b/client/src/includes/a11y-result.test.ts @@ -124,9 +124,17 @@ jest.mock('axe-core', () => ({ })); describe('getA11yReport', () => { + let consoleError: jest.SpyInstance; + beforeEach(() => { + consoleError = jest.spyOn(console, 'error').mockImplementation(() => {}); jest.clearAllMocks(); }); + + afterEach(() => { + consoleError.mockRestore(); + }); + it('should configure Axe with custom rules and return the accessibility report', async () => { const mockResults = { violations: [ @@ -146,6 +154,10 @@ describe('getA11yReport', () => { }; const report = await getA11yReport(config); expect(axe.configure).toHaveBeenCalled(); + expect(consoleError).toHaveBeenCalledWith( + 'axe.run results', + mockResults.violations, + ); expect(axe.run).toHaveBeenCalledWith(config.context, config.options); expect(report.results).toEqual(mockResults); expect(report.a11yErrorsNumber).toBe(3); @@ -166,5 +178,6 @@ describe('getA11yReport', () => { }; const report = await getA11yReport(config); expect(report.a11yErrorsNumber).toBe(0); + expect(consoleError).not.toHaveBeenCalled(); }); }); diff --git a/client/src/includes/a11y-result.ts b/client/src/includes/a11y-result.ts index 05a90568e5..ed190a7001 100644 --- a/client/src/includes/a11y-result.ts +++ b/client/src/includes/a11y-result.ts @@ -142,6 +142,13 @@ export const getA11yReport = async ( (sum, violation) => sum + violation.nodes.length, 0, ); + + if (a11yErrorsNumber > 0) { + // Help developers potentially troubleshooting userbar check results. + // eslint-disable-next-line no-console + console.error('axe.run results', results.violations); + } + return { results, a11yErrorsNumber, diff --git a/docs/releases/6.2.md b/docs/releases/6.2.md index c0a92ab387..3c9e92aa28 100644 --- a/docs/releases/6.2.md +++ b/docs/releases/6.2.md @@ -59,6 +59,7 @@ StreamField definitions within migrations are now represented in a more compact * Support customizations to `UserViewSet` via the app config (Sage Abdullah) * Allow changing available privacy options per page model (Shlomo Markowitz) * Add "soft" client-side validation for `StreamBlock` / `ListBlock` `min_num` / `max_num` (Matt Westcott) + * Log accessibility checker results in the console to help developers with troubleshooting (Thibaud Colas) ### Bug fixes