Skip to content

Commit

Permalink
Merge pull request #13 from lpelypenko/addTags
Browse files Browse the repository at this point in the history
Added all WCAG tags to WCAG column and added all raw tags in description
  • Loading branch information
lpelypenko authored Jan 3, 2021
2 parents 50e4ca2 + 8c82d08 commit 3b93c5d
Show file tree
Hide file tree
Showing 22 changed files with 4,385 additions and 872 deletions.
205 changes: 182 additions & 23 deletions artifacts/accessibilityReport.html

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion artifacts/tcAllPassedOnlyViolations.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ <h3>
AXE Accessibility Results
</h3>
<div class="summarySection">

</div>
<h5>axe-core found <span class="badge badge-success">0</span> violations</h5>
<tbody>
Expand Down
317 changes: 238 additions & 79 deletions artifacts/tcInapplicablePresent.html

Large diffs are not rendered by default.

204 changes: 182 additions & 22 deletions artifacts/tcIncludingCustomSummary.html

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion artifacts/tcOnlyPasses.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ <h3>
<a href="https:&#x2F;&#x2F;dequeuniversity.com&#x2F;demo&#x2F;mars&#x2F;" target="_blank" class="card-link">https:&#x2F;&#x2F;dequeuniversity.com&#x2F;demo&#x2F;mars&#x2F;</a>
<br />
</div>

</div>
<h5>axe-core found <span class="badge badge-success">0</span> violations</h5>
<tbody>
Expand Down
263 changes: 211 additions & 52 deletions artifacts/tcPassesAndViolations.html

Large diffs are not rendered by default.

65 changes: 32 additions & 33 deletions artifacts/tcWithTheKey.html

Large diffs are not rendered by default.

310 changes: 235 additions & 75 deletions artifacts/tsAllOptionalParametersPresent.html

Large diffs are not rendered by default.

205 changes: 182 additions & 23 deletions artifacts/urlIsNotPassed.html

Large diffs are not rendered by default.

154 changes: 94 additions & 60 deletions docs/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "axe-html-reporter",
"version": "2.1.0",
"version": "2.1.1",
"description": "The module that allows you to create HTML Report from raw accessibility aXe result object",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions src/util/AxeReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface NodeResult {

interface Details {
wcag: string;
tags: string[];
id: string;
impact: string;
description: string;
Expand Down
36 changes: 23 additions & 13 deletions src/util/getWcagReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,30 @@
* @returns {string}
*/
export function getWcagReference(tags: string[]): string {
const tagsNames = ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'best-practice'];
const foundTags = tags.filter((tag) => tagsNames.includes(tag));

const tagNamesToAccessibilityStandard: Record<string, string> = {
wcag2a: 'WCAG 2.0 Level A',
wcag2aa: 'WCAG 2.0 Level AA',
wcag21a: 'WCAG 2.1 Level A',
wcag21aa: 'WCAG 2.1 Level AA',
'best-practice': 'Best practice',
};

if (foundTags.length > 0) {
return foundTags.map((tag) => tagNamesToAccessibilityStandard[tag]).join(',');
// case 1: tags includes best-practice
if (tags.includes('best-practice')) {
return 'Best practice';
}
// case 2: tags does not include best-practice and include one or more wcag tags
const foundWcagTags = tags.filter((tag) => tag.includes('wcag'));
if (foundWcagTags.length > 0) {
return foundWcagTags
.map((tag) => {
const sectionNumberMatch = tag.match(/\d+/);
const levelMatch = tag.match(/wcag\d+(a+)/);
const sectionNumber =
sectionNumberMatch && sectionNumberMatch.length >= 1
? sectionNumberMatch[0].split('').join('.')
: ''; // wcag section number, e.g 2 in 'wcag2aa' or 411 in 'wcag411' tag
const level =
levelMatch && levelMatch.length > 1
? ` Level ${levelMatch[1].toUpperCase()}`
: ''; // wcag level, e.g aa in 'wcag2aa' or a in 'wcag21a' tag
return `WCAG ${sectionNumber}${level}`;
})
.join(', ');
}
// case 3: tags does not include best-practice or wcag, return raw tags comma separated

return tags.join(',');
}
2 changes: 2 additions & 0 deletions src/util/prepareReportData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function simplifyAxeResultForSummary(results: Result[]): Summary[] {
id,
help,
wcag: getWcagReference(tags),
tags,
impact: impact || 'n/a',
nodes: nodes.length,
}));
Expand Down Expand Up @@ -68,6 +69,7 @@ export function prepareReportData({
return {
index: issueIndex + 1,
wcag: getWcagReference(tags),
tags,
id,
impact: impact || 'n/a',
description,
Expand Down
20 changes: 14 additions & 6 deletions src/util/template/pageTemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ <h3>
<a href="{{url}}" target="_blank" class="card-link">{{url}}</a>
<br />
</div>
{{/url}}
{{#customSummary}}<div class="summary">{{{customSummary}}}</div>{{/customSummary}}
{{/url}} {{#customSummary}}
<div class="summary">{{{customSummary}}}</div>
{{/customSummary}}
</div>
<h5>{{{violationsSummary}}}</h5>
{{#violationDetails.length}}
Expand All @@ -103,8 +104,8 @@ <h5>{{{violationsSummary}}}</h5>
<th style="width: 5%">#</th>
<th style="width: 45%">Description</th>
<th style="width: 15%">Axe rule ID</th>
<th style="width: 15%">WCAG</th>
<th style="width: 15%">Impact</th>
<th style="width: 23%">WCAG</th>
<th style="width: 7%">Impact</th>
<th style="width: 5%">Count</th>
</tr>
</thead>
Expand Down Expand Up @@ -150,6 +151,13 @@ <h6 class="card-subtitle mb-2 text-muted violationCardTitleItem">
{{impact}}
</h6>
</div>
<div class="violationCardLine">
<h6 class="card-subtitle mb-2 text-muted violationCardTitleItem">
Issue Tags: {{#tags}}
<span class="badge bg-light text-dark"> {{.}} </span>
{{/tags}}
</h6>
</div>
<div class="violationNode">
<table class="table table-sm table-bordered">
<thead>
Expand Down Expand Up @@ -224,9 +232,9 @@ <h5 class="mb-0">
<thead>
<tr>
<th style="width: 5%">#</th>
<th style="width: 50%">Description</th>
<th style="width: 40%">Description</th>
<th style="width: 5%">Axe rule ID</th>
<th style="width: 5%">WCAG</th>
<th style="width: 15%">WCAG</th>
<th style="width: 5%">Nodes passed check</th>
</tr>
</thead>
Expand Down
Loading

0 comments on commit 3b93c5d

Please sign in to comment.