From 573a5e9b839bcf6c23f188d9ff80b0a4b81fd009 Mon Sep 17 00:00:00 2001 From: Himanshu Ranjan Date: Thu, 22 Aug 2024 18:40:21 +0530 Subject: [PATCH 1/6] badeball test --- accessibility/scanner/index.js | 68 +++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/accessibility/scanner/index.js b/accessibility/scanner/index.js index ab67ee4..f85d8f2 100644 --- a/accessibility/scanner/index.js +++ b/accessibility/scanner/index.js @@ -84,7 +84,7 @@ console.log('log', "debugging scan form command " + command.attributes.name); cy.window().then((win) => { let wcagCriteriaValue = Cypress.env("WCAG_CRITERIA") || "wcag21a"; let bestPracticeValue = Cypress.env("BEST_PRACTICE") || false; - let needsReviewValue = Cypress.env("NEEDS_REVIEW") || true; + let needsReviewValue = Cypress.env("NEEDS_REVIEW") || false; const payloadToSend = { message: 'SET_CONFIG', @@ -92,6 +92,8 @@ cy.window().then((win) => { bestPractice: bestPracticeValue, needsReview: needsReviewValue } + + console.log('log', "payload to send " + payloadToSend); let testId = Cypress.env("TEST_ID") || "" const filePath = Cypress.env("ACCESSIBILITY_REPORT_PATH") || 'cypress/results/accessibilityReport_' + testId + '.json'; @@ -142,4 +144,68 @@ cy.window().then((win) => { Cypress.on('command:end', (command) => { return; +}) + + +afterEach(() => { +console.log("after each hook") + cy.window().then((win) => { + let wcagCriteriaValue = Cypress.env("WCAG_CRITERIA") || "wcag21a"; + let bestPracticeValue = Cypress.env("BEST_PRACTICE") || false; + let needsReviewValue = Cypress.env("NEEDS_REVIEW") || false; + + const payloadToSend = { + message: 'SET_CONFIG', + wcagCriteria: wcagCriteriaValue, + bestPractice: bestPracticeValue, + needsReview: needsReviewValue + } + + console.log('log', "payload to send " + payloadToSend); + let testId = Cypress.env("TEST_ID") || "" + + const filePath = Cypress.env("ACCESSIBILITY_REPORT_PATH") || 'cypress/results/accessibilityReport_' + testId + '.json'; + + cy.wrap(setScanConfig(win, payloadToSend), {timeout: 30000}).then((res) => { + console.log('logging config reponse', res); + + const payload = { + message: 'GET_LATEST_SCAN_DATA', + } + + cy.wrap(getScanData(win, payload), {timeout: 45000}).then((res) => { + LambdatestLog('log', "scanning data "); + + + cy.task('initializeFile', filePath).then((filePath) => { + cy.readFile(filePath, { log: true, timeout: 45000 }).then((fileContent) => { + let resultsArray = [{}]; + console.log('logging report', res); + // If the file is not empty, parse the existing content + if (fileContent) { + try { + resultsArray = JSON.parse(JSON.stringify(fileContent)); + } catch (e) { + console.log("parsing error for content " , fileContent) + console.log('Error parsing JSON file:', e); + return; + } + } + console.log('scanned data recieved is', res.message); + if (res.message == "GET_LATEST_SCAN_DATA") { + // Append the new result + resultsArray.push(res); + console.log('resultsarray logging', resultsArray); + } + + // Write the updated content back to the file + cy.writeFile(filePath, resultsArray, { log: true, timeout: 45000 }); + }); + }); + }); + + }); +}) + + }) \ No newline at end of file From 8fba856d009a44e3d2e87818bd15f5b95feaa8e1 Mon Sep 17 00:00:00 2001 From: Himanshu Ranjan Date: Fri, 23 Aug 2024 15:53:05 +0530 Subject: [PATCH 2/6] removed unused fs --- accessibility/scanner/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/accessibility/scanner/index.js b/accessibility/scanner/index.js index f85d8f2..6d86b2e 100644 --- a/accessibility/scanner/index.js +++ b/accessibility/scanner/index.js @@ -1,4 +1,3 @@ -const fs = require("fs") const LambdatestLog = (message) => { if (!Cypress.env('LAMBDATEST_LOGS')) return; From e74080ee328b578ec3ac74b4aeb40c9a68575996 Mon Sep 17 00:00:00 2001 From: Himanshu Ranjan Date: Fri, 23 Aug 2024 21:32:48 +0530 Subject: [PATCH 3/6] supporting edge --- accessibility/plugin/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/accessibility/plugin/index.js b/accessibility/plugin/index.js index f87ee83..097f98e 100644 --- a/accessibility/plugin/index.js +++ b/accessibility/plugin/index.js @@ -24,8 +24,8 @@ const Accessibility = (on, config) => { on('before:browser:launch', (browser = {}, launchOptions) => { try { if (process.env.ACCESSIBILITY_EXTENSION_PATH !== undefined) { - if (browser.name !== 'chrome') { - console.log(`Accessibility Automation will run only on Chrome browsers.`); + if (browser.name !== 'chrome' && browser.name !== 'edge') { + console.log(`Accessibility Automation will run only on Chrome browsers. But browser run on ` + browser.name); browser_validation = false; } if (browser.name === 'chrome' && browser.majorVersion <= 94) { From 2c074b0bc83ec6361aea82cfedbb8dfa6904551b Mon Sep 17 00:00:00 2001 From: Himanshu Ranjan Date: Fri, 23 Aug 2024 22:32:54 +0530 Subject: [PATCH 4/6] added log --- accessibility/plugin/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accessibility/plugin/index.js b/accessibility/plugin/index.js index 097f98e..35dede7 100644 --- a/accessibility/plugin/index.js +++ b/accessibility/plugin/index.js @@ -25,7 +25,7 @@ const Accessibility = (on, config) => { try { if (process.env.ACCESSIBILITY_EXTENSION_PATH !== undefined) { if (browser.name !== 'chrome' && browser.name !== 'edge') { - console.log(`Accessibility Automation will run only on Chrome browsers. But browser run on ` + browser.name); + console.log(`Accessibility Automation will run only on Chrome and Edge browsers. But browser used is ` + browser.name); browser_validation = false; } if (browser.name === 'chrome' && browser.majorVersion <= 94) { From 2ac34155832c24c6e5f3fbba575999c194d11a0d Mon Sep 17 00:00:00 2001 From: Himanshu Ranjan Date: Tue, 8 Oct 2024 03:35:27 +0530 Subject: [PATCH 5/6] added flag for accessiblity --- accessibility/scanner/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/accessibility/scanner/index.js b/accessibility/scanner/index.js index 6d86b2e..61fac1d 100644 --- a/accessibility/scanner/index.js +++ b/accessibility/scanner/index.js @@ -84,6 +84,9 @@ cy.window().then((win) => { let wcagCriteriaValue = Cypress.env("WCAG_CRITERIA") || "wcag21a"; let bestPracticeValue = Cypress.env("BEST_PRACTICE") || false; let needsReviewValue = Cypress.env("NEEDS_REVIEW") || false; + + bestPracticeValue = bestPracticeValue == "true" ? true : false; + needsReviewValue = needsReviewValue == "true" ? true : false; const payloadToSend = { message: 'SET_CONFIG', @@ -152,6 +155,15 @@ console.log("after each hook") let wcagCriteriaValue = Cypress.env("WCAG_CRITERIA") || "wcag21a"; let bestPracticeValue = Cypress.env("BEST_PRACTICE") || false; let needsReviewValue = Cypress.env("NEEDS_REVIEW") || false; + + bestPracticeValue = bestPracticeValue == "true" ? true : false; + needsReviewValue = needsReviewValue == "true" ? true : false; + + let isAccessibilityLoaded = Cypress.env("ACCESSIBILITY") || false; + if (!isAccessibilityLoaded){ + console.log('log', "accessibility not enabled " + isAccessibilityLoaded); + return; + } const payloadToSend = { message: 'SET_CONFIG', From f9bb11b306551975925061236c1a52189e54e57f Mon Sep 17 00:00:00 2001 From: Himanshu Ranjan Date: Thu, 17 Oct 2024 16:10:41 +0530 Subject: [PATCH 6/6] bumped version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 797f87f..953ebec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "lambdatest-cypress-cli", - "version": "3.0.32", + "version": "3.0.33", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "lambdatest-cypress-cli", - "version": "3.0.32", + "version": "3.0.33", "license": "MIT", "dependencies": { "@lambdatest/node-tunnel": "latest", diff --git a/package.json b/package.json index ab4a2db..84dd5c0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lambdatest-cypress-cli", - "version": "3.0.32", + "version": "3.0.33", "description": "The lambdatest-cypress-cli is LambdaTest's command-line interface (CLI) aimed to help you run your Cypress tests on LambdaTest platform.", "homepage": "https://github.com/LambdaTest/lambdatest-cypress-cli", "author": "LambdaTest ",