Skip to content

Commit

Permalink
Merge pull request #340 from LambdaTest/dev
Browse files Browse the repository at this point in the history
Release 21 oct
  • Loading branch information
HRanjan-11 authored Oct 21, 2024
2 parents 54fe51f + 449a1a4 commit a82c4ae
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 4 deletions.
76 changes: 75 additions & 1 deletion accessibility/scanner/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const fs = require("fs")

const LambdatestLog = (message) => {
if (!Cypress.env('LAMBDATEST_LOGS')) return;
Expand Down Expand Up @@ -93,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';
Expand Down Expand Up @@ -143,4 +144,77 @@ 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;

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',
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 });
});
});
});

});
})


})
4 changes: 2 additions & 2 deletions 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": "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 <[email protected]>",
Expand Down

0 comments on commit a82c4ae

Please sign in to comment.