mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-31 01:57:45 +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,6 +1430,9 @@ 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);
|
||||||
|
|
||||||
|
if (response.status === 200) {
|
||||||
|
validateErrorMessage(response, resData);
|
||||||
|
|
||||||
switch (response.body.authentication_type) {
|
switch (response.body.authentication_type) {
|
||||||
case "three_ds":
|
case "three_ds":
|
||||||
if (
|
if (
|
||||||
@ -1478,6 +1492,7 @@ Cypress.Commands.add(
|
|||||||
`Invalid authentication type ${response.body.authentication_type}`
|
`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