@@ -13,32 +13,37 @@ const commandsToOverride = [
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
1515const performNewLambdaScan = ( originalFn , Subject , stateType , ...args ) => {
16- let customChaining = cy . wrap ( null ) . processAccessibilityReport ( ) ;
17- const changeSub = ( args , stateType , newSubject ) => {
18- if ( stateType !== 'parent' ) {
19- return [ newSubject , ...args . slice ( 1 ) ] ;
20- }
21- return args ;
22- }
23- const runCustomizedCommand = ( ) => {
16+ let cycustomChaining = cy . wrap ( null ) . processAccessibilityReport ( ) ;
17+ const updateSubj = ( args , stateType , newSubject ) =>
18+ stateType === 'parent' ? args : [ newSubject , ...args . slice ( 1 ) ] ;
19+
20+ const runCustomizedChainingCommand = ( ) => {
2421 if ( ! Subject ) {
25- let orgS1 , orgS2 , cypressCommandSubject = null ;
26- if ( ( orgS2 = ( orgS1 = cy ) . subject ) !== null && orgS2 !== void 0 ) {
27- cypressCommandSubject = orgS2 . call ( orgS1 ) ;
22+ let cypressCommandSubject = null ;
23+ const subjectFn = cy && cy . subject ;
24+ if ( subjectFn !== null && subjectFn !== void 0 ) {
25+ cypressCommandSubject = subjectFn . call ( cy ) ;
2826 }
29- customChaining . then ( ( ) => cypressCommandSubject ) . then ( ( ) => { originalFn ( ...args ) } ) ;
27+ cycustomChaining
28+ . then ( ( ) => cypressCommandSubject )
29+ . then ( ( ) => {
30+ originalFn ( ...args ) ;
31+ } ) ;
3032 } else {
31- let orgSC1 , orgSC2 , timeO1 , cypressCommandChain = null , setTimeout = null ;
32- if ( ( timeO1 = args . find ( arg => arg !== null && arg !== void 0 ? arg . timeout : null ) ) !== null && timeO1 !== void 0 ) {
33- setTimeout = timeO1 . timeout ;
33+ let cypressCommandChain = null , setTimeout = null ;
34+ // Extract timeout value if present
35+ const timeoutArg = args . find ( arg => arg !== null && arg !== void 0 ? arg . timeout : null ) ;
36+ if ( timeoutArg !== null && timeoutArg !== void 0 ) {
37+ setTimeout = timeoutArg . timeout ;
3438 }
35- if ( ( orgSC1 = ( orgSC2 = cy ) . subjectChain ) !== null && orgSC1 !== void 0 ) {
36- cypressCommandChain = orgSC1 . call ( orgSC2 ) ;
39+ const subjectChainFn = cy && cy . subjectChain ;
40+ if ( subjectChainFn !== null && subjectChainFn !== void 0 ) {
41+ cypressCommandChain = subjectChainFn . call ( cy ) ;
3742 }
38- customChaining . performScanSubjectQuery ( cypressCommandChain , setTimeout ) . then ( { timeout : 30000 } , ( newSubject ) => originalFn ( ...changeSub ( args , stateType , newSubject ) ) ) ;
43+ cycustomChaining . performScanSubjectQuery ( cypressCommandChain , setTimeout ) . then ( { timeout : 30000 } , ( newSubject ) => originalFn ( ...updateSubj ( args , stateType , newSubject ) ) ) ;
3944 }
4045 }
41- runCustomizedCommand ( ) ;
46+ runCustomizedChainingCommand ( ) ;
4247}
4348
4449Cypress . Commands . add ( 'processAccessibilityReport' , ( ) => {
0 commit comments