Cypress waiting until graphql query finishes

Viewed 151

I'm trying to wait for a specific graphql request to finish before I check for an element on the page but it doesn't seem to wait the way I have it set up

describe('CopyrightModule', () => {
  it('edit, cancel, edit, save', () => {
    cy.intercept(
      {
        method: 'POST',
        url: '/graphql',
      },
      req => {
        console.log(req.body.id);
        console.log(req);
        if (req.body.id === 'TakedownUserRendererQuery') {
          req.alias = 'TakedownUserRendererQuery';
        }
      },
    );
    cy.visit('/');
    cy.get(selectors.DMCA_LINK).click({ force: true });
    cy.contains('My Requests').click();
    cy.get(selectors.REQUEST_ROW)
      .first()
      .click();
    cy.wait('@TakedownUserRendererQuery');
    cy.get(selectors.COPYRIGHT_EDIT).click();
    cy.contains('Cancel').click();
    cy.get(selectors.COPYRIGHT_EDIT).click();
    cy.contains('div', 'Owner Website URLs')
      .find('input')
      .first()
      .type('8000-1612023');
  });
});
0 Answers
Related