Cypress.visit() is not working when passed URL in qs(query string)

Viewed 876

I am trying to open a URL with the below code and passed the qs(Query String) parameter. In my qs(Query String) parameter I have 2 elements as below -

  1. Client ID ('0000-11111-33333-44444-55555')
  2. Redirect URL ('http://localhost:8088/api/callback')
  1. If I pass the Redirect URL in a non-encoded format the test is terminated.

  2. And if I pass the Redirect URL in the encoded format before calling visit cypress again encodes it and due to that the duel encoded callback URL is called and due to it's failing. See in below example -

describe('Connect', function () {
    beforeEach(() => {
        cy.visit({
            method: 'GET',
            url: 'https://someURL.com/oauth2/authorize',
            qs: {
                client_id: encodeURIComponent('0000-11111-33333-44444-55555'),
                redirect_uri: encodeURIComponent('http://localhost:8088/api/callback'),
            }
        });
    });

    it('Check connection', function () {
        cy.contains('Success').should('be.visible');
    });
});

This produces the URL to visit -

https://open-ic.epic.com/Argonaut/oauth2/authorize?client_id=0000-11111-33333-44444-55555&redirect_uri=http%253A%252F%252Flocalhost%253A8088%252Fapi%252Fcallback

This is incorrect and this should be like -

https://someURL.com/oauth2/authorize?client_id=0000-11111-33333-44444-55555&redirect_uri=http%3A%2F%2Flocalhost%3A8088%2Fapi%2Fcallback

In the above URLs observe redirect_uri is encoded twice which I think the issue.

Is there something I am missing to add here??

0 Answers
Related