cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.03k stars 3.19k forks source link

Cypress window closes with invalid argument when try to intercept a PUT request. #16392

Closed Ppkd2021 closed 3 years ago

Ppkd2021 commented 3 years ago

Current behavior

We are trying to intercept a put request for uploading image to s3 bucket, It fails with an invalid argument type error when we wait for that respective interception. All other interceptions are working fine just one mentioned above is failing, Also, THe same test case is working fine in cypress 6.8.0 but when we upgraded cypress to 7.2.0 then it started failing. I checked again by downgrading the cypress to 6.8 and it is working fine but not in 7.2.0

Route URL : https://bd-cs-dev-media.s3.us-east-1.amazonaws.com/public/pics/*

Desired behavior

Test code to reproduce

beforeEach(`restore the session`, () => {
        cy.intercept({
            method: `PUT`,
            url: Cypress.env(`uploadUrl`)
        }).as(`uploadImage`);
        cy.restoreLocalStorage();
        cy.visit('group-admin/manage');
        cy.contains(`.list-item`, `Cs Admin Test Group`, {timeout: 60000})
            .within(() => {
                cy.get(`button.linker`).should(`have.length`, 1).click();
            })
            .MultipleInterceptRoute([`CreateFbPostModel`, `ListFbPostModels`, `GetLastdayGroupMetricsByGroupId`]);
    });
it(`C28 : Verify the user as group admin able to publish a post successfully with Text with Emoji's and Image`, () => {
        cy.wait(`@GetLastdayGroupMetricsByGroupId`, {timeout: 30000});
        cy.getDataTestId(`btn-group-create-a-post`).click();
        cy.get(`[data-cs-label="To post page"]`).click();
        cy.get('#postMessage').type(`this is a text message with emoji`);
        cy.get(`#toggleEmoji`).click();
        cy.get(`ngx-emoji`).as(`emojis`).eq(5).click();
        cy.get(`@emojis`).eq(7).click();
        cy.get(`input[type="file"]`).attachFile(`../fixtures/files/pictures/pic1.jpg`);
        cy.get(`.thumbnail.image`).should(`have.length`, 1);
        cy.get(`.publish-btn`).eq(0).should(`be.visible`).click();
        cy.wait(`@uploadImage`, {timeout: 60000})
            .then(res => {
                expect(res.response.statusCode).to.be.equal(200);
            })
            cy.wait(`@CreateFbPostModel`, {timeout: 60000})
            .then(req => {
                expect(req.request.body.variables.input.contentType).to.be.equal(`Photo`);
            });
        cy.wait(`@ListFbPostModels`, {timeout: 60000});
        cy.contains(`.scheduled-post-wrapper > .post-box-wrapper`, `this is a text message with emoji`).within(() => {
            cy.get(`.post-box-body > .ng-star-inserted`).should(`contain.text`, `this is a text message with emoji`);
            cy.get('.ng-star-inserted > img').should(`have.length`, 1);
        });
    });

https://user-images.githubusercontent.com/59794856/117450691-32903e80-af5f-11eb-8ae4-04df7758286e.mp4

Versions

<Cypress 7.2.0>

Ppkd2021 commented 3 years ago

https://user-images.githubusercontent.com/59794856/117451213-d974da80-af5f-11eb-9ca1-92bfc367ff5b.mp4

Ppkd2021 commented 3 years ago

image

jennifer-shehane commented 3 years ago

Hey @Ppkd2021, we have a fix going out in our next release on Monday for the ERR_INVALID_ARG_TYPE error here: https://github.com/cypress-io/cypress/issues/16223

You can download the pre-release version of Cypress to get this fix. Follow the instructions here

Duplicate of https://github.com/cypress-io/cypress/issues/16223

Ppkd2021 commented 3 years ago

@jennifer-shehane Thanks for sharing the info. Also, We are observing that auto-scrolling is happening during the execution of test cases due to which many test cases are failing because cypress is not able to click on the element. Is that issue will also be addressed with the next release.

Ppkd2021 commented 3 years ago

https://user-images.githubusercontent.com/59794856/117531318-94a08080-afff-11eb-9acc-1e38983bf5d6.mp4

We have not set scrollingbehavior flag in cypress.json or in the test case.

jennifer-shehane commented 3 years ago

@Ppkd2021 I'm not aware of this issue specifically. Can you open an issue with an example to reproduce?