Skip to content

send data to api #357

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 1 commit into from
Mar 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 35 additions & 5 deletions accessibility/scanner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,50 @@ async function processAccessibilityReport(url) {
needsReview: needsReviewValue
};

console.log('log', "Payload to send: for url: ", payloadToSend,url);
console.log('log', "SET SCAN: Payload to send: for url: ", payloadToSend,url);
try {
let setResult = await setScanConfig(currentWindow, payloadToSend);
console.log('SET SCAN response:', setResult);
console.log('SET SCAN: response:', setResult);
} catch (err) {
console.error("Error while setting scan", err);
console.error("SET SCAN: Error while setting scan", err);
return ;
}

let scanData;
try {
const payload = {message: 'GET_LATEST_SCAN_DATA'};
scanData = await getScanData(currentWindow, payload);
LambdatestLog("LambdaTest Accessibility: Scanning URL");
LambdatestLog("GET SCAN:LambdaTest Accessibility: Scanning URL");
} catch (err) {
console.error("GET SCAN:Error while setting scan", err);
return ;
}

console.log("Logging response before sending to API:", scanData);

try {
const response = await fetch("http://127.0.0.1:43000/cypress/v1/generateAccessibilityReport", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
url: url,
scanData: scanData
})
});

if (!response.ok) {
console.log("HTTP error! Status", response.status);
return ;
}

const result = await response.json();
console.log("Accessibility Report Response:", result);
}catch(err) {
console.error("Error while making api", err);
}

} catch (error) {
LambdatestLog("ERROR", error);
}
Expand All @@ -115,4 +140,9 @@ commandsToOverride.forEach((command) => {
})

});
});
});

// AI:
// mutliple it()
// make error in set scan & get scan and ensure it doesnt break flow
// virgin media repo run rishabh singh (hyperex)