Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(report): add rules descriptions to the report #153

Merged
merged 1 commit into from
Jan 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/ace-core/src/checker/checker-epub.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function asString(arrayOrString) {
return '';
}

function newViolation({ impact = 'serious', title, testDesc, resDesc, kbPath, kbTitle }) {
function newViolation({ impact = 'serious', title, testDesc, resDesc, kbPath, kbTitle, ruleDesc }) {
return new builders.AssertionBuilder()
.withAssertedBy(ASSERTED_BY)
.withMode(MODE)
Expand All @@ -27,7 +27,8 @@ function newViolation({ impact = 'serious', title, testDesc, resDesc, kbPath, kb
.withDescription(testDesc)
.withHelp(
KB_BASE + kbPath,
kbTitle)
kbTitle,
ruleDesc)
.withRulesetTags(['EPUB'])
.build())
.withResult(
Expand All @@ -45,6 +46,7 @@ function newMetadataAssertion(name, impact = 'serious') {
resDesc: `Add a '${name}' metadata property to the Package Document`,
kbPath: 'docs/metadata/schema-org.html',
kbTitle: 'Schema.org Accessibility Metadata',
ruleDesc: `Publications must declare the '${name}' metadata`
});
}

Expand Down Expand Up @@ -72,6 +74,7 @@ function checkTitle(assertions, epub) {
resDesc: 'Add a \'dc:title\' metadata property to the Package Document',
kbPath: '',
kbTitle: 'EPUB Title',
ruleDesc: 'Publications must have a title',
}));
}
}
Expand All @@ -86,6 +89,7 @@ function checkPageSource(assertion, epub) {
resDesc: 'Add a \'dc:source\' metadata property to the Package Document',
kbPath: 'docs/navigation/pagelist.html',
kbTitle: 'Page Navigation',
ruleDesc: 'Publications with page breaks must declare the \'dc:source\' metadata',
}));
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ace-report-axe/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function axe2ace(spineItem, axeResults) {
.withImpact(violation.impact)
.withTitle(violation.id)
.withDescription(violation.description)
.withHelp(kbURL, kbTitle)
.withHelp(kbURL, kbTitle, violation.help)
.withRulesetTags(violation.tags)
.build();
violation.nodes.forEach(node => assertion.withAssertions(
Expand Down
4 changes: 2 additions & 2 deletions packages/ace-report/src/report-builders.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ class TestBuilder {
this._json['dct:description'] = description;
return this;
}
withHelp(url, title) {
this._json.help = { url, title };
withHelp(url, title, description) {
this._json.help = { url, title, description };
return this;
}
withRulesetTags(tags) {
Expand Down
26 changes: 26 additions & 0 deletions tests/__tests__/report_json.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,32 @@ describe('check assertions', () => {
assertions: [],
}));
});
test('with violations', async () => {
const report = await ace(path.join(__dirname, '../data/has-violations'));
expect(report['earl:result']).toBeDefined();
expect(report['earl:result']).toEqual({ 'earl:outcome': 'fail' });
expect(Array.isArray(report.assertions)).toBe(true);
report.assertions.forEach(
(assertion) => {
expect(assertion.assertions).toEqual(expect.arrayContaining([
expect.objectContaining({
'earl:result': expect.objectContaining({
'earl:outcome': 'fail',
}),
'earl:test': expect.objectContaining({
'earl:impact': expect.anything(),
'dct:title': expect.anything(),
'dct:description': expect.anything(),
'help': {
'url': expect.anything(),
'title': expect.anything(),
'description': expect.anything(),
}
})
}),
]));
});
});
});

describe('check properties', () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/data/has-violations/EPUB/package.opf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<meta property="schema:accessibilityHazard">noSoundHazard</meta>
<meta property="schema:accessibilityHazard">noMotionSimulationHazard</meta>
<meta property="schema:accessMode">textual</meta>
<meta property="schema:accessModeSufficient">textual</meta>
<!-- <meta property="schema:accessModeSufficient">textual</meta> -->
</metadata>
<manifest>
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
Expand Down