Skip to content

Commit a82c4ae

Browse files
authored
Merge pull request #340 from LambdaTest/dev
Release 21 oct
2 parents 54fe51f + 449a1a4 commit a82c4ae

File tree

3 files changed

+78
-4
lines changed

3 files changed

+78
-4
lines changed

accessibility/scanner/index.js

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const fs = require("fs")
21

32
const LambdatestLog = (message) => {
43
if (!Cypress.env('LAMBDATEST_LOGS')) return;
@@ -93,6 +92,8 @@ cy.window().then((win) => {
9392
bestPractice: bestPracticeValue,
9493
needsReview: needsReviewValue
9594
}
95+
96+
console.log('log', "payload to send " + payloadToSend);
9697
let testId = Cypress.env("TEST_ID") || ""
9798

9899
const filePath = Cypress.env("ACCESSIBILITY_REPORT_PATH") || 'cypress/results/accessibilityReport_' + testId + '.json';
@@ -143,4 +144,77 @@ cy.window().then((win) => {
143144
Cypress.on('command:end', (command) => {
144145

145146
return;
147+
})
148+
149+
150+
afterEach(() => {
151+
console.log("after each hook")
152+
cy.window().then((win) => {
153+
let wcagCriteriaValue = Cypress.env("WCAG_CRITERIA") || "wcag21a";
154+
let bestPracticeValue = Cypress.env("BEST_PRACTICE") || false;
155+
let needsReviewValue = Cypress.env("NEEDS_REVIEW") || false;
156+
157+
bestPracticeValue = bestPracticeValue == "true" ? true : false;
158+
needsReviewValue = needsReviewValue == "true" ? true : false;
159+
160+
let isAccessibilityLoaded = Cypress.env("ACCESSIBILITY") || false;
161+
if (!isAccessibilityLoaded){
162+
console.log('log', "accessibility not enabled " + isAccessibilityLoaded);
163+
return;
164+
}
165+
166+
const payloadToSend = {
167+
message: 'SET_CONFIG',
168+
wcagCriteria: wcagCriteriaValue,
169+
bestPractice: bestPracticeValue,
170+
needsReview: needsReviewValue
171+
}
172+
173+
console.log('log', "payload to send " + payloadToSend);
174+
let testId = Cypress.env("TEST_ID") || ""
175+
176+
const filePath = Cypress.env("ACCESSIBILITY_REPORT_PATH") || 'cypress/results/accessibilityReport_' + testId + '.json';
177+
178+
cy.wrap(setScanConfig(win, payloadToSend), {timeout: 30000}).then((res) => {
179+
console.log('logging config reponse', res);
180+
181+
const payload = {
182+
message: 'GET_LATEST_SCAN_DATA',
183+
}
184+
185+
cy.wrap(getScanData(win, payload), {timeout: 45000}).then((res) => {
186+
LambdatestLog('log', "scanning data ");
187+
188+
189+
cy.task('initializeFile', filePath).then((filePath) => {
190+
cy.readFile(filePath, { log: true, timeout: 45000 }).then((fileContent) => {
191+
let resultsArray = [{}];
192+
console.log('logging report', res);
193+
// If the file is not empty, parse the existing content
194+
if (fileContent) {
195+
try {
196+
resultsArray = JSON.parse(JSON.stringify(fileContent));
197+
} catch (e) {
198+
console.log("parsing error for content " , fileContent)
199+
console.log('Error parsing JSON file:', e);
200+
return;
201+
}
202+
}
203+
console.log('scanned data recieved is', res.message);
204+
if (res.message == "GET_LATEST_SCAN_DATA") {
205+
// Append the new result
206+
resultsArray.push(res);
207+
console.log('resultsarray logging', resultsArray);
208+
}
209+
210+
// Write the updated content back to the file
211+
cy.writeFile(filePath, resultsArray, { log: true, timeout: 45000 });
212+
});
213+
});
214+
});
215+
216+
});
217+
})
218+
219+
146220
})

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lambdatest-cypress-cli",
3-
"version": "3.0.32",
3+
"version": "3.0.33",
44
"description": "The lambdatest-cypress-cli is LambdaTest's command-line interface (CLI) aimed to help you run your Cypress tests on LambdaTest platform.",
55
"homepage": "https://github.com/LambdaTest/lambdatest-cypress-cli",
66
"author": "LambdaTest <keys@lambdatest.com>",

0 commit comments

Comments
 (0)