Skip to content

Commit

Permalink
fix(rules): add help title and description to `epub-type-has-matching…
Browse files Browse the repository at this point in the history
…-role`

Also sorts the rule/KB map alphabetically.

Fixes #156
  • Loading branch information
rdeltour committed Jan 21, 2018
1 parent 601d915 commit a2506e4
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 41 deletions.
1 change: 1 addition & 0 deletions packages/ace-core/src/scripts/ace-axe.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ daisy.ace.run = function(done) {
selector: '[*|type]',
any: ['matching-aria-role'],
metadata: {
help: "ARIA role should be used in addition to epub:type",
description: "Ensure the element has an ARIA role matching its epub:type",
},
tags: ['best-practice']
Expand Down
75 changes: 38 additions & 37 deletions packages/ace-report-axe/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,57 +9,58 @@ const winston = require('winston');
const kbMap = {
'baseUrl': 'http://kb.daisy.org/publishing/',
'map': {
'pagebreak-label': {url: 'docs/navigation/pagelist.html', 'title': 'Page Breaks'},
'html-has-lang': {url: 'docs/html/lang.html', title: 'Language'},
'html-lang-valid': {url: 'docs/html/lang.html', title: 'Language'},
'valid-lang': {url: 'docs/html/lang.html', title: 'Language'},
'accesskeys': {url: 'docs/html/accesskeys.html', title: 'Access Keys'},
'area-alt': {url: 'docs/html/maps.html', title: 'Image Maps'},
'server-side-image-map': {url: 'docs/html/maps.html', title: 'Image Maps'},
'list': {url: 'docs/html/lists.html', title: 'Lists'},
'listitem': {url: 'docs/html/lists.html', title: 'Lists'},
'definition-list': {url: 'docs/html/lists.html', title: 'Lists'},
'dlitem': {url: 'docs/html/lists.html', title: 'Lists'},
'video-caption': {url: 'docs/html/video.html', title: 'Video'},
'video-description': {url: 'docs/html/video.html', title: 'Video'},
'table-duplicate-name': {url: 'docs/html/tables.html', title: 'Tables'},
'table-fake-caption': {url: 'docs/html/tables.html', title: 'Tables'},
'td-has-header': {url: 'docs/html/tables.html', title: 'Tables'},
'td-headers-attr': {url: 'docs/html/tables.html', title: 'Tables'},
'th-has-data-cells': {url: 'docs/html/tables.html', title: 'Tables'},
'layout-table': {url: 'docs/html/tables.html', title: 'Tables'},
'scope-attr-valid': {url: 'docs/html/tables.html', title: 'Tables'},
'image-alt': {url: 'docs/html/images.html', title: 'Images'},
'image-redundant-alt': {url: 'docs/html/images.html', title: 'Images'},
'input-image-alt': {url: 'docs/html/images.html', title: 'Images'},
'frame-title-unique': {url: 'docs/html/iframes.html', title: 'Inline Frames'},
'frame-title': {url: 'docs/html/iframes.html', title: 'Inline Frames'},
'meta-refresh': {url: 'docs/html/meta.html', title: 'Meta'},
'meta-viewport-large': {url: 'docs/html/meta.html', title: 'Meta'},
'meta-viewport': {url: 'docs/html/meta.html', title: 'Meta'},
'aria-allowed-attr': {url: 'docs/script/aria.html', title: 'ARIA'},
'aria-hidden-body': {url: 'docs/script/aria.html', title: 'ARIA'},
'aria-required-attr': {url: 'docs/script/aria.html', title: 'ARIA'},
'aria-required-children': {url: 'docs/script/aria.html', title: 'ARIA'},
'aria-required-parent': {url: 'docs/script/aria.html', title: 'ARIA'},
'aria-roles': {url: 'docs/script/aria.html', title: 'ARIA'},
'aria-valid-attr-value': {url: 'docs/script/aria.html', title: 'ARIA'},
'aria-valid-attr': {url: 'docs/script/aria.html', title: 'ARIA'},
'aria-hidden-body': {url: 'docs/script/aria.html', title: 'ARIA'},
'empty-heading': {url: 'docs/html/headings.html', title: 'Headings'},
'heading-order': {url: 'docs/html/headings.html', title: 'Headings'},
'p-as-heading': {url: 'docs/html/headings.html', title: 'Headings'},
'button-name': {url: 'docs/html/forms.html', title: 'Forms'},
'checkboxgroup': {url: 'docs/html/forms.html', title: 'Forms'},
'color-contrast': {url: 'docs/css/color.html', title: 'Color'},
'definition-list': {url: 'docs/html/lists.html', title: 'Lists'},
'dlitem': {url: 'docs/html/lists.html', title: 'Lists'},
'document-title': {url: 'docs/html/title.html', title: 'Page Title'},
'duplicate-id': {url: 'docs/html/ids.html', title: 'Identifiers'},
'radiogroup': {url: 'docs/html/forms.html', title: 'Forms'},
'checkboxgroup': {url: 'docs/html/forms.html', title: 'Forms'},
'empty-heading': {url: 'docs/html/headings.html', title: 'Headings'},
'epub-type-has-matching-role': {url: 'docs/html/roles.html', title: 'ARIA role'},
'frame-title-unique': {url: 'docs/html/iframes.html', title: 'Inline Frames'},
'frame-title': {url: 'docs/html/iframes.html', title: 'Inline Frames'},
'heading-order': {url: 'docs/html/headings.html', title: 'Headings'},
'href-no-hash': {url: 'docs/html/links.html', title: 'Links'},
'html-has-lang': {url: 'docs/html/lang.html', title: 'Language'},
'html-lang-valid': {url: 'docs/html/lang.html', title: 'Language'},
'image-alt': {url: 'docs/html/images.html', title: 'Images'},
'image-redundant-alt': {url: 'docs/html/images.html', title: 'Images'},
'input-image-alt': {url: 'docs/html/images.html', title: 'Images'},
'label-title-only': {url: 'docs/html/forms.html', title: 'Forms'},
'label': {url: 'docs/html/forms.html', title: 'Forms'},
'button-name': {url: 'docs/html/forms.html', title: 'Forms'},
'accesskeys': {url: 'docs/html/accesskeys.html', title: 'Access Keys'},
'color-contrast': {url: 'docs/css/color.html', title: 'Color'},
'layout-table': {url: 'docs/html/tables.html', title: 'Tables'},
'link-in-text-block': {url: 'docs/html/links.html', title: 'Links'},
'link-name': {url: 'docs/html/links.html', title: 'Links'},
'href-no-hash': {url: 'docs/html/links.html', title: 'Links'},
'object-alt': {url: 'docs/html/object.html', title: 'Object'}
'list': {url: 'docs/html/lists.html', title: 'Lists'},
'listitem': {url: 'docs/html/lists.html', title: 'Lists'},
'meta-refresh': {url: 'docs/html/meta.html', title: 'Meta'},
'meta-viewport-large': {url: 'docs/html/meta.html', title: 'Meta'},
'meta-viewport': {url: 'docs/html/meta.html', title: 'Meta'},
'object-alt': {url: 'docs/html/object.html', title: 'Object'},
'p-as-heading': {url: 'docs/html/headings.html', title: 'Headings'},
'pagebreak-label': {url: 'docs/navigation/pagelist.html', 'title': 'Page Breaks'},
'radiogroup': {url: 'docs/html/forms.html', title: 'Forms'},
'scope-attr-valid': {url: 'docs/html/tables.html', title: 'Tables'},
'server-side-image-map': {url: 'docs/html/maps.html', title: 'Image Maps'},
'table-duplicate-name': {url: 'docs/html/tables.html', title: 'Tables'},
'table-fake-caption': {url: 'docs/html/tables.html', title: 'Tables'},
'td-has-header': {url: 'docs/html/tables.html', title: 'Tables'},
'td-headers-attr': {url: 'docs/html/tables.html', title: 'Tables'},
'th-has-data-cells': {url: 'docs/html/tables.html', title: 'Tables'},
'valid-lang': {url: 'docs/html/lang.html', title: 'Language'},
'video-caption': {url: 'docs/html/video.html', title: 'Video'},
'video-description': {url: 'docs/html/video.html', title: 'Video'},
}
};

Expand Down
12 changes: 8 additions & 4 deletions tests/__tests__/axe-rules.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,14 @@ test('Checks that `epub:type` have matching ARIA roles', async() => {
expect(assertions).toBeDefined();
expect(assertions).toEqual(expect.arrayContaining([
expect.objectContaining({
'earl:test': expect.objectContaining({ 'dct:title': 'epub-type-has-matching-role' }),
'earl:result': expect.objectContaining({
'earl:outcome': 'fail',
'earl:pointer': expect.objectContaining({ css: ['#fail1'] }),
'earl:test': expect.objectContaining({
'dct:title': 'epub-type-has-matching-role',
'dct:description': 'Ensure the element has an ARIA role matching its epub:type',
'help': {
'url': 'http://kb.daisy.org/publishing/docs/html/roles.html',
'title': 'ARIA role',
'description': 'ARIA role should be used in addition to epub:type'
}
}),
}),
expect.objectContaining({
Expand Down

0 comments on commit a2506e4

Please sign in to comment.