From cdc36fa242955784a45a97e510c65fd16f4af92d Mon Sep 17 00:00:00 2001 From: Shunguo Date: Fri, 20 Oct 2023 15:17:40 -0500 Subject: [PATCH] update the webdriver test file #1676 --- accessibility-checker/.achecker.yml | 1 - accessibility-checker/src-ts/lib/ACHelper.ts | 4 ++-- .../test/webdriverio/test/specs/example.e2e.ts | 14 +++++++------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/accessibility-checker/.achecker.yml b/accessibility-checker/.achecker.yml index e2465fd35..ba8a55c75 100644 --- a/accessibility-checker/.achecker.yml +++ b/accessibility-checker/.achecker.yml @@ -13,7 +13,6 @@ ignoreHTTPSErrors: true # We are setting no policies because we want the unit test to run for all policies policies: - IBM_Accessibility - - WCAG_2_2 # optional - Specify one or many violation levels on which to fail the test # i.e. If specified violation then the testcase will only fail if diff --git a/accessibility-checker/src-ts/lib/ACHelper.ts b/accessibility-checker/src-ts/lib/ACHelper.ts index 2c63db56e..ab1cd9ce3 100644 --- a/accessibility-checker/src-ts/lib/ACHelper.ts +++ b/accessibility-checker/src-ts/lib/ACHelper.ts @@ -55,7 +55,7 @@ class MyFS implements IAbstractAPI { async function initialize() { if (Config) return; - Config = await ACConfigManager.getConfigUnsupported(); console.log("Config=" + JSON.stringify(Config)); + Config = await ACConfigManager.getConfigUnsupported(); await ACEngineManager.loadEngineLocal(); let absAPI = new MyFS(); let refactorMap : RefactorMap = {} @@ -287,7 +287,7 @@ cb(e); async function getComplianceHelperWebDriverIO(label, parsed, curPol) : Promise { - try { console.log("label="+label +", curPol=" + JSON.stringify(curPol)); + try { const startScan = Date.now(); // NOTE: Engine should already be loaded const page = parsed; diff --git a/accessibility-checker/test/webdriverio/test/specs/example.e2e.ts b/accessibility-checker/test/webdriverio/test/specs/example.e2e.ts index a5e80e294..0f317c2d8 100644 --- a/accessibility-checker/test/webdriverio/test/specs/example.e2e.ts +++ b/accessibility-checker/test/webdriverio/test/specs/example.e2e.ts @@ -28,7 +28,7 @@ before(async function () { policyMap[policy] = true; }); - let rulesets = checker.rulesets; console.log("rulesets=" +JSON.stringify(rulesets)); + let rulesets = checker.rulesets; rulesets.forEach(function (rs) { if (rs.id in policyMap) { for (const cp of rs.checkpoints) { @@ -39,7 +39,7 @@ before(async function () { } }); }); -console.log("validList=" +JSON.stringify(validList)); console.log("policyMap=" +JSON.stringify(policyMap)); + after(async () => { // await browser.close(); }) @@ -93,9 +93,9 @@ describe("Rule Unit Tests from WebdriverIO", function () { var originalTimeout; // let count = 10; // Loop over all the unitTestcase html/htm files and perform a scan for them - for (var unitTestFile in unitTestcaseHTML) { if (!unitTestFile.includes("element_overlaid_visible_zindex")) continue; + for (var unitTestFile in unitTestcaseHTML) { if (unitTestFile in skipMap) continue; - console.log("unitTestFile=" + unitTestFile); + console.log(unitTestFile); // if (count-- < 0) continue; // Get the extension of the file we are about to scan var fileExtension = unitTestFile.substr(unitTestFile.lastIndexOf('.') + 1); @@ -129,7 +129,7 @@ describe("Rule Unit Tests from WebdriverIO", function () { console.error("\nWas unable to scan: " + unitTestFile); return Promise.reject(e); } } - report = result.report; console.log("report=" + JSON.stringify(report)); + report = result.report; let unitTestInfo = await browser.execute(() => ({ legacyExpectedInfo: (typeof ((window as any).OpenAjax) !== 'undefined' && (window as any).OpenAjax && (window as any).OpenAjax.a11y && (window as any).OpenAjax.a11y.ruleCoverage), expectedInfo: (typeof ((window as any).UnitTest) !== 'undefined' && (window as any).UnitTest) @@ -138,7 +138,7 @@ describe("Rule Unit Tests from WebdriverIO", function () { // Extract the ruleCoverage object from the unit testcases that is loaded on to the iframe. let expectedInfo = unitTestInfo.expectedInfo; let legacyExpectedInfo = unitTestInfo.legacyExpectedInfo; - console.log('expectedInfo=' + JSON.stringify(expectedInfo) + ', legacyExpectedInfo=' + legacyExpectedInfo); + if (expectedInfo && expectedInfo.ruleIds) { let filtReport = []; for (const issue of report.results) { @@ -165,7 +165,7 @@ describe("Rule Unit Tests from WebdriverIO", function () { if (pc !== 0) return pc; return b.ruleId.localeCompare(a.ruleId); }) - console.log("filtReport=" + JSON.stringify(filtReport)); + expect(filtReport).toEqual(expectedInfo.results); } else if (legacyExpectedInfo) { let expectedInfo = {}