kopia lustrzana https://github.com/wagtail/wagtail
Log accessibility checker results when present
rodzic
a684273227
commit
aa070ef08e
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue