mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 17:47:54 +08:00
feat(cypress): valdiate error_code and error_message and make it visible in reports (#6913)
This commit is contained in:
@ -38,6 +38,13 @@ function logRequestId(xRequestId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function validateErrorMessage(response, resData) {
|
||||||
|
if (resData.body.status !== "failed") {
|
||||||
|
expect(response.body.error_message).to.be.null;
|
||||||
|
expect(response.body.error_code).to.be.null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Cypress.Commands.add(
|
Cypress.Commands.add(
|
||||||
"merchantCreateCallTest",
|
"merchantCreateCallTest",
|
||||||
(merchantCreateBody, globalState) => {
|
(merchantCreateBody, globalState) => {
|
||||||
@ -1113,6 +1120,8 @@ Cypress.Commands.add(
|
|||||||
).to.be.null;
|
).to.be.null;
|
||||||
expect(response.body.connector_mandate_id, "connector_mandate_id").to.be
|
expect(response.body.connector_mandate_id, "connector_mandate_id").to.be
|
||||||
.null;
|
.null;
|
||||||
|
|
||||||
|
validateErrorMessage(response, resData);
|
||||||
} else {
|
} else {
|
||||||
defaultErrorHandler(response, resData);
|
defaultErrorHandler(response, resData);
|
||||||
}
|
}
|
||||||
@ -1319,6 +1328,8 @@ Cypress.Commands.add(
|
|||||||
expect(response.body.profile_id, "profile_id").to.equal(profileId).and
|
expect(response.body.profile_id, "profile_id").to.equal(profileId).and
|
||||||
.to.not.be.null;
|
.to.not.be.null;
|
||||||
|
|
||||||
|
validateErrorMessage(response, resData);
|
||||||
|
|
||||||
if (response.body.capture_method === "automatic") {
|
if (response.body.capture_method === "automatic") {
|
||||||
if (response.body.authentication_type === "three_ds") {
|
if (response.body.authentication_type === "three_ds") {
|
||||||
expect(response.body)
|
expect(response.body)
|
||||||
@ -1419,64 +1430,68 @@ Cypress.Commands.add(
|
|||||||
globalState.set("connectorId", response.body.connector);
|
globalState.set("connectorId", response.body.connector);
|
||||||
globalState.set("paymentMethodType", confirmBody.payment_method_type);
|
globalState.set("paymentMethodType", confirmBody.payment_method_type);
|
||||||
|
|
||||||
switch (response.body.authentication_type) {
|
if (response.status === 200) {
|
||||||
case "three_ds":
|
validateErrorMessage(response, resData);
|
||||||
if (
|
|
||||||
response.body.capture_method === "automatic" ||
|
switch (response.body.authentication_type) {
|
||||||
response.body.capture_method === "manual"
|
case "three_ds":
|
||||||
) {
|
if (
|
||||||
if (response.body.status !== "failed") {
|
response.body.capture_method === "automatic" ||
|
||||||
// we get many statuses here, hence this verification
|
response.body.capture_method === "manual"
|
||||||
if (
|
) {
|
||||||
connectorId === "adyen" &&
|
if (response.body.status !== "failed") {
|
||||||
response.body.payment_method_type === "blik"
|
// we get many statuses here, hence this verification
|
||||||
) {
|
if (
|
||||||
expect(response.body)
|
connectorId === "adyen" &&
|
||||||
.to.have.property("next_action")
|
response.body.payment_method_type === "blik"
|
||||||
.to.have.property("type")
|
) {
|
||||||
.to.equal("wait_screen_information");
|
expect(response.body)
|
||||||
} else {
|
.to.have.property("next_action")
|
||||||
expect(response.body)
|
.to.have.property("type")
|
||||||
.to.have.property("next_action")
|
.to.equal("wait_screen_information");
|
||||||
.to.have.property("redirect_to_url");
|
} else {
|
||||||
globalState.set(
|
expect(response.body)
|
||||||
"nextActionUrl",
|
.to.have.property("next_action")
|
||||||
response.body.next_action.redirect_to_url
|
.to.have.property("redirect_to_url");
|
||||||
|
globalState.set(
|
||||||
|
"nextActionUrl",
|
||||||
|
response.body.next_action.redirect_to_url
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else if (response.body.status === "failed") {
|
||||||
|
expect(response.body.error_code).to.equal(
|
||||||
|
resData.body.error_code
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (response.body.status === "failed") {
|
} else {
|
||||||
expect(response.body.error_code).to.equal(
|
throw new Error(
|
||||||
resData.body.error_code
|
`Invalid capture method ${response.body.capture_method}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
break;
|
||||||
|
case "no_three_ds":
|
||||||
|
if (
|
||||||
|
response.body.capture_method === "automatic" ||
|
||||||
|
response.body.capture_method === "manual"
|
||||||
|
) {
|
||||||
|
expect(response.body)
|
||||||
|
.to.have.property("next_action")
|
||||||
|
.to.have.property("redirect_to_url");
|
||||||
|
globalState.set(
|
||||||
|
"nextActionUrl",
|
||||||
|
response.body.next_action.redirect_to_url
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
throw new Error(
|
||||||
|
`Invalid capture method ${response.body.capture_method}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Invalid capture method ${response.body.capture_method}`
|
`Invalid authentication type ${response.body.authentication_type}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case "no_three_ds":
|
|
||||||
if (
|
|
||||||
response.body.capture_method === "automatic" ||
|
|
||||||
response.body.capture_method === "manual"
|
|
||||||
) {
|
|
||||||
expect(response.body)
|
|
||||||
.to.have.property("next_action")
|
|
||||||
.to.have.property("redirect_to_url");
|
|
||||||
globalState.set(
|
|
||||||
"nextActionUrl",
|
|
||||||
response.body.next_action.redirect_to_url
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
throw new Error(
|
|
||||||
`Invalid capture method ${response.body.capture_method}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error(
|
|
||||||
`Invalid authentication type ${response.body.authentication_type}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
defaultErrorHandler(response, resData);
|
defaultErrorHandler(response, resData);
|
||||||
@ -1521,6 +1536,9 @@ Cypress.Commands.add(
|
|||||||
expect(response.headers["content-type"]).to.include("application/json");
|
expect(response.headers["content-type"]).to.include("application/json");
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
globalState.set("paymentID", paymentIntentID);
|
globalState.set("paymentID", paymentIntentID);
|
||||||
|
|
||||||
|
validateErrorMessage(response, resData);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
response.body.capture_method === "automatic" ||
|
response.body.capture_method === "automatic" ||
|
||||||
response.body.capture_method === "manual"
|
response.body.capture_method === "manual"
|
||||||
@ -1601,6 +1619,8 @@ Cypress.Commands.add(
|
|||||||
logRequestId(response.headers["x-request-id"]);
|
logRequestId(response.headers["x-request-id"]);
|
||||||
expect(response.headers["content-type"]).to.include("application/json");
|
expect(response.headers["content-type"]).to.include("application/json");
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
|
validateErrorMessage(response, resData);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
response.body.capture_method === "automatic" ||
|
response.body.capture_method === "automatic" ||
|
||||||
response.body.capture_method === "manual"
|
response.body.capture_method === "manual"
|
||||||
@ -1698,6 +1718,8 @@ Cypress.Commands.add(
|
|||||||
expect(response.body.profile_id, "profile_id").to.not.be.null;
|
expect(response.body.profile_id, "profile_id").to.not.be.null;
|
||||||
expect(response.body).to.have.property("status");
|
expect(response.body).to.have.property("status");
|
||||||
|
|
||||||
|
validateErrorMessage(response, resData);
|
||||||
|
|
||||||
if (response.body.capture_method === "automatic") {
|
if (response.body.capture_method === "automatic") {
|
||||||
if (response.body.authentication_type === "three_ds") {
|
if (response.body.authentication_type === "three_ds") {
|
||||||
expect(response.body)
|
expect(response.body)
|
||||||
@ -1819,6 +1841,8 @@ Cypress.Commands.add(
|
|||||||
expect(response.body.profile_id, "profile_id").to.not.be.null;
|
expect(response.body.profile_id, "profile_id").to.not.be.null;
|
||||||
expect(response.body.payment_token, "payment_token").to.not.be.null;
|
expect(response.body.payment_token, "payment_token").to.not.be.null;
|
||||||
|
|
||||||
|
validateErrorMessage(response, resData);
|
||||||
|
|
||||||
if (response.body.capture_method === "automatic") {
|
if (response.body.capture_method === "automatic") {
|
||||||
if (response.body.authentication_type === "three_ds") {
|
if (response.body.authentication_type === "three_ds") {
|
||||||
expect(response.body)
|
expect(response.body)
|
||||||
|
|||||||
Reference in New Issue
Block a user