@@ -22,17 +22,25 @@ const performModifiedScan = (originalFn, Subject, stateType, ...args) => {
22
22
}
23
23
return args ;
24
24
}
25
- const runCutomizedCommand = ( ) => {
25
+ const runCustomizedCommand = ( ) => {
26
26
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 ) } ) ;
29
32
} 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 ) ) ) ;
33
41
}
34
42
}
35
- runCutomizedCommand ( ) ;
43
+ runCustomizedCommand ( ) ;
36
44
}
37
45
38
46
const performScan = ( win , payloadToSend ) =>
@@ -297,16 +305,13 @@ commandToOverwrite.forEach((command) => {
297
305
const shouldScanTestForAccessibility = shouldScanForAccessibility ( attributes ) ;
298
306
const state = cy . state ( 'current' ) , Subject = 'getSubjectFromChain' in cy ;
299
307
const stateName = state === null || state === void 0 ? void 0 : state . get ( 'name' ) ;
300
- let stateType ;
308
+ let stateType = null ;
301
309
if ( ! shouldScanTestForAccessibility || ( stateName && stateName !== command ) ) {
302
310
return originalFn ( ...args ) ;
303
311
}
304
312
if ( state !== null && state !== void 0 ) {
305
313
stateType = state . get ( 'type' ) ;
306
314
}
307
- else {
308
- stateType = null ;
309
- }
310
315
performModifiedScan ( originalFn , Subject , stateType , ...args ) ;
311
316
} ) ;
312
317
} ) ;
0 commit comments