From 5f30135f3bb19de189dd90444ef5ab336168880c Mon Sep 17 00:00:00 2001 From: Daniel Weck Date: Thu, 11 Apr 2019 16:42:47 +0100 Subject: [PATCH 001/119] Axe Core upgrade to 3.2.2, breaking changes, work in progress (end goal: localized messages) --- packages/ace-core/package.json | 2 +- packages/ace-core/src/scripts/ace-axe.js | 17 ++++++++++------- packages/ace-logger/src/index.js | 7 +++++++ packages/ace-report-axe/src/index.js | 6 +++++- packages/ace-report/src/generate-html-report.js | 12 ++++++------ packages/ace-report/src/report.js | 2 +- tests/__tests__/axe-rules.test.js | 2 ++ tests/__tests__/epub-rules.test.js | 3 +++ tests/__tests__/regression.test.js | 2 ++ tests/__tests__/report_files.test.js | 2 ++ tests/__tests__/report_json.test.js | 2 ++ tests/__tests__/unzip.test.js | 2 ++ website/content/rules/html.md | 2 +- yarn.lock | 7 ++++--- 14 files changed, 48 insertions(+), 20 deletions(-) diff --git a/packages/ace-core/package.json b/packages/ace-core/package.json index 4d29edb8..d3ff1618 100644 --- a/packages/ace-core/package.json +++ b/packages/ace-core/package.json @@ -21,7 +21,7 @@ "@daisy/ace-report-axe": "^1.0.1", "@daisy/epub-utils": "^1.0.2", "@daisy/puppeteer-utils": "^1.0.0", - "axe-core": "~2.6.1", + "axe-core": "^3.2.2", "file-url": "^2.0.2", "h5o": "^0.11.3", "p-map": "^1.2.0", diff --git a/packages/ace-core/src/scripts/ace-axe.js b/packages/ace-core/src/scripts/ace-axe.js index fb86f1ee..2ab6e6a9 100644 --- a/packages/ace-core/src/scripts/ace-axe.js +++ b/packages/ace-core/src/scripts/ace-axe.js @@ -77,7 +77,7 @@ daisy.ace.run = function(done) { jsonItem.targetCFI.push(cfi); } } else { - throw "WTF?!"; + throw "WTF?!"; // TODO translate / localize / l10n ;) } } } @@ -149,11 +149,11 @@ daisy.ace.run = function(done) { impact: 'minor', messages: { pass: function anonymous(it) { - var out = 'Element has an ARIA role matching its epub:type'; + var out = 'Element has an ARIA role matching its epub:type'; // TODO translate / localize / l10n return out; }, fail: function anonymous(it) { - var out = 'Element has no ARIA role matching its epub:type'; + var out = 'Element has no ARIA role matching its epub:type'; // TODO translate / localize / l10n return out; } } @@ -166,7 +166,7 @@ daisy.ace.run = function(done) { selector: '[*|type~="pagebreak"], [role~="doc-pagebreak"]', any: ['aria-label', 'non-empty-title'], metadata: { - description: "Ensure page markers have an accessible label", + description: "Ensure page markers have an accessible label", // TODO translate / localize / l10n }, tags: ['cat.epub'] }, @@ -175,15 +175,16 @@ 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", + help: "ARIA role should be used in addition to epub:type", // TODO translate / localize / l10n + description: "Ensure the element has an ARIA role matching its epub:type", // TODO translate / localize / l10n }, tags: ['best-practice'] }, { id: 'landmark-one-main', all: [ - "has-no-more-than-one-main" + "has-no-more-than-one-main", + "page-no-duplicate-main" // Was `has-no-more-than-one-main`, see https://github.com/dequelabs/axe-core/blob/develop/CHANGELOG.md#300-2018-03-19 ], } ] @@ -193,6 +194,8 @@ daisy.ace.run = function(done) { { "rules": { "bypass": { enabled: false }, + // "region": { enabled: false }, + // "implicit-role-fallback": { enabled: false }, } }, function(axeError, axeResult) { diff --git a/packages/ace-logger/src/index.js b/packages/ace-logger/src/index.js index de39303a..9cd19df1 100644 --- a/packages/ace-logger/src/index.js +++ b/packages/ace-logger/src/index.js @@ -22,6 +22,13 @@ module.exports.initLogger = function initLogger(options = {}) { fs.removeSync(logfile); } + // TODO remove this, this is just for testing/debugging + if (options.verbose && !options.silent) { + console.log(`>>>>> LOG FILE PATH: ${logfile}`); + process.stdout.write(`>>>>> LOG FILE PATH: ${logfile}`); + process.stderr.write(`>>>>> LOG FILE PATH: ${logfile}`); + } + // set up logger const level = (options.verbose) ? 'verbose' : logConfig.level; winston.configure({ diff --git a/packages/ace-report-axe/src/index.js b/packages/ace-report-axe/src/index.js index 0331bbec..a906b976 100644 --- a/packages/ace-report-axe/src/index.js +++ b/packages/ace-report-axe/src/index.js @@ -74,12 +74,16 @@ function axe2ace(spineItem, axeResults) { .withTestSubject(spineItem.relpath, spineItem.title); // process axe's individual checks for a single content document axeResults.violations.forEach((violation) => { + + // TODO: tweak ResultBuilder info, nodes + relatedNodes (e.g. region Axe rule for containing landmarks) + // console.log(JSON.stringify(violation, null, 4)); + const kbURL = (kbMap.map.hasOwnProperty(violation.id)) ? kbMap.baseUrl + kbMap.map[violation.id].url : kbMap.baseUrl; const kbTitle = (kbMap.map.hasOwnProperty(violation.id)) ? kbMap.map[violation.id].title - : 'Unknown'; + : 'Unknown'; // TODO translate / localize / l10n if (kbTitle == 'Unknown') winston.verbose(`Couldn’t find KB key for rule '${violation.id}'`) const test = new builders.TestBuilder() .withImpact(violation.impact) diff --git a/packages/ace-report/src/generate-html-report.js b/packages/ace-report/src/generate-html-report.js index 23ef5cd4..84caa869 100644 --- a/packages/ace-report/src/generate-html-report.js +++ b/packages/ace-report/src/generate-html-report.js @@ -16,8 +16,8 @@ module.exports = function generateHtmlReport(reportData) { 'wcag2a': 'WCAG 2.0 A', 'wcag2aa': 'WCAG 2.0 AA', 'EPUB': 'EPUB', - 'best-practice': 'Best Practice', - 'other': 'Other' + 'best-practice': 'Best Practice', // TODO translate / localize / l10n + 'other': 'Other' // TODO translate / localize / l10n }; // return 5 data cells for each ruleset: critical, serious, moderate, minor, total @@ -61,15 +61,15 @@ module.exports = function generateHtmlReport(reportData) { \"${violation['fileTitle']}\"

${violation['location']}`; if (violation.html) { - htmlStr +=`

Snippet:${violation.html.trim()}
`; + htmlStr +=`

Snippet:${violation.html.trim()}
`; // TODO translate / localize / l10n } htmlStr += ""; var desc = violation["desc"]; - desc = desc.replace("Fix all of the following:", ""); - desc = desc.replace("Fix any of the following:", ""); + desc = desc.replace("Fix all of the following:", ""); // TODO translate / localize / l10n + desc = desc.replace("Fix any of the following:", ""); // TODO translate / localize / l10n var detailsArr = desc.split("\n"); var listStr = ''; @@ -82,7 +82,7 @@ module.exports = function generateHtmlReport(reportData) { htmlStr += `

Learn more about ${violation['kbtitle']}

- `; + `; // TODO translate / localize / l10n htmlStr += ""; }); diff --git a/packages/ace-report/src/report.js b/packages/ace-report/src/report.js index 6d280549..f2f92313 100644 --- a/packages/ace-report/src/report.js +++ b/packages/ace-report/src/report.js @@ -21,7 +21,7 @@ function headingsToOutline(headings) { } } else if (hx.level > level) { for (let i = level + 1; i < hx.level; i += 1) { - result.push(`