SDK-1884: Cypress SDK not wrapping A11Y commands appropriately#949
SDK-1884: Cypress SDK not wrapping A11Y commands appropriately#949pranavj1001 merged 9 commits intomasterfrom
Conversation
| } | ||
|
|
||
| const commandsToWrap = ['visit', 'click', 'type', 'request', 'dblclick', 'rightclick', 'clear', 'check', 'uncheck', 'select', 'trigger', 'selectFile', 'scrollIntoView', 'scroll', 'scrollTo', 'blur', 'focus', 'go', 'reload', 'submit', 'viewport', 'origin']; | ||
| const commandToOverwrite = ['visit', 'click', 'type', 'request', 'dblclick', 'rightclick', 'clear', 'check', 'uncheck', 'select', 'trigger', 'selectFile', 'scrollIntoView', 'scrollTo', 'blur', 'focus', 'go', 'reload', 'submit', 'viewport', 'origin']; |
There was a problem hiding this comment.
any reason for removing scroll from the list ?
There was a problem hiding this comment.
scroll is not a default cypress function. This error was occuring.
There was a problem hiding this comment.
is this verified across all supported cy versions ?
| } | ||
|
|
||
| function waitForScannerReadiness(retryCount = 30, retryInterval = 100) { | ||
| function waitForScannerReadiness(retryCount = 100, retryInterval = 100) { |
There was a problem hiding this comment.
Is retryCount number intentional ? Why 100 ?
There was a problem hiding this comment.
yes a11y team told to retry for 10 sec other framework have same count.
| cy.window().then(async (win) => { | ||
| browserStackLog(`Performing accessibility scan`); | ||
| await performScan(win); | ||
| cy.wrap(performScan(win), {timeout:40000}); |
There was a problem hiding this comment.
This sets timeout, which can break the test if mochaTimeout is less than 40s. should we also handle mocha timeout ?
There was a problem hiding this comment.
if the response from performScan take less time no timeout will occur. Eventually if response does not come and mocha timeout occurs it should be considered as timeout.
81e2cc9 to
48c4784
Compare
bin/helpers/utils.js
Outdated
| } | ||
| const header = JSON.parse(base64UrlDecode(parts[0])); | ||
| const payload = JSON.parse(base64UrlDecode(parts[1])); | ||
| return { header, payload }; |
There was a problem hiding this comment.
why to parse header if we are not using
There was a problem hiding this comment.
also let's not return it if not used
There was a problem hiding this comment.
i made it a generic function to get used in future if need headers
|
RUN_SCA |
| "Accessibility Automation Scanner is not ready on the page." | ||
| ) | ||
| ); | ||
| return; |
There was a problem hiding this comment.
shouldn't promise be resolved?
| function onScanComplete() { | ||
| win.removeEventListener("A11Y_SCAN_FINISHED", onScanComplete); | ||
| resolve(); | ||
| return; |
There was a problem hiding this comment.
shouldn't promise be resolved?
| .catch((err) => { | ||
| resolve(); | ||
| }); | ||
| return; |
There was a problem hiding this comment.
resolving do we need return?
| const ally_path = path.dirname(process.env.ACCESSIBILITY_EXTENSION_PATH) | ||
| const {_, payload} = decodeJWTToken(process.env.ACCESSIBILITY_AUTH); | ||
| launchOptions.extensions.push(ally_path); | ||
| if(!utils.isUndefined(payload) && !utils.isUndefined(payload.a11y_core_config) && payload.a11y_core_config.domForge === true) { |
There was a problem hiding this comment.
significance of these?
There was a problem hiding this comment.
other ticket SDK-1907
|
|
||
| const commandsToWrap = ['visit', 'click', 'type', 'request', 'dblclick', 'rightclick', 'clear', 'check', 'uncheck', 'select', 'trigger', 'selectFile', 'scrollIntoView', 'scroll', 'scrollTo', 'blur', 'focus', 'go', 'reload', 'submit', 'viewport', 'origin']; | ||
| const commandToOverwrite = ['visit', 'click', 'type', 'request', 'dblclick', 'rightclick', 'clear', 'check', 'uncheck', 'select', 'trigger', 'selectFile', 'scrollIntoView', 'scrollTo', 'blur', 'focus', 'go', 'reload', 'submit', 'viewport', 'origin']; | ||
| const performModifiedScan = (originalFn, Subject, stateType, ...args) => { |
There was a problem hiding this comment.
please add some comments explaining the below function for future ref
| function runCutomizedCommand() { | ||
| if (!Subject) { | ||
| let orgS1, orgS2, cypressCommandSubject; | ||
| if((orgS2 = (orgS1 = cy).subject) !==null && orgS2 !== void 0){ | ||
| cypressCommandSubject = orgS2.call(orgS1); | ||
| } | ||
| else{ | ||
| cypressCommandSubject = null; | ||
| } | ||
| customChaining.then(()=> cypressCommandSubject).then(() => {originalFn(...args)}); | ||
| } | ||
| else { | ||
| let orgSC1, orgSC2, timeO1, cypressCommandChain, setTimeout; | ||
| if((timeO1 = args.find(arg => arg !== null && arg !== void 0 ? arg.timeout : null)) !== null && timeO1 !== void 0) { | ||
| setTimeout = timeO1.timeout; | ||
| } | ||
| else { | ||
| setTimeout = null; | ||
| } | ||
| if((orgSC1 = (orgSC2 = cy).subjectChain) !== null && orgSC1 !== void 0){ | ||
| cypressCommandChain = orgSC1.call(orgSC2); | ||
| } | ||
| else { | ||
| cypressCommandChain = null; | ||
| } | ||
| customChaining.performScanSubjectQuery(cypressCommandChain, setTimeout).then({timeout: 30000}, (newSubject) => originalFn(...changeSub(args, stateType, newSubject))); |
There was a problem hiding this comment.
| function runCutomizedCommand() { | |
| if (!Subject) { | |
| let orgS1, orgS2, cypressCommandSubject; | |
| if((orgS2 = (orgS1 = cy).subject) !==null && orgS2 !== void 0){ | |
| cypressCommandSubject = orgS2.call(orgS1); | |
| } | |
| else{ | |
| cypressCommandSubject = null; | |
| } | |
| customChaining.then(()=> cypressCommandSubject).then(() => {originalFn(...args)}); | |
| } | |
| else { | |
| let orgSC1, orgSC2, timeO1, cypressCommandChain, setTimeout; | |
| if((timeO1 = args.find(arg => arg !== null && arg !== void 0 ? arg.timeout : null)) !== null && timeO1 !== void 0) { | |
| setTimeout = timeO1.timeout; | |
| } | |
| else { | |
| setTimeout = null; | |
| } | |
| if((orgSC1 = (orgSC2 = cy).subjectChain) !== null && orgSC1 !== void 0){ | |
| cypressCommandChain = orgSC1.call(orgSC2); | |
| } | |
| else { | |
| cypressCommandChain = null; | |
| } | |
| customChaining.performScanSubjectQuery(cypressCommandChain, setTimeout).then({timeout: 30000}, (newSubject) => originalFn(...changeSub(args, stateType, newSubject))); | |
| function runCutomizedCommand() { | |
| if (!Subject) { | |
| let cypressCommandSubject = (cy.subject?.call(cy)) ?? null; | |
| customChaining.then(() => cypressCommandSubject).then(() => { originalFn(...args); }); | |
| } else { | |
| let setTimeout = args.find(arg => arg?.timeout)?.timeout ?? null; | |
| let cypressCommandChain = (cy.subjectChain?.call(cy)) ?? null; | |
| customChaining.performScanSubjectQuery(cypressCommandChain, setTimeout).then({ timeout: 30000 }, newSubject => originalFn(...changeSub(args, stateType, newSubject))); | |
| } | |
| } |
The base branch was changed.
pranavj1001
left a comment
There was a problem hiding this comment.
Approved for base branch change
Uh oh!
There was an error while loading. Please reload this page.