@@ -12,39 +12,31 @@ const commandsToOverride = [
12
12
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
- 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 = ( ) => {
21
21
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 ) ;
26
25
}
27
-
28
- customChaining
29
- . then ( ( ) => cypressCommandSubject )
30
- . then ( ( ) => {
31
- originalFn ( ...args ) ;
32
- } ) ;
26
+ customChainingCypressCommands . then ( ( ) => cyCommandSubject ) . then ( ( ) => { originalFn ( ...args ) ; } ) ;
33
27
} 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 ;
39
31
}
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 ) ;
43
34
}
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 ) ) ) ;
45
37
}
46
38
}
47
- runCustomizedChainingCommand ( ) ;
39
+ runCustomizedLambdaChainingCommand ( ) ;
48
40
}
49
41
50
42
Cypress . Commands . add ( 'processAccessibilityReport' , ( ) => {
@@ -266,7 +258,7 @@ if (overRideCommands) {
266
258
if ( state !== null && state !== void 0 ) {
267
259
stateType = state . get ( 'type' ) ;
268
260
}
269
- performModifiedScan ( originalFn , Subject , stateType , ...args ) ;
261
+ performNewLambdaScan ( originalFn , Subject , stateType , ...args ) ;
270
262
271
263
} ) ;
272
264
} ) ;
0 commit comments