Skip to content

Conversation

asirvadAbrahamVarghese
Copy link
Contributor

PR to enhance interceptApi command:

  • Option to control wait-if-request-fired logic, this logic is useful for tree navigation flows, but not needed for button actions where requests are always guaranteed.
  • Callback for request interception

@miq-bot assign @jrafanie
@miq-bot add-label cypress
@miq-bot add-label enhancement

@jrafanie
Copy link
Member

cc @Fryguy do you have any thoughts on this way to do some mock/stubbing the result of an intercepted request?

@asirvadAbrahamVarghese asirvadAbrahamVarghese force-pushed the enhance-intercept-api-command branch from c695ff5 to 068c59a Compare September 23, 2025 08:22
@asirvadAbrahamVarghese asirvadAbrahamVarghese force-pushed the enhance-intercept-api-command branch from 068c59a to 27f2bc8 Compare September 23, 2025 09:22
@jrafanie
Copy link
Member

LGTM, merging. I'm not quite sure how to use it yet so I think as you use it, it should probably help demonstrate the usability and help us revise as needed.

@jrafanie jrafanie merged commit 8e71ce6 into ManageIQ:master Sep 24, 2025
18 checks passed
@asirvadAbrahamVarghese
Copy link
Contributor Author

I'm not quite sure how to use it yet

If the request isn't guaranteed to fire for example, in tree navigation where clicking an already-selected node may not trigger a request then you should set the waitOnlyIfRequestIntercepted flag to true like we did from selectAccordionItem

            cy.interceptApi({
              alias: 'treeSelectApi',
              urlPattern: "api/tree_select/text=TestName",
              triggerFn: () => cy.wrap(li).click(),
              waitOnlyIfRequestIntercepted: true,
            });

If the request is guaranteed to fire, such as from a button click, you can leave the waitOnlyIfRequestIntercepted flag as false (its default value) so that it waits without relying on the environment flag.

            cy.interceptApi({
              alias: 'saveApi',
              urlPattern: "api/data/action=save",
              triggerFn: () => cy.get('button').click(),
            });

@jrafanie
Copy link
Member

@GilbertCherrie @elsamaryv Please review this PR, especially, the summary of usage on the last comment. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants