@@ -10,18 +10,11 @@ describe('Validate intercept command', () => {
10
10
11
11
it ( 'Should register the alias, intercept, wait & validate response status code when an API is fired' , ( ) => {
12
12
cy . accordion ( 'Diagnostics' ) ;
13
- cy . interceptApi ( {
14
- alias : 'treeSelectApi' ,
15
- urlPattern : / \/ o p s \/ t r e e _ s e l e c t \? i d = .* & t e x t = .* / ,
16
- triggerFn : ( ) => cy . selectAccordionItem ( [ / ^ M a n a g e I Q R e g i o n : / , / ^ Z o n e : / ] ) ,
17
- onApiResponse : ( interception ) => {
18
- expect ( interception . response . statusCode ) . to . equal ( 200 ) ;
19
- } ,
20
- } ) . then ( ( ) => {
21
- // verifies that the alias is set and the request is intercepted & awaited
22
- cy . getInterceptedApiAliases ( ) . then ( ( interceptedAliasesObject ) => {
23
- expect ( interceptedAliasesObject ) . to . have . property ( 'post-treeSelectApi' ) ;
24
- } ) ;
13
+ // Tree select api wait is handled from selectAccordionItem with alias 'treeSelectApi'
14
+ cy . selectAccordionItem ( [ / ^ M a n a g e I Q R e g i o n : / , / ^ Z o n e : / ] ) ;
15
+ // verifies that the alias is set and the request is intercepted & awaited
16
+ cy . getInterceptedApiAliases ( ) . then ( ( interceptedAliasesObject ) => {
17
+ expect ( interceptedAliasesObject ) . to . have . property ( 'post-treeSelectApi' ) ;
25
18
} ) ;
26
19
} ) ;
27
20
@@ -32,19 +25,14 @@ describe('Validate intercept command', () => {
32
25
urlPattern : / \/ o p s \/ a c c o r d i o n _ s e l e c t \? i d = .* / ,
33
26
triggerFn : ( ) => cy . accordion ( 'Diagnostics' ) ,
34
27
} ) ;
35
- // second api with alias 'treeSelectApi'
36
- cy . interceptApi ( {
37
- alias : 'treeSelectApi' ,
38
- urlPattern : / \/ o p s \/ t r e e _ s e l e c t \? i d = .* & t e x t = .* / ,
39
- triggerFn : ( ) => cy . selectAccordionItem ( [ / ^ M a n a g e I Q R e g i o n : / , / ^ Z o n e : / ] ) ,
40
- } ) . then ( ( ) => {
41
- // verifies that both the aliases are set and the request is intercepted & awaited
42
- cy . getInterceptedApiAliases ( ) . then ( ( interceptedAliasesObject ) => {
43
- expect ( interceptedAliasesObject ) . to . include . all . keys (
44
- 'post-accordionSelectApi' ,
45
- 'post-treeSelectApi'
46
- ) ;
47
- } ) ;
28
+ // second api with alias 'treeSelectApi'(Tree select api wait is handled from selectAccordionItem with alias 'treeSelectApi')
29
+ cy . selectAccordionItem ( [ / ^ M a n a g e I Q R e g i o n : / , / ^ Z o n e : / ] ) ;
30
+ // verifies that both the aliases are set and the request is intercepted & awaited
31
+ cy . getInterceptedApiAliases ( ) . then ( ( interceptedAliasesObject ) => {
32
+ expect ( interceptedAliasesObject ) . to . include . all . keys (
33
+ 'post-accordionSelectApi' ,
34
+ 'post-treeSelectApi'
35
+ ) ;
48
36
} ) ;
49
37
} ) ;
50
38
@@ -59,15 +47,10 @@ describe('Validate intercept command', () => {
59
47
expect ( Object . keys ( interceptedAliasesObject ) . length ) . to . equal ( 1 ) ;
60
48
} ) ;
61
49
} ) ;
62
- // second first api with alias 'treeSelectApi'
63
- cy . interceptApi ( {
64
- alias : 'treeSelectApi' ,
65
- urlPattern : / \/ o p s \/ t r e e _ s e l e c t \? i d = .* & t e x t = .* / ,
66
- triggerFn : ( ) => cy . selectAccordionItem ( [ / ^ M a n a g e I Q R e g i o n : / , / ^ Z o n e : / ] ) ,
67
- } ) . then ( ( ) => {
68
- cy . getInterceptedApiAliases ( ) . then ( ( interceptedAliasesObject ) => {
69
- expect ( Object . keys ( interceptedAliasesObject ) . length ) . to . equal ( 2 ) ;
70
- } ) ;
50
+ // second api with alias 'treeSelectApi'(Tree select api wait is handled from selectAccordionItem with alias 'treeSelectApi')
51
+ cy . selectAccordionItem ( [ / ^ M a n a g e I Q R e g i o n : / , / ^ Z o n e : / ] ) ;
52
+ cy . getInterceptedApiAliases ( ) . then ( ( interceptedAliasesObject ) => {
53
+ expect ( Object . keys ( interceptedAliasesObject ) . length ) . to . equal ( 2 ) ;
71
54
} ) ;
72
55
// third api with a duplicate alias as above 'accordionSelectApi'
73
56
cy . interceptApi ( {
0 commit comments