@@ -22,17 +22,25 @@ const performModifiedScan = (originalFn, Subject, stateType, ...args) => {
2222 }
2323 return args ;
2424 }
25- const runCutomizedCommand = ( ) => {
25+ const runCustomizedCommand = ( ) => {
2626 if ( ! Subject ) {
27- let cypressCommandSubject = ( cy . subject ?. call ( cy ) ) ?? null ;
28- customChaining . then ( ( ) => cypressCommandSubject ) . then ( ( ) => { originalFn ( ...args ) ; } ) ;
27+ let orgS1 , orgS2 , cypressCommandSubject = null ;
28+ if ( ( orgS2 = ( orgS1 = cy ) . subject ) !== null && orgS2 !== void 0 ) {
29+ cypressCommandSubject = orgS2 . call ( orgS1 ) ;
30+ }
31+ customChaining . then ( ( ) => cypressCommandSubject ) . then ( ( ) => { originalFn ( ...args ) } ) ;
2932 } else {
30- let setTimeout = args . find ( arg => arg ?. timeout ) ?. timeout ?? null ;
31- let cypressCommandChain = ( cy . subjectChain ?. call ( cy ) ) ?? null ;
32- customChaining . performScanSubjectQuery ( cypressCommandChain , setTimeout ) . then ( { timeout : 10000 } , newSubject => originalFn ( ...changeSub ( args , stateType , newSubject ) ) ) ;
33+ let orgSC1 , orgSC2 , timeO1 , cypressCommandChain = null , setTimeout = null ;
34+ if ( ( timeO1 = args . find ( arg => arg !== null && arg !== void 0 ? arg . timeout : null ) ) !== null && timeO1 !== void 0 ) {
35+ setTimeout = timeO1 . timeout ;
36+ }
37+ if ( ( orgSC1 = ( orgSC2 = cy ) . subjectChain ) !== null && orgSC1 !== void 0 ) {
38+ cypressCommandChain = orgSC1 . call ( orgSC2 ) ;
39+ }
40+ customChaining . performScanSubjectQuery ( cypressCommandChain , setTimeout ) . then ( { timeout : 30000 } , ( newSubject ) => originalFn ( ...changeSub ( args , stateType , newSubject ) ) ) ;
3341 }
3442 }
35- runCutomizedCommand ( ) ;
43+ runCustomizedCommand ( ) ;
3644}
3745
3846const performScan = ( win , payloadToSend ) =>
@@ -297,16 +305,13 @@ commandToOverwrite.forEach((command) => {
297305 const shouldScanTestForAccessibility = shouldScanForAccessibility ( attributes ) ;
298306 const state = cy . state ( 'current' ) , Subject = 'getSubjectFromChain' in cy ;
299307 const stateName = state === null || state === void 0 ? void 0 : state . get ( 'name' ) ;
300- let stateType ;
308+ let stateType = null ;
301309 if ( ! shouldScanTestForAccessibility || ( stateName && stateName !== command ) ) {
302310 return originalFn ( ...args ) ;
303311 }
304312 if ( state !== null && state !== void 0 ) {
305313 stateType = state . get ( 'type' ) ;
306314 }
307- else {
308- stateType = null ;
309- }
310315 performModifiedScan ( originalFn , Subject , stateType , ...args ) ;
311316 } ) ;
312317} ) ;
0 commit comments