fix: Update product alert stub to check for 200 status (#25881)
Product alert api was mocked in the cypress tests which missed cases where the api would return a 401 error. Updating the mock to now make the call, verify the response status code to be 200 and then stub the response. --------- Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
This commit is contained in:
parent
830ef5f8aa
commit
6cd4117f38
|
|
@ -1133,15 +1133,26 @@ Cypress.Commands.add("startServerAndRoutes", () => {
|
|||
cy.intercept("PUT", "/api/v1/git/discard/app/*").as("discardChanges");
|
||||
cy.intercept("GET", "/api/v1/libraries/*").as("getLibraries");
|
||||
featureFlagIntercept({}, false);
|
||||
// Mock empty product alerts so that it does not interfere with tests
|
||||
cy.intercept("GET", "/api/v1/product-alert/alert", {
|
||||
responseMeta: {
|
||||
status: 200,
|
||||
success: true,
|
||||
},
|
||||
data: {},
|
||||
errorDisplay: "",
|
||||
});
|
||||
|
||||
cy.intercept("GET", "/api/v1/product-alert/alert", (req) => {
|
||||
try {
|
||||
req.continue((res) => {
|
||||
// This api should always be 200, for any case.
|
||||
expect(res.statusCode).to.be.equal(200);
|
||||
// Mock empty product alerts response so that it does not interfere with tests
|
||||
res.send(200, {
|
||||
responseMeta: {
|
||||
status: 200,
|
||||
success: true,
|
||||
},
|
||||
data: {},
|
||||
errorDisplay: "",
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}).as("productAlert");
|
||||
});
|
||||
|
||||
Cypress.Commands.add("startErrorRoutes", () => {
|
||||
|
|
@ -1374,6 +1385,7 @@ Cypress.Commands.add("createSuperUser", () => {
|
|||
expect(interception.request.body).contains("signupForNewsletter=true");
|
||||
});
|
||||
}
|
||||
cy.wait("@getWorkspace");
|
||||
|
||||
cy.LogOut();
|
||||
cy.wait(2000);
|
||||
|
|
|
|||
|
|
@ -92,7 +92,6 @@ before(function () {
|
|||
cy.url().then((url) => {
|
||||
if (url.indexOf("setup/welcome") > -1) {
|
||||
cy.createSuperUser();
|
||||
cy.LogOut();
|
||||
cy.SignupFromAPI(
|
||||
Cypress.env("TESTUSERNAME1"),
|
||||
Cypress.env("TESTPASSWORD1"),
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user