Skip to content

Commit 3af740b

Browse files
committed
new 4 logs
1 parent fd7617e commit 3af740b

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

bin/accessibility-automation/helper.js

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -265,18 +265,35 @@ exports.setAccessibilityEventListeners = (bsConfig) => {
265265
browserStackLog(`Inside isPattern`);
266266

267267
try {
268-
const defaultFileContent = fs.readFileSync(supportFilesData.supportFile, {encoding: 'utf-8'});
269-
let cypressCommandEventListener = getAccessibilityCypressCommandEventListener(path.extname(supportFilesData.supportFile));
270-
271-
if(!defaultFileContent.includes(cypressCommandEventListener)) {
272-
let newFileContent = defaultFileContent +
273-
'\n' +
274-
cypressCommandEventListener +
275-
'\n';
276-
// Fixed: use supportFilesData.supportFile instead of undefined 'file'
277-
fs.writeFileSync(supportFilesData.supportFile, newFileContent, {encoding: 'utf-8'});
278-
supportFileContentMap[supportFilesData.supportFile] = supportFilesData.cleanupParams ? supportFilesData.cleanupParams : defaultFileContent;
279-
}
268+
const defaultFileContent = fs.readFileSync(file, {encoding: 'utf-8'});
269+
console.log(`log1`);
270+
sendData(`bstack-log1`);
271+
272+
let cypressCommandEventListener = getAccessibilityCypressCommandEventListener(path.extname(file));
273+
console.log(`log2`);
274+
sendData(`bstack-log2`);
275+
276+
// Add debugging to understand why the condition fails
277+
const alreadyIncludes = defaultFileContent.includes(cypressCommandEventListener);
278+
console.log(`File ${file} already includes accessibility listener: ${alreadyIncludes}`);
279+
console.log(`Looking for: ${cypressCommandEventListener}`);
280+
console.log(`In content (first 500 chars): ${defaultFileContent.substring(0, 500)}`);
281+
sendData(`bstack-already-includes-${alreadyIncludes}`);
282+
283+
if(!alreadyIncludes) {
284+
let newFileContent = defaultFileContent +
285+
'\n' +
286+
cypressCommandEventListener +
287+
'\n';
288+
fs.writeFileSync(file, newFileContent, {encoding: 'utf-8'});
289+
console.log(`log3`);
290+
browserStackLog(`bstack-log3`);
291+
sendData(`bstack-log3`);
292+
supportFileContentMap[file] = supportFilesData.cleanupParams ? supportFilesData.cleanupParams : defaultFileContent;
293+
} else {
294+
console.log(`Skipping ${file} - accessibility listener already present`);
295+
sendData(`bstack-skipped-${path.basename(file)}`);
296+
}
280297
} catch(error) {
281298
console.log(`>>> Unable to modify file contents for ${supportFilesData.supportFile} to set event listeners with error ${error}`);
282299
sendData(`BROKEN`);

0 commit comments

Comments
 (0)