From 0dced3c2ff481f23c57786fedf6fe094996e5223 Mon Sep 17 00:00:00 2001 From: Tom Brunet Date: Fri, 23 Aug 2024 15:23:37 -0500 Subject: [PATCH 1/7] Do counting and "pass" filtering in the checking context --- accessibility-checker/src-ts/lib/ACHelper.ts | 287 +++++++++++++++++- common/module/src/engine/IReport.ts | 32 +- common/module/src/report/ReporterManager.ts | 20 +- .../src/lib/ACCommands.js | 70 +++++ .../src/lib/ACHelper.js | 72 ++++- 5 files changed, 447 insertions(+), 34 deletions(-) diff --git a/accessibility-checker/src-ts/lib/ACHelper.ts b/accessibility-checker/src-ts/lib/ACHelper.ts index ab1cd9ce3..5f50011df 100644 --- a/accessibility-checker/src-ts/lib/ACHelper.ts +++ b/accessibility-checker/src-ts/lib/ACHelper.ts @@ -229,6 +229,70 @@ async function getComplianceHelperSelenium(label, parsed, curPol) : Promise { + let reportLevel; + if (reportValue[1] === "PASS") { + reportLevel = "pass"; + } + else if ((reportValue[0] === "VIOLATION" || reportValue[0] === "RECOMMENDATION") && reportValue[1] === "MANUAL") { + reportLevel = "manual"; + } + else if (reportValue[0] === "VIOLATION") { + if (reportValue[1] === "FAIL") { + reportLevel = "violation"; + } + else if (reportValue[1] === "POTENTIAL") { + reportLevel = "potentialviolation"; + } + } + else if (reportValue[0] === "RECOMMENDATION") { + if (reportValue[1] === "FAIL") { + reportLevel = "recommendation"; + } + else if (reportValue[1] === "POTENTIAL") { + reportLevel = "potentialrecommendation"; + } + } + return reportLevel; +} + +const getCounts = (engineReport) => { + let counts = { + violation: 0, + potentialviolation: 0, + recommendation: 0, + potentialrecommendation: 0, + manual: 0, + pass: 0, + ignored: 0, + elements: 0, + elementsViolation: 0, + elementsViolationReview: 0 + } + let elementSet = new Set(); + let elementViolationSet = new Set(); + let elementViolationReviewSet = new Set(); + for (const issue of engineReport.results) { + elementSet.add(issue.path.dom); + if (issue.ignored) { + ++counts.ignored; + } else { + ++counts[issue.level]; + if (issue.level === "violation") { + elementViolationSet.add(issue.path.dom); + elementViolationReviewSet.add(issue.path.dom); + } else if (issue.level === "potentialviolation" || issue.level === "manual") { + elementViolationReviewSet.add(issue.path.dom); + } + } + } + counts.elements = elementSet.size; + counts.elementsViolation = elementViolationSet.size; + counts.elementsViolationReview = elementViolationReviewSet.size + return counts; +} + let policies = ${JSON.stringify(Config.policies)}; let checker = new window.ace_ibma.Checker(); @@ -238,7 +302,14 @@ setTimeout(function() { checker.check(document, policies).then(function(report) { for (const result of report.results) { delete result.node; + result.level = valueToLevel(result.value) } + report.summary ||= {}; + report.summary.counts ||= getCounts(report); + let reportLevels = ${JSON.stringify((Config.reportLevels || []).concat(Config.failLevels || []).map(lvl => lvl.toString()))}; + // Filter out pass results unless they asked for them in reports + // We don't want to mess with baseline functions, but pass results can break the response object + report.results = report.results.filter(result => reportLevels.includes(result.level) || result.level !== "pass"); cb(report); }) },0) @@ -291,8 +362,71 @@ async function getComplianceHelperWebDriverIO(label, parsed, curPol) : Promise { + let report : IEngineReport = await page.executeAsync(({ policies, customRulesets, reportLevels }, done) => { + const valueToLevel = (reportValue) => { + let reportLevel; + if (reportValue[1] === "PASS") { + reportLevel = "pass"; + } + else if ((reportValue[0] === "VIOLATION" || reportValue[0] === "RECOMMENDATION") && reportValue[1] === "MANUAL") { + reportLevel = "manual"; + } + else if (reportValue[0] === "VIOLATION") { + if (reportValue[1] === "FAIL") { + reportLevel = "violation"; + } + else if (reportValue[1] === "POTENTIAL") { + reportLevel = "potentialviolation"; + } + } + else if (reportValue[0] === "RECOMMENDATION") { + if (reportValue[1] === "FAIL") { + reportLevel = "recommendation"; + } + else if (reportValue[1] === "POTENTIAL") { + reportLevel = "potentialrecommendation"; + } + } + return reportLevel; + } + + const getCounts = (engineReport) => { + let counts = { + violation: 0, + potentialviolation: 0, + recommendation: 0, + potentialrecommendation: 0, + manual: 0, + pass: 0, + ignored: 0, + elements: 0, + elementsViolation: 0, + elementsViolationReview: 0 + } + let elementSet = new Set(); + let elementViolationSet = new Set(); + let elementViolationReviewSet = new Set(); + for (const issue of engineReport.results) { + elementSet.add(issue.path.dom); + if (issue.ignored) { + ++counts.ignored; + } else { + ++counts[issue.level]; + if (issue.level === "violation") { + elementViolationSet.add(issue.path.dom); + elementViolationReviewSet.add(issue.path.dom); + } else if (issue.level === "potentialviolation" || issue.level === "manual") { + elementViolationReviewSet.add(issue.path.dom); + } + } + } + counts.elements = elementSet.size; + counts.elementsViolation = elementViolationSet.size; + counts.elementsViolationReview = elementViolationReviewSet.size + return counts; + } + let checker = new (window as any).ace_ibma.Checker(); customRulesets.forEach((rs) => checker.addRuleset(rs)); return new Promise((resolve, reject) => { @@ -300,13 +434,19 @@ async function getComplianceHelperWebDriverIO(label, parsed, curPol) : Promise reportLevels.includes(result.level) || result.level !== "pass"); resolve(report); done(report); }) }, 0) }) - }, { policies: Config.policies, customRulesets: ACEngineManager.customRulesets }); + }, { policies: Config.policies, customRulesets: ACEngineManager.customRulesets, reportLevels: (Config.reportLevels || []).concat(Config.failLevels || []).map(lvl => lvl.toString()) }); if (curPol != null && !checkPolicy) { const valPolicies = ACEngineManager.customRulesets.map(rs => rs.id).concat(await page.execute(() => (new (window as any).ace_ibma.Checker().rulesetIds))); checkPolicy = true; @@ -347,8 +487,69 @@ async function getComplianceHelperPuppeteer(label, parsed, curPol) : Promise { - + let report : IEngineReport = await page.evaluate(({ policies, customRulesets, reportLevels }) => { + const valueToLevel = (reportValue) => { + let reportLevel; + if (reportValue[1] === "PASS") { + reportLevel = "pass"; + } + else if ((reportValue[0] === "VIOLATION" || reportValue[0] === "RECOMMENDATION") && reportValue[1] === "MANUAL") { + reportLevel = "manual"; + } + else if (reportValue[0] === "VIOLATION") { + if (reportValue[1] === "FAIL") { + reportLevel = "violation"; + } + else if (reportValue[1] === "POTENTIAL") { + reportLevel = "potentialviolation"; + } + } + else if (reportValue[0] === "RECOMMENDATION") { + if (reportValue[1] === "FAIL") { + reportLevel = "recommendation"; + } + else if (reportValue[1] === "POTENTIAL") { + reportLevel = "potentialrecommendation"; + } + } + return reportLevel; + } + + const getCounts = (engineReport) => { + let counts = { + violation: 0, + potentialviolation: 0, + recommendation: 0, + potentialrecommendation: 0, + manual: 0, + pass: 0, + ignored: 0, + elements: 0, + elementsViolation: 0, + elementsViolationReview: 0 + } + let elementSet = new Set(); + let elementViolationSet = new Set(); + let elementViolationReviewSet = new Set(); + for (const issue of engineReport.results) { + elementSet.add(issue.path.dom); + if (issue.ignored) { + ++counts.ignored; + } else { + ++counts[issue.level]; + if (issue.level === "violation") { + elementViolationSet.add(issue.path.dom); + elementViolationReviewSet.add(issue.path.dom); + } else if (issue.level === "potentialviolation" || issue.level === "manual") { + elementViolationReviewSet.add(issue.path.dom); + } + } + } + counts.elements = elementSet.size; + counts.elementsViolation = elementViolationSet.size; + counts.elementsViolationReview = elementViolationReviewSet.size + return counts; + } let checker = new (window as any).ace_ibma.Checker(); customRulesets.forEach((rs) => checker.addRuleset(rs)); return new Promise((resolve, reject) => { @@ -356,12 +557,18 @@ async function getComplianceHelperPuppeteer(label, parsed, curPol) : Promise reportLevels.includes(result.level) || result.level !== "pass"); resolve(report); }) }, 0) }) - }, { policies: Config.policies, customRulesets: ACEngineManager.customRulesets }); + }, { policies: Config.policies, customRulesets: ACEngineManager.customRulesets, reportLevels: (Config.reportLevels || []).concat(Config.failLevels || []).map(lvl => lvl.toString()) }); if (curPol != null && !checkPolicy) { const valPolicies = ACEngineManager.customRulesets.map(rs => rs.id).concat(await page.evaluate("new window.ace_ibma.Checker().rulesetIds")); checkPolicy = true; @@ -399,6 +606,69 @@ async function getComplianceHelperPuppeteer(label, parsed, curPol) : Promise { try { + const valueToLevel = (reportValue) => { + let reportLevel; + if (reportValue[1] === "PASS") { + reportLevel = "pass"; + } + else if ((reportValue[0] === "VIOLATION" || reportValue[0] === "RECOMMENDATION") && reportValue[1] === "MANUAL") { + reportLevel = "manual"; + } + else if (reportValue[0] === "VIOLATION") { + if (reportValue[1] === "FAIL") { + reportLevel = "violation"; + } + else if (reportValue[1] === "POTENTIAL") { + reportLevel = "potentialviolation"; + } + } + else if (reportValue[0] === "RECOMMENDATION") { + if (reportValue[1] === "FAIL") { + reportLevel = "recommendation"; + } + else if (reportValue[1] === "POTENTIAL") { + reportLevel = "potentialrecommendation"; + } + } + return reportLevel; + } + + const getCounts = (engineReport) => { + let counts = { + violation: 0, + potentialviolation: 0, + recommendation: 0, + potentialrecommendation: 0, + manual: 0, + pass: 0, + ignored: 0, + elements: 0, + elementsViolation: 0, + elementsViolationReview: 0 + } + let elementSet = new Set(); + let elementViolationSet = new Set(); + let elementViolationReviewSet = new Set(); + for (const issue of engineReport.results) { + elementSet.add(issue.path.dom); + if (issue.ignored) { + ++counts.ignored; + } else { + ++counts[issue.level]; + if (issue.level === "violation") { + elementViolationSet.add(issue.path.dom); + elementViolationReviewSet.add(issue.path.dom); + } else if (issue.level === "potentialviolation" || issue.level === "manual") { + elementViolationReviewSet.add(issue.path.dom); + } + } + } + counts.elements = elementSet.size; + counts.elementsViolation = elementViolationSet.size; + counts.elementsViolationReview = elementViolationReviewSet.size + return counts; + } + let startScan = Date.now(); let checker = ACEngineManager.getChecker(); ACEngineManager.customRulesets.forEach((rs) => checker.addGuideline(rs)); @@ -406,7 +676,14 @@ async function getComplianceHelperLocal(label, parsed, curPol) : Promise lvl.toString()); + // Filter out pass results unless they asked for them in reports + // We don't want to mess with baseline functions, but pass results can break the response object + report.results = report.results.filter(result => reportLevels.includes(result.level) || result.level !== "pass"); return report; }) diff --git a/common/module/src/engine/IReport.ts b/common/module/src/engine/IReport.ts index 5c42187e4..1da743258 100644 --- a/common/module/src/engine/IReport.ts +++ b/common/module/src/engine/IReport.ts @@ -65,6 +65,9 @@ export type IEngineReport = { [ruleId: string]: { [reasonId: string]: string } + }, + summary?: { + counts?: SummaryCounts } } @@ -76,6 +79,19 @@ export type IBaselineResult = IEngineResult & { level: eRuleLevel } +export type SummaryCounts = { + violation: number, + potentialviolation: number, + recommendation: number, + potentialrecommendation: number, + manual: number, + pass: number, + ignored: number, + elements: number, + elementsViolation: number, + elementsViolationReview: number +} + export type IBaselineReport = { results: IBaselineResult[] numExecuted: number, @@ -85,18 +101,7 @@ export type IBaselineReport = { } } summary: { - counts: { - violation: number, - potentialviolation: number, - recommendation: number, - potentialrecommendation: number, - manual: number, - pass: number, - ignored: number, - elements: number, - elementsViolation: number, - elementsViolationReview: number - } + counts: SummaryCounts, scanTime: number, ruleArchive: string policies: string[] @@ -120,7 +125,8 @@ export type CompressedReport = [ string, // ruleArchive string[], // policies string[], // reportLevels - CompressedIssue[] + CompressedIssue[], + SummaryCounts ] export type CompressedIssue = [ // results diff --git a/common/module/src/report/ReporterManager.ts b/common/module/src/report/ReporterManager.ts index 605fc8a5c..b1524b1b0 100644 --- a/common/module/src/report/ReporterManager.ts +++ b/common/module/src/report/ReporterManager.ts @@ -105,7 +105,8 @@ export class ReporterManager { report.engineReport.summary.ruleArchive, // 7 report.engineReport.summary.policies, // 8 report.engineReport.summary.reportLevels, // 9 - compressedResults // 10 + compressedResults, // 10 + report.engineReport.summary.counts // 11 ] for (let idx=0; idx 32000) { @@ -151,18 +152,7 @@ export class ReporterManager { numExecuted: report[5], nls, summary: { - counts: { - violation: 0, - potentialviolation: 0, - recommendation: 0, - potentialrecommendation: 0, - manual: 0, - pass: 0, - ignored: 0, - elements: 0, - elementsViolation: 0, - elementsViolationReview: 0 - }, + counts: report[11], scanTime: report[6], ruleArchive: report[7], policies: report[8], @@ -174,7 +164,6 @@ export class ReporterManager { toolID: ReporterManager.toolID, label: report[3] } - engineReport.summary.counts = ReporterManager.getCounts(engineReport); return { startScan: report[0], url: report[1], @@ -390,7 +379,7 @@ export class ReporterManager { }); (retVal as any).summary = {}; - retVal.summary.counts = ReporterManager.getCounts(retVal); + retVal.summary.counts = engineResult.summary.counts || ReporterManager.getCounts(engineResult as any); retVal.results = retVal.results.filter(pageResult => { if (ReporterManager.config.reportLevels.includes(pageResult.level)) { @@ -460,6 +449,7 @@ export class ReporterManager { counts.elements = elementSet.size; counts.elementsViolation = elementViolationSet.size; counts.elementsViolationReview = elementViolationReviewSet.size + console.log(counts.pass); return counts; } diff --git a/cypress-accessibility-checker/src/lib/ACCommands.js b/cypress-accessibility-checker/src/lib/ACCommands.js index 87a573493..6248aa080 100644 --- a/cypress-accessibility-checker/src/lib/ACCommands.js +++ b/cypress-accessibility-checker/src/lib/ACCommands.js @@ -16,6 +16,69 @@ let logger = { create: loggerCreate }; +function valueToLevel(reportValue) { + let reportLevel; + if (reportValue[1] === "PASS") { + reportLevel = "pass"; + } + else if ((reportValue[0] === "VIOLATION" || reportValue[0] === "RECOMMENDATION") && reportValue[1] === "MANUAL") { + reportLevel = "manual"; + } + else if (reportValue[0] === "VIOLATION") { + if (reportValue[1] === "FAIL") { + reportLevel = "violation"; + } + else if (reportValue[1] === "POTENTIAL") { + reportLevel = "potentialviolation"; + } + } + else if (reportValue[0] === "RECOMMENDATION") { + if (reportValue[1] === "FAIL") { + reportLevel = "recommendation"; + } + else if (reportValue[1] === "POTENTIAL") { + reportLevel = "potentialrecommendation"; + } + } + return reportLevel; +} + +function getCounts(engineReport) { + let counts = { + violation: 0, + potentialviolation: 0, + recommendation: 0, + potentialrecommendation: 0, + manual: 0, + pass: 0, + ignored: 0, + elements: 0, + elementsViolation: 0, + elementsViolationReview: 0 + } + let elementSet = new Set(); + let elementViolationSet = new Set(); + let elementViolationReviewSet = new Set(); + for (const issue of engineReport.results) { + elementSet.add(issue.path.dom); + if (issue.ignored) { + ++counts.ignored; + } else { + ++counts[issue.level]; + if (issue.level === "violation") { + elementViolationSet.add(issue.path.dom); + elementViolationReviewSet.add(issue.path.dom); + } else if (issue.level === "potentialviolation" || issue.level === "manual") { + elementViolationReviewSet.add(issue.path.dom); + } + } + } + counts.elements = elementSet.size; + counts.elementsViolation = elementViolationSet.size; + counts.elementsViolationReview = elementViolationReviewSet.size + return counts; +} + let ACCommands = module.exports = { DEBUG: false, initialize: (win, fileConfig) => { @@ -107,7 +170,14 @@ let ACCommands = module.exports = { .then(function (report) { for (const result of report.results) { delete result.node; + result.level = valueToLevel(result.value) } + report.summary ||= {}; + report.summary.counts ||= getCounts(report); + let reportLevels = (ACCommands.Config.reportLevels || []).concat(ACCommands.Config.failLevels || []); + // Filter out pass results unless they asked for them in reports + // We don't want to mess with baseline functions, but pass results can break the response object + report.results = report.results.filter(result => reportLevels.includes(result.level) || result.level !== "pass"); return report; }) } catch (err) { diff --git a/karma-accessibility-checker/src/lib/ACHelper.js b/karma-accessibility-checker/src/lib/ACHelper.js index 20f5cda98..53ba04001 100644 --- a/karma-accessibility-checker/src/lib/ACHelper.js +++ b/karma-accessibility-checker/src/lib/ACHelper.js @@ -235,7 +235,70 @@ let aChecker = { * @memberOf this */ aChecker.runScan = async function (content, policies, url, pageTitle, label, iframeWindow) { - try { + try { + const valueToLevel = (reportValue) => { + let reportLevel; + if (reportValue[1] === "PASS") { + reportLevel = "pass"; + } + else if ((reportValue[0] === "VIOLATION" || reportValue[0] === "RECOMMENDATION") && reportValue[1] === "MANUAL") { + reportLevel = "manual"; + } + else if (reportValue[0] === "VIOLATION") { + if (reportValue[1] === "FAIL") { + reportLevel = "violation"; + } + else if (reportValue[1] === "POTENTIAL") { + reportLevel = "potentialviolation"; + } + } + else if (reportValue[0] === "RECOMMENDATION") { + if (reportValue[1] === "FAIL") { + reportLevel = "recommendation"; + } + else if (reportValue[1] === "POTENTIAL") { + reportLevel = "potentialrecommendation"; + } + } + return reportLevel; + } + + const getCounts = (engineReport) => { + let counts = { + violation: 0, + potentialviolation: 0, + recommendation: 0, + potentialrecommendation: 0, + manual: 0, + pass: 0, + ignored: 0, + elements: 0, + elementsViolation: 0, + elementsViolationReview: 0 + } + let elementSet = new Set(); + let elementViolationSet = new Set(); + let elementViolationReviewSet = new Set(); + for (const issue of engineReport.results) { + elementSet.add(issue.path.dom); + if (issue.ignored) { + ++counts.ignored; + } else { + ++counts[issue.level]; + if (issue.level === "violation") { + elementViolationSet.add(issue.path.dom); + elementViolationReviewSet.add(issue.path.dom); + } else if (issue.level === "potentialviolation" || issue.level === "manual") { + elementViolationReviewSet.add(issue.path.dom); + } + } + } + counts.elements = elementSet.size; + counts.elementsViolation = elementViolationSet.size; + counts.elementsViolationReview = elementViolationReviewSet.size + return counts; + } + // Get the Data when the scan is started // Start time will be in milliseconds elapsed since 1 January 1970 00:00:00 UTC up until now. const startScan = Date.now(); @@ -247,7 +310,14 @@ let aChecker = { let engineReport = await checker.check(content, policies); for (const result of engineReport.results) { delete result.node; + result.level = valueToLevel(result.value) } + let reportLevels = (aChecker.Config.reportLevels || []).concat(aChecker.Config.failLevels || []).map(lvl => lvl.toString()); + report.summary ||= {}; + report.summary.counts ||= getCounts(report); + // Filter out pass results unless they asked for them in reports + // We don't want to mess with baseline functions, but pass results can break the response object + report.results = report.results.filter(result => reportLevels.includes(result.level) || result.level !== "pass"); ReporterManager.config = BaselineManager.config = aChecker.Config; From 3f496e4fa8c8a13bb1d18cefa9d7a134ba56d06a Mon Sep 17 00:00:00 2001 From: Tom Brunet Date: Fri, 23 Aug 2024 16:03:10 -0500 Subject: [PATCH 2/7] typescript --- accessibility-checker-engine/src/v4/api/IRule.ts | 3 ++- common/module/src/engine/IRule.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/accessibility-checker-engine/src/v4/api/IRule.ts b/accessibility-checker-engine/src/v4/api/IRule.ts index 19c1bdae8..32a0fd6f3 100644 --- a/accessibility-checker-engine/src/v4/api/IRule.ts +++ b/accessibility-checker-engine/src/v4/api/IRule.ts @@ -101,7 +101,8 @@ export type Issue = RuleResult & { ruleTime: number, message: string, bounds?: Bounds, - snippet: string + snippet: string, + level?: string } export type RuleContextHierarchy = { [namespace: string] : IMapResult[] }; diff --git a/common/module/src/engine/IRule.ts b/common/module/src/engine/IRule.ts index f10a64d8c..dd65ba100 100644 --- a/common/module/src/engine/IRule.ts +++ b/common/module/src/engine/IRule.ts @@ -99,7 +99,8 @@ export type Issue = RuleResult & { ruleTime: number, message: string, bounds?: Bounds, - snippet: string + snippet: string, + level?: string } export type RuleContextHierarchy = { [namespace: string] : IMapResult[] }; From 31fea343225ecdfac2b2285a7f51dbc004ec088b Mon Sep 17 00:00:00 2001 From: Tom Brunet Date: Fri, 23 Aug 2024 16:10:53 -0500 Subject: [PATCH 3/7] Wrong variable --- karma-accessibility-checker/src/lib/ACHelper.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/karma-accessibility-checker/src/lib/ACHelper.js b/karma-accessibility-checker/src/lib/ACHelper.js index 53ba04001..719b8e616 100644 --- a/karma-accessibility-checker/src/lib/ACHelper.js +++ b/karma-accessibility-checker/src/lib/ACHelper.js @@ -313,11 +313,11 @@ let aChecker = { result.level = valueToLevel(result.value) } let reportLevels = (aChecker.Config.reportLevels || []).concat(aChecker.Config.failLevels || []).map(lvl => lvl.toString()); - report.summary ||= {}; - report.summary.counts ||= getCounts(report); + engineReport.summary ||= {}; + engineReport.summary.counts ||= getCounts(engineReport); // Filter out pass results unless they asked for them in reports // We don't want to mess with baseline functions, but pass results can break the response object - report.results = report.results.filter(result => reportLevels.includes(result.level) || result.level !== "pass"); + engineReport.results = engineReport.results.filter(result => reportLevels.includes(result.level) || result.level !== "pass"); ReporterManager.config = BaselineManager.config = aChecker.Config; From b2670d47df10a6dcb6536590c4c6095c9cd8efe6 Mon Sep 17 00:00:00 2001 From: Tom Brunet Date: Fri, 23 Aug 2024 16:52:24 -0500 Subject: [PATCH 4/7] Fix counting --- accessibility-checker/src-ts/lib/ACHelper.ts | 102 ++---------------- common/module/src/report/ReporterManager.ts | 16 +-- .../src/lib/ACCommands.js | 24 +---- .../src/lib/ACHelper.js | 26 +---- .../src/lib/ReporterManager.js | 15 +-- 5 files changed, 24 insertions(+), 159 deletions(-) diff --git a/accessibility-checker/src-ts/lib/ACHelper.ts b/accessibility-checker/src-ts/lib/ACHelper.ts index 5f50011df..9213a1be9 100644 --- a/accessibility-checker/src-ts/lib/ACHelper.ts +++ b/accessibility-checker/src-ts/lib/ACHelper.ts @@ -264,35 +264,15 @@ const getCounts = (engineReport) => { recommendation: 0, potentialrecommendation: 0, manual: 0, - pass: 0, - ignored: 0, - elements: 0, - elementsViolation: 0, - elementsViolationReview: 0 + pass: 0 } - let elementSet = new Set(); - let elementViolationSet = new Set(); - let elementViolationReviewSet = new Set(); for (const issue of engineReport.results) { - elementSet.add(issue.path.dom); - if (issue.ignored) { - ++counts.ignored; - } else { - ++counts[issue.level]; - if (issue.level === "violation") { - elementViolationSet.add(issue.path.dom); - elementViolationReviewSet.add(issue.path.dom); - } else if (issue.level === "potentialviolation" || issue.level === "manual") { - elementViolationReviewSet.add(issue.path.dom); - } - } + ++counts[issue.level]; } - counts.elements = elementSet.size; - counts.elementsViolation = elementViolationSet.size; - counts.elementsViolationReview = elementViolationReviewSet.size return counts; } + let policies = ${JSON.stringify(Config.policies)}; let checker = new window.ace_ibma.Checker(); @@ -398,32 +378,11 @@ async function getComplianceHelperWebDriverIO(label, parsed, curPol) : Promise checker.addRuleset(rs)); return new Promise((resolve, reject) => { @@ -640,32 +579,11 @@ async function getComplianceHelperLocal(label, parsed, curPol) : Promise { if (ReporterManager.config.reportLevels.includes(pageResult.level)) { @@ -416,18 +416,13 @@ export class ReporterManager { return retVal; } - private static getCounts(engineReport: IBaselineReport) { + private static addCounts(engineReport: IBaselineReport) { let counts = { - violation: 0, - potentialviolation: 0, - recommendation: 0, - potentialrecommendation: 0, - manual: 0, - pass: 0, ignored: 0, elements: 0, elementsViolation: 0, - elementsViolationReview: 0 + elementsViolationReview: 0, + ...engineReport.summary.counts } let elementSet = new Set(); let elementViolationSet = new Set(); @@ -436,8 +431,8 @@ export class ReporterManager { elementSet.add(issue.path.dom); if (issue.ignored) { ++counts.ignored; + --counts[issue.level.toString()]; } else { - ++counts[issue.level.toString()]; if (issue.level === eRuleLevel.violation) { elementViolationSet.add(issue.path.dom); elementViolationReviewSet.add(issue.path.dom); @@ -449,7 +444,6 @@ export class ReporterManager { counts.elements = elementSet.size; counts.elementsViolation = elementViolationSet.size; counts.elementsViolationReview = elementViolationReviewSet.size - console.log(counts.pass); return counts; } diff --git a/cypress-accessibility-checker/src/lib/ACCommands.js b/cypress-accessibility-checker/src/lib/ACCommands.js index 6248aa080..f1d715121 100644 --- a/cypress-accessibility-checker/src/lib/ACCommands.js +++ b/cypress-accessibility-checker/src/lib/ACCommands.js @@ -49,33 +49,11 @@ function getCounts(engineReport) { potentialviolation: 0, recommendation: 0, potentialrecommendation: 0, - manual: 0, - pass: 0, - ignored: 0, - elements: 0, - elementsViolation: 0, - elementsViolationReview: 0 + manual: 0 } - let elementSet = new Set(); - let elementViolationSet = new Set(); - let elementViolationReviewSet = new Set(); for (const issue of engineReport.results) { elementSet.add(issue.path.dom); - if (issue.ignored) { - ++counts.ignored; - } else { - ++counts[issue.level]; - if (issue.level === "violation") { - elementViolationSet.add(issue.path.dom); - elementViolationReviewSet.add(issue.path.dom); - } else if (issue.level === "potentialviolation" || issue.level === "manual") { - elementViolationReviewSet.add(issue.path.dom); - } - } } - counts.elements = elementSet.size; - counts.elementsViolation = elementViolationSet.size; - counts.elementsViolationReview = elementViolationReviewSet.size return counts; } diff --git a/karma-accessibility-checker/src/lib/ACHelper.js b/karma-accessibility-checker/src/lib/ACHelper.js index 719b8e616..b49117054 100644 --- a/karma-accessibility-checker/src/lib/ACHelper.js +++ b/karma-accessibility-checker/src/lib/ACHelper.js @@ -270,35 +270,15 @@ let aChecker = { recommendation: 0, potentialrecommendation: 0, manual: 0, - pass: 0, - ignored: 0, - elements: 0, - elementsViolation: 0, - elementsViolationReview: 0 + pass: 0 } - let elementSet = new Set(); - let elementViolationSet = new Set(); - let elementViolationReviewSet = new Set(); for (const issue of engineReport.results) { - elementSet.add(issue.path.dom); - if (issue.ignored) { - ++counts.ignored; - } else { - ++counts[issue.level]; - if (issue.level === "violation") { - elementViolationSet.add(issue.path.dom); - elementViolationReviewSet.add(issue.path.dom); - } else if (issue.level === "potentialviolation" || issue.level === "manual") { - elementViolationReviewSet.add(issue.path.dom); - } - } + ++counts[issue.level]; } - counts.elements = elementSet.size; - counts.elementsViolation = elementViolationSet.size; - counts.elementsViolationReview = elementViolationReviewSet.size return counts; } + // Get the Data when the scan is started // Start time will be in milliseconds elapsed since 1 January 1970 00:00:00 UTC up until now. const startScan = Date.now(); diff --git a/karma-accessibility-checker/src/lib/ReporterManager.js b/karma-accessibility-checker/src/lib/ReporterManager.js index ce00870e2..ac55612be 100644 --- a/karma-accessibility-checker/src/lib/ReporterManager.js +++ b/karma-accessibility-checker/src/lib/ReporterManager.js @@ -142,7 +142,7 @@ class ReporterManager { }); retVal.summary = {}; - retVal.summary.counts = ReporterManager.getCounts(retVal); + retVal.summary.counts = ReporterManager.addCounts(retVal); retVal.results = retVal.results.filter(pageResult => { if (ReporterManager.config.reportLevels.includes(pageResult.level)) { @@ -179,18 +179,13 @@ class ReporterManager { return retVal; } - static getCounts(engineReport) { + static addCounts(engineReport) { let counts = { - violation: 0, - potentialviolation: 0, - recommendation: 0, - potentialrecommendation: 0, - manual: 0, - pass: 0, ignored: 0, elements: 0, elementsViolation: 0, - elementsViolationReview: 0 + elementsViolationReview: 0, + ...engineReport.summary.counts } let elementSet = new Set(); let elementViolationSet = new Set(); @@ -199,8 +194,8 @@ class ReporterManager { elementSet.add(issue.path.dom); if (issue.ignored) { ++counts.ignored; + --counts[issue.level.toString()]; } else { - ++counts[issue.level.toString()]; if (issue.level === eRuleLevel.violation) { elementViolationSet.add(issue.path.dom); elementViolationReviewSet.add(issue.path.dom); From 6de1516723fe4b3721f863d32d59a12956d57f6e Mon Sep 17 00:00:00 2001 From: Tom Brunet Date: Fri, 23 Aug 2024 17:03:10 -0500 Subject: [PATCH 5/7] Typescript bug --- accessibility-checker/src-ts/lib/ACHelper.ts | 8 ++++---- common/module/src/engine/IReport.ts | 11 ++++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/accessibility-checker/src-ts/lib/ACHelper.ts b/accessibility-checker/src-ts/lib/ACHelper.ts index 9213a1be9..6f68a2f0c 100644 --- a/accessibility-checker/src-ts/lib/ACHelper.ts +++ b/accessibility-checker/src-ts/lib/ACHelper.ts @@ -6,7 +6,7 @@ import { IConfigInternal } from "./common/config/IConfig"; import { ReporterManager } from "./common/report/ReporterManager"; import { existsSync, mkdirSync, writeFileSync } from "fs"; import { IAbstractAPI } from "./common/api-ext/IAbstractAPI"; -import { IBaselineReport, IEngineReport } from "./common/engine/IReport"; +import { EngineSummaryCounts, IBaselineReport, IEngineReport } from "./common/engine/IReport"; import { dirname, join, resolve as pathResolve } from "path"; import { BaselineManager, RefactorMap } from "./common/report/BaselineManager"; @@ -372,7 +372,7 @@ async function getComplianceHelperWebDriverIO(label, parsed, curPol) : Promise { - let counts = { + let counts: EngineSummaryCounts = { violation: 0, potentialviolation: 0, recommendation: 0, @@ -475,7 +475,7 @@ async function getComplianceHelperPuppeteer(label, parsed, curPol) : Promise { - let counts = { + let counts: EngineSummaryCounts = { violation: 0, potentialviolation: 0, recommendation: 0, @@ -573,7 +573,7 @@ async function getComplianceHelperLocal(label, parsed, curPol) : Promise { - let counts = { + let counts: EngineSummaryCounts = { violation: 0, potentialviolation: 0, recommendation: 0, diff --git a/common/module/src/engine/IReport.ts b/common/module/src/engine/IReport.ts index 1da743258..b36abbbc3 100644 --- a/common/module/src/engine/IReport.ts +++ b/common/module/src/engine/IReport.ts @@ -67,7 +67,7 @@ export type IEngineReport = { } }, summary?: { - counts?: SummaryCounts + counts?: EngineSummaryCounts } } @@ -79,6 +79,15 @@ export type IBaselineResult = IEngineResult & { level: eRuleLevel } +export type EngineSummaryCounts = { + violation: number, + potentialviolation: number, + recommendation: number, + potentialrecommendation: number, + manual: number, + pass: number +} + export type SummaryCounts = { violation: number, potentialviolation: number, From a957835a74d1290f2e12ab5eaf537d7d1966eec2 Mon Sep 17 00:00:00 2001 From: Tom Brunet Date: Fri, 23 Aug 2024 19:33:41 -0500 Subject: [PATCH 6/7] init counts --- common/module/src/report/ReporterManager.ts | 6 ++++-- karma-accessibility-checker/src/lib/ReporterManager.js | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/common/module/src/report/ReporterManager.ts b/common/module/src/report/ReporterManager.ts index d2da3aa29..d914e27f9 100644 --- a/common/module/src/report/ReporterManager.ts +++ b/common/module/src/report/ReporterManager.ts @@ -378,8 +378,10 @@ export class ReporterManager { } }); - (retVal as any).summary = {}; - retVal.summary.counts = ReporterManager.addCounts(engineResult as any); + (retVal as any).summary = { + counts: engineResult.summary.counts + }; + retVal.summary.counts = ReporterManager.addCounts(retVal); retVal.results = retVal.results.filter(pageResult => { if (ReporterManager.config.reportLevels.includes(pageResult.level)) { diff --git a/karma-accessibility-checker/src/lib/ReporterManager.js b/karma-accessibility-checker/src/lib/ReporterManager.js index ac55612be..14daa7235 100644 --- a/karma-accessibility-checker/src/lib/ReporterManager.js +++ b/karma-accessibility-checker/src/lib/ReporterManager.js @@ -141,7 +141,9 @@ class ReporterManager { } }); - retVal.summary = {}; + retVal.summary = { + counts: retVal.summary.counts + }; retVal.summary.counts = ReporterManager.addCounts(retVal); retVal.results = retVal.results.filter(pageResult => { From 19f9112fe032652a4f7a0fa95a145096e2d0e2d4 Mon Sep 17 00:00:00 2001 From: Tom Brunet Date: Fri, 23 Aug 2024 19:38:21 -0500 Subject: [PATCH 7/7] fix count --- cypress-accessibility-checker/src/lib/ACCommands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress-accessibility-checker/src/lib/ACCommands.js b/cypress-accessibility-checker/src/lib/ACCommands.js index f1d715121..ced1ae95c 100644 --- a/cypress-accessibility-checker/src/lib/ACCommands.js +++ b/cypress-accessibility-checker/src/lib/ACCommands.js @@ -52,7 +52,7 @@ function getCounts(engineReport) { manual: 0 } for (const issue of engineReport.results) { - elementSet.add(issue.path.dom); + ++counts[issue.level]; } return counts; }