@@ -12,39 +12,31 @@ const commandsToOverride = [
1212
1313const commandsToWrap = [ 'visit' , 'click' , 'type' , 'request' , 'dblclick' , 'rightclick' , 'clear' , 'check' , 'uncheck' , 'select' , 'trigger' , 'selectFile' , 'scrollIntoView' , 'scroll' , 'scrollTo' , 'blur' , 'focus' , 'go' , 'reload' , 'submit' , 'viewport' , 'origin' ] ;
1414
15- const performModifiedScan = ( originalFn , Subject , stateType , ...args ) => {
16- let customChaining = cy . wrap ( null ) . processAccessibilityReport ( ) ;
17- const updateSubj = ( args , stateType , newSubject ) =>
18- stateType === 'parent' ? args : [ newSubject , ...args . slice ( 1 ) ] ;
19-
20- const runCustomizedChainingCommand = ( ) => {
15+ const performNewLambdaScan = ( originalFn , Subject , stateType , ...args ) => {
16+ let customChainingCypressCommands = cy . wrap ( null ) . processAccessibilityReport ( ) ;
17+ const updateSub = ( args , stateType , newSubject ) => {
18+ return stateType !== 'parent' ? [ newSubject , ...args . slice ( 1 ) ] : args ;
19+ }
20+ const runCustomizedLambdaChainingCommand = ( ) => {
2121 if ( ! Subject ) {
22- let cypressCommandSubject = null ;
23- const subjectFn = cy && cy . subject ;
24- if ( subjectFn !== null && subjectFn !== void 0 ) {
25- cypressCommandSubject = subjectFn . call ( cy ) ;
22+ let origSubject1 , origSubject2 , cyCommandSubject = null ;
23+ if ( ( origSubject2 = ( origSubject1 = cy ) . subject ) !== null && origSubject2 !== void 0 ) {
24+ cyCommandSubject = origSubject2 . call ( origSubject1 ) ;
2625 }
27-
28- customChaining
29- . then ( ( ) => cypressCommandSubject )
30- . then ( ( ) => {
31- originalFn ( ...args ) ;
32- } ) ;
26+ customChainingCypressCommands . then ( ( ) => cyCommandSubject ) . then ( ( ) => { originalFn ( ...args ) ; } ) ;
3327 } else {
34- let cypressCommandChain = null , setTimeout = null ;
35- // Extract timeout value if present
36- const timeoutArg = args . find ( arg => arg !== null && arg !== void 0 ? arg . timeout : null ) ;
37- if ( timeoutArg !== null && timeoutArg !== void 0 ) {
38- setTimeout = timeoutArg . timeout ;
28+ let origChain1 , origChain2 , timeoutObj , cyCommandChain = null , setDelay = null ;
29+ if ( ( timeoutObj = args . find ( arg => arg !== null && arg !== void 0 ? arg . timeout : null ) ) !== null && timeoutObj !== void 0 ) {
30+ setDelay = timeoutObj . timeout ;
3931 }
40- const subjectChainFn = cy && cy . subjectChain ;
41- if ( subjectChainFn !== null && subjectChainFn !== void 0 ) {
42- cypressCommandChain = subjectChainFn . call ( cy ) ;
32+ if ( ( origChain1 = ( origChain2 = cy ) . subjectChain ) !== null && origChain1 !== void 0 ) {
33+ cyCommandChain = origChain1 . call ( origChain2 ) ;
4334 }
44- customChaining . performScanSubjectQuery ( cypressCommandChain , setTimeout ) . then ( { timeout : 30000 } , ( newSubject ) => originalFn ( ...updateSubj ( args , stateType , newSubject ) ) ) ;
35+ customChainingCypressCommands . performScanSubjectQuery ( cyCommandChain , setDelay )
36+ . then ( { timeout : 30000 } , ( newSubject ) => originalFn ( ...updateSub ( args , stateType , newSubject ) ) ) ;
4537 }
4638 }
47- runCustomizedChainingCommand ( ) ;
39+ runCustomizedLambdaChainingCommand ( ) ;
4840}
4941
5042Cypress . Commands . add ( 'processAccessibilityReport' , ( ) => {
@@ -266,7 +258,7 @@ if (overRideCommands) {
266258 if ( state !== null && state !== void 0 ) {
267259 stateType = state . get ( 'type' ) ;
268260 }
269- performModifiedScan ( originalFn , Subject , stateType , ...args ) ;
261+ performNewLambdaScan ( originalFn , Subject , stateType , ...args ) ;
270262
271263 } ) ;
272264 } ) ;
0 commit comments