Skip to content

Release 21 oct #340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Oct 21, 2024
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