@@ -10,18 +10,11 @@ describe('Validate intercept command', () => {
1010
1111 it ( 'Should register the alias, intercept, wait & validate response status code when an API is fired' , ( ) => {
1212 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' ) ;
2518 } ) ;
2619 } ) ;
2720
@@ -32,19 +25,14 @@ describe('Validate intercept command', () => {
3225 urlPattern : / \/ o p s \/ a c c o r d i o n _ s e l e c t \? i d = .* / ,
3326 triggerFn : ( ) => cy . accordion ( 'Diagnostics' ) ,
3427 } ) ;
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+ ) ;
4836 } ) ;
4937 } ) ;
5038
@@ -59,15 +47,10 @@ describe('Validate intercept command', () => {
5947 expect ( Object . keys ( interceptedAliasesObject ) . length ) . to . equal ( 1 ) ;
6048 } ) ;
6149 } ) ;
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 ) ;
7154 } ) ;
7255 // third api with a duplicate alias as above 'accordionSelectApi'
7356 cy . interceptApi ( {
0 commit comments