@@ -13,30 +13,37 @@ const commandsToOverride = [
13
13
const commandsToWrap = [ 'visit' , 'click' , 'type' , 'request' , 'dblclick' , 'rightclick' , 'clear' , 'check' , 'uncheck' , 'select' , 'trigger' , 'selectFile' , 'scrollIntoView' , 'scroll' , 'scrollTo' , 'blur' , 'focus' , 'go' , 'reload' , 'submit' , 'viewport' , 'origin' ] ;
14
14
15
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 = ( ) => {
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 = ( ) => {
21
21
if ( ! Subject ) {
22
- let origSubject1 , origSubject2 , cyCommandSubject = null ;
23
- if ( ( origSubject2 = ( origSubject1 = cy ) . subject ) !== null && origSubject2 !== void 0 ) {
24
- cyCommandSubject = origSubject2 . call ( origSubject1 ) ;
22
+ let cypressCommandSubject = null ;
23
+ const subjectFn = cy && cy . subject ;
24
+ if ( subjectFn !== null && subjectFn !== void 0 ) {
25
+ cypressCommandSubject = subjectFn . call ( cy ) ;
25
26
}
26
- customChainingCypressCommands . then ( ( ) => cyCommandSubject ) . then ( ( ) => { originalFn ( ...args ) ; } ) ;
27
+ cycustomChaining
28
+ . then ( ( ) => cypressCommandSubject )
29
+ . then ( ( ) => {
30
+ originalFn ( ...args ) ;
31
+ } ) ;
27
32
} else {
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 ;
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 ;
31
38
}
32
- if ( ( origChain1 = ( origChain2 = cy ) . subjectChain ) !== null && origChain1 !== void 0 ) {
33
- cyCommandChain = origChain1 . call ( origChain2 ) ;
39
+ const subjectChainFn = cy && cy . subjectChain ;
40
+ if ( subjectChainFn !== null && subjectChainFn !== void 0 ) {
41
+ cypressCommandChain = subjectChainFn . call ( cy ) ;
34
42
}
35
- customChainingCypressCommands . performScanSubjectQuery ( cyCommandChain , setDelay )
36
- . then ( { timeout : 30000 } , ( newSubject ) => originalFn ( ...updateSub ( args , stateType , newSubject ) ) ) ;
43
+ cycustomChaining . performScanSubjectQuery ( cypressCommandChain , setTimeout ) . then ( { timeout : 30000 } , ( newSubject ) => originalFn ( ...updateSubj ( args , stateType , newSubject ) ) ) ;
37
44
}
38
45
}
39
- runCustomizedLambdaChainingCommand ( ) ;
46
+ runCustomizedChainingCommand ( ) ;
40
47
}
41
48
42
49
Cypress . Commands . add ( 'processAccessibilityReport' , ( ) => {
0 commit comments