-
Notifications
You must be signed in to change notification settings - Fork 40
Fix: Double Ally testcase save calls #988
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
base: master
Are you sure you want to change the base?
Changes from 50 commits
d54c407
b3d79f8
fc985b7
e45f782
9214805
1bd74d2
136c2fe
8fa469d
2aa6f71
dfa60aa
f922241
58dde04
5c9ff21
7db800c
7087439
9d6500a
e1ef09d
0f7ca3c
c0769c3
967684b
42273d0
5d82249
dc92b92
689ad31
1e6b4b3
b12a7c3
906f64d
3ed07f5
fd7617e
3af740b
d90ac44
f1edd41
7780635
9beab9c
8dec92b
79e9b25
5bf215a
19e2bd6
902ec25
4420f3e
6d08175
532d703
048cfd6
785cf0f
89d19a9
654cf99
e90b4ed
97479cb
f740346
d14f0a1
0d1bfc3
4c4bea5
c74ec20
5d05d23
8dc5393
bdd00fe
62f8310
d9ff28f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,13 +15,14 @@ | |
exports.checkAccessibilityPlatform = (user_config) => { | ||
let accessibility = false; | ||
try { | ||
|
||
user_config.browsers.forEach(browser => { | ||
if (browser.accessibility) { | ||
accessibility = true; | ||
} | ||
}) | ||
} catch {} | ||
|
||
return accessibility; | ||
} | ||
|
||
|
@@ -34,6 +35,7 @@ | |
user_config.run_settings.accessibilityOptions["scannerVersion"] = accessibilityResponse.data.scannerVersion; | ||
user_config.run_settings.system_env_vars.push(`ACCESSIBILITY_AUTH=${accessibilityResponse.data.accessibilityToken}`) | ||
user_config.run_settings.system_env_vars.push(`ACCESSIBILITY_SCANNERVERSION=${accessibilityResponse.data.scannerVersion}`) | ||
|
||
} | ||
|
||
exports.isAccessibilitySupportedCypressVersion = (cypress_config_filename) => { | ||
|
@@ -44,6 +46,7 @@ | |
exports.createAccessibilityTestRun = async (user_config, framework) => { | ||
|
||
try { | ||
|
||
if (!this.isAccessibilitySupportedCypressVersion(user_config.run_settings.cypress_config_file) ){ | ||
logger.warn(`Accessibility Testing is not supported on Cypress version 9 and below.`) | ||
process.env.BROWSERSTACK_TEST_ACCESSIBILITY = 'false'; | ||
|
@@ -99,6 +102,7 @@ | |
const response = await nodeRequest( | ||
'POST', 'v2/test_runs', data, config, API_URL | ||
); | ||
|
||
if(!utils.isUndefined(response.data)) { | ||
process.env.BS_A11Y_JWT = response.data.data.accessibilityToken; | ||
process.env.BS_A11Y_TEST_RUN_ID = response.data.data.id; | ||
|
@@ -113,35 +117,33 @@ | |
|
||
} catch (error) { | ||
if (error.response) { | ||
logger.error("Incorrect Cred") | ||
logger.error("Incorrect Cred"); | ||
logger.error( | ||
`Exception while creating test run for BrowserStack Accessibility Automation: ${ | ||
error.response.status | ||
} ${error.response.statusText} ${JSON.stringify(error.response.data)}` | ||
} ${error.response.statusText} ${JSON.stringify(error.response.data)} | ||
` | ||
); | ||
} else { | ||
if(error.message === 'Invalid configuration passed.') { | ||
logger.error("Invalid configuration passed.") | ||
logger.error( | ||
`Exception while creating test run for BrowserStack Accessibility Automation: ${ | ||
error.message || error.stack | ||
}` | ||
); | ||
for(const errorkey of error.errors){ | ||
logger.error(errorkey.message); | ||
} | ||
|
||
} else { | ||
logger.error( | ||
`Exception while creating test run for BrowserStack Accessibility Automation: ${ | ||
error.message || error.stack | ||
}` | ||
); | ||
} else if (error.message === 'Invalid configuration passed.') { | ||
logger.error("Invalid configuration passed."); | ||
logger.error( | ||
`Exception while creating test run for BrowserStack Accessibility Automation: ${ | ||
error.message || error.stack | ||
}` | ||
); | ||
for (const errorkey of error.errors) { | ||
logger.error(errorkey.message); | ||
} | ||
// since create accessibility session failed | ||
process.env.BROWSERSTACK_TEST_ACCESSIBILITY = 'false'; | ||
user_config.run_settings.accessibility = false; | ||
} else { | ||
logger.error( | ||
`Exception while creating test run for BrowserStack Accessibility Automation: ${ | ||
error.message || error.stack | ||
}` | ||
); | ||
} | ||
// since create accessibility session failed | ||
process.env.BROWSERSTACK_TEST_ACCESSIBILITY = 'false'; | ||
user_config.run_settings.accessibility = false; | ||
} | ||
} | ||
|
||
|
@@ -216,22 +218,56 @@ | |
|
||
exports.setAccessibilityEventListeners = (bsConfig) => { | ||
try { | ||
// Searching form command.js recursively | ||
|
||
const supportFilesData = helper.getSupportFiles(bsConfig, true); | ||
if(!supportFilesData.supportFile) return; | ||
glob(process.cwd() + supportFilesData.supportFile, {}, (err, files) => { | ||
if(err) return logger.debug('EXCEPTION IN BUILD START EVENT : Unable to parse cypress support files'); | ||
|
||
const isPattern = glob.hasMagic(supportFilesData.supportFile); | ||
if(!isPattern) { | ||
console.log(`Using user defined support file: ${supportFilesData.supportFile}`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this to logger. |
||
try { | ||
file = process.cwd() + supportFilesData.supportFile; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should you check whether supportfile is absolute/relative path? If we are always getting an absolute path why do we cwd to be added to it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test it windows + mac, locally. |
||
const defaultFileContent = fs.readFileSync(file, {encoding: 'utf-8'}); | ||
let cypressCommandEventListener = getAccessibilityCypressCommandEventListener(path.extname(file)); | ||
const alreadyIncludes = defaultFileContent.includes(cypressCommandEventListener); | ||
if(!alreadyIncludes) { | ||
let newFileContent = defaultFileContent + | ||
'\n' + | ||
cypressCommandEventListener + | ||
'\n'; | ||
fs.writeFileSync(file, newFileContent, {encoding: 'utf-8'}); | ||
supportFileContentMap[file] = supportFilesData.cleanupParams ? supportFilesData.cleanupParams : defaultFileContent; | ||
} | ||
} catch(e) { | ||
logger.debug(`Unable to modify file contents for ${file} to set event listeners with error ${e}`, true, e); | ||
} | ||
} | ||
|
||
// Build the correct glob pattern | ||
const cwd_path = process.cwd(); | ||
const globPattern = supportFilesData.supportFile.startsWith('/') | ||
? cwd_path + supportFilesData.supportFile | ||
: path.resolve(cwd_path,supportFilesData.supportFile); | ||
|
||
|
||
glob(globPattern, {}, (err, files) => { | ||
if(err) { | ||
logger.debug('EXCEPTION IN BUILD START EVENT : Unable to parse cypress support files'); | ||
return; | ||
} | ||
|
||
files.forEach(file => { | ||
try { | ||
if(!file.includes('commands.js') && !file.includes('commands.ts')) { | ||
const fileName = path.basename(file); | ||
if(['e2e.js', 'e2e.ts', 'component.ts', 'component.js'].includes(fileName) && !file.includes('node_modules')) { | ||
|
||
const defaultFileContent = fs.readFileSync(file, {encoding: 'utf-8'}); | ||
|
||
let cypressCommandEventListener = getAccessibilityCypressCommandEventListener(path.extname(file)); | ||
|
||
if(!defaultFileContent.includes(cypressCommandEventListener)) { | ||
let newFileContent = defaultFileContent + | ||
let newFileContent = defaultFileContent + | ||
'\n' + | ||
cypressCommandEventListener + | ||
'\n' | ||
'\n'; | ||
fs.writeFileSync(file, newFileContent, {encoding: 'utf-8'}); | ||
supportFileContentMap[file] = supportFilesData.cleanupParams ? supportFilesData.cleanupParams : defaultFileContent; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain the changes done as part of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@karanshah-browserstack this is to check if the returned supportFile is a single file path or a glob pattern cause if it's a single path then user has explicitly passed in their cypress config and plugins should be added to only that file .If glob pattern is present which we return by default and then that needs to be treated with a loop.