mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 19:42:27 +08:00
ci(cypress): Add field level verification (#6153)
This commit is contained in:
@ -822,13 +822,67 @@ Cypress.Commands.add(
|
||||
globalState.set("paymentID", response.body.payment_id);
|
||||
cy.log(clientSecret);
|
||||
for (const key in res_data.body) {
|
||||
expect(res_data.body[key]).to.equal(response.body[key]);
|
||||
expect(res_data.body[key]).to.equal(
|
||||
response.body[key],
|
||||
`Expected ${res_data.body[key]} but got ${response.body[key]}`
|
||||
);
|
||||
}
|
||||
expect(createPaymentBody.amount).to.equal(response.body.amount);
|
||||
expect(null).to.equal(response.body.amount_received);
|
||||
expect(createPaymentBody.amount).to.equal(
|
||||
expect(createPaymentBody.amount, "amount").to.equal(
|
||||
response.body.amount
|
||||
);
|
||||
expect(createPaymentBody.currency, "currency").to.equal(
|
||||
response.body.currency
|
||||
);
|
||||
expect(createPaymentBody.capture_method, "capture_method").to.equal(
|
||||
response.body.capture_method
|
||||
);
|
||||
expect(
|
||||
createPaymentBody.authentication_type,
|
||||
"authentication_type"
|
||||
).to.equal(response.body.authentication_type);
|
||||
expect(createPaymentBody.description, "description").to.equal(
|
||||
response.body.description
|
||||
);
|
||||
expect(createPaymentBody.email, "email").to.equal(response.body.email);
|
||||
expect(createPaymentBody.email, "customer.email").to.equal(
|
||||
response.body.customer.email
|
||||
);
|
||||
expect(createPaymentBody.customer_id, "customer.id").to.equal(
|
||||
response.body.customer.id
|
||||
);
|
||||
expect(createPaymentBody.metadata, "metadata").to.deep.equal(
|
||||
response.body.metadata
|
||||
);
|
||||
expect(
|
||||
createPaymentBody.setup_future_usage,
|
||||
"setup_future_usage"
|
||||
).to.equal(response.body.setup_future_usage);
|
||||
expect(createPaymentBody.amount, "amount_capturable").to.equal(
|
||||
response.body.amount_capturable
|
||||
);
|
||||
expect(response.body.amount_received, "amount_received").to.be.oneOf([
|
||||
0,
|
||||
null,
|
||||
]);
|
||||
expect(response.body.connector, "connector").to.be.null;
|
||||
expect(createPaymentBody.capture_method, "capture_method").to.equal(
|
||||
response.body.capture_method
|
||||
);
|
||||
expect(response.body.payment_method, "payment_method").to.be.null;
|
||||
expect(response.body.payment_method_data, "payment_method_data").to.be
|
||||
.null;
|
||||
expect(response.body.merchant_connector_id, "merchant_connector_id").to
|
||||
.be.null;
|
||||
expect(response.body.payment_method_id, "payment_method_id").to.be.null;
|
||||
expect(response.body.payment_method_id, "payment_method_status").to.be
|
||||
.null;
|
||||
expect(response.body.profile_id, "profile_id").to.not.be.null;
|
||||
expect(
|
||||
response.body.merchant_order_reference_id,
|
||||
"merchant_order_reference_id"
|
||||
).to.be.null;
|
||||
expect(response.body.connector_mandate_id, "connector_mandate_id").to.be
|
||||
.null;
|
||||
} else {
|
||||
defaultErrorHandler(response, res_data);
|
||||
}
|
||||
@ -911,6 +965,24 @@ Cypress.Commands.add(
|
||||
if (response.status === 200) {
|
||||
globalState.set("paymentID", paymentIntentID);
|
||||
globalState.set("connectorId", response.body.connector);
|
||||
expect(response.body.connector, "connector").to.equal(
|
||||
globalState.get("connectorId")
|
||||
);
|
||||
expect(response.body.payment_id, "payment_id").to.equal(
|
||||
paymentIntentID
|
||||
);
|
||||
expect(response.body.payment_method_data, "payment_method_data").to.not
|
||||
.be.empty;
|
||||
expect(response.body.merchant_connector_id, "connector_id").to.equal(
|
||||
globalState.get("merchantConnectorId")
|
||||
);
|
||||
expect(response.body.customer, "customer").to.not.be.empty;
|
||||
expect(response.body.billing, "billing_address").to.not.be.empty;
|
||||
expect(response.body.profile_id, "profile_id").to.not.be.null;
|
||||
expect(
|
||||
response.body.connector_transaction_id,
|
||||
"connector_transaction_id"
|
||||
).to.not.be.null;
|
||||
if (response.body.capture_method === "automatic") {
|
||||
if (response.body.authentication_type === "three_ds") {
|
||||
expect(response.body)
|
||||
@ -921,11 +993,15 @@ Cypress.Commands.add(
|
||||
response.body.next_action.redirect_to_url
|
||||
);
|
||||
for (const key in res_data.body) {
|
||||
expect(res_data.body[key]).to.equal(response.body[key]);
|
||||
expect(res_data.body[key], [key]).to.deep.equal(
|
||||
response.body[key]
|
||||
);
|
||||
}
|
||||
} else if (response.body.authentication_type === "no_three_ds") {
|
||||
for (const key in res_data.body) {
|
||||
expect(res_data.body[key]).to.equal(response.body[key]);
|
||||
expect(res_data.body[key], [key]).to.deep.equal(
|
||||
response.body[key]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw new Error(
|
||||
@ -941,9 +1017,16 @@ Cypress.Commands.add(
|
||||
"nextActionUrl",
|
||||
response.body.next_action.redirect_to_url
|
||||
);
|
||||
for (const key in res_data.body) {
|
||||
expect(res_data.body[key], [key]).to.deep.equal(
|
||||
response.body[key]
|
||||
);
|
||||
}
|
||||
} else if (response.body.authentication_type === "no_three_ds") {
|
||||
for (const key in res_data.body) {
|
||||
expect(res_data.body[key]).to.equal(response.body[key]);
|
||||
expect(res_data.body[key], [key]).to.deep.equal(
|
||||
response.body[key]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw new Error(
|
||||
@ -1212,10 +1295,28 @@ Cypress.Commands.add(
|
||||
logRequestId(response.headers["x-request-id"]);
|
||||
expect(response.headers["content-type"]).to.include("application/json");
|
||||
if (response.status === 200) {
|
||||
globalState.set("paymentAmount", createConfirmPaymentBody.amount);
|
||||
globalState.set("paymentID", response.body.payment_id);
|
||||
expect(response.body.connector, "connector").to.equal(
|
||||
globalState.get("connectorId")
|
||||
);
|
||||
expect(response.body.payment_id, "payment_id").to.equal(
|
||||
globalState.get("paymentID")
|
||||
);
|
||||
expect(response.body.payment_method_data, "payment_method_data").to.not
|
||||
.be.empty;
|
||||
expect(response.body.merchant_connector_id, "connector_id").to.equal(
|
||||
globalState.get("merchantConnectorId")
|
||||
);
|
||||
expect(response.body.customer, "customer").to.not.be.empty;
|
||||
expect(response.body.billing, "billing_address").to.not.be.empty;
|
||||
expect(response.body.profile_id, "profile_id").to.not.be.null;
|
||||
expect(
|
||||
response.body.connector_transaction_id,
|
||||
"connector_transaction_id"
|
||||
).to.not.be.null;
|
||||
expect(response.body).to.have.property("status");
|
||||
if (response.body.capture_method === "automatic") {
|
||||
expect(response.body).to.have.property("status");
|
||||
globalState.set("paymentAmount", createConfirmPaymentBody.amount);
|
||||
globalState.set("paymentID", response.body.payment_id);
|
||||
if (response.body.authentication_type === "three_ds") {
|
||||
expect(response.body)
|
||||
.to.have.property("next_action")
|
||||
@ -1224,9 +1325,16 @@ Cypress.Commands.add(
|
||||
"nextActionUrl",
|
||||
response.body.next_action.redirect_to_url
|
||||
);
|
||||
for (const key in res_data.body) {
|
||||
expect(res_data.body[key], [key]).to.deep.equal(
|
||||
response.body[key]
|
||||
);
|
||||
}
|
||||
} else if (response.body.authentication_type === "no_three_ds") {
|
||||
for (const key in res_data.body) {
|
||||
expect(res_data.body[key]).to.equal(response.body[key]);
|
||||
expect(res_data.body[key], [key]).to.deep.equal(
|
||||
response.body[key]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw new Error(
|
||||
@ -1234,9 +1342,6 @@ Cypress.Commands.add(
|
||||
);
|
||||
}
|
||||
} else if (response.body.capture_method === "manual") {
|
||||
expect(response.body).to.have.property("status");
|
||||
globalState.set("paymentAmount", createConfirmPaymentBody.amount);
|
||||
globalState.set("paymentID", response.body.payment_id);
|
||||
if (response.body.authentication_type === "three_ds") {
|
||||
expect(response.body)
|
||||
.to.have.property("next_action")
|
||||
@ -1245,9 +1350,16 @@ Cypress.Commands.add(
|
||||
"nextActionUrl",
|
||||
response.body.next_action.redirect_to_url
|
||||
);
|
||||
for (const key in res_data.body) {
|
||||
expect(res_data.body[key], [key]).to.deep.equal(
|
||||
response.body[key]
|
||||
);
|
||||
}
|
||||
} else if (response.body.authentication_type === "no_three_ds") {
|
||||
for (const key in res_data.body) {
|
||||
expect(res_data.body[key]).to.equal(response.body[key]);
|
||||
expect(res_data.body[key], [key]).to.deep.equal(
|
||||
response.body[key]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw new Error(
|
||||
@ -1409,11 +1521,33 @@ Cypress.Commands.add(
|
||||
failOnStatusCode: false,
|
||||
}).then((response) => {
|
||||
logRequestId(response.headers["x-request-id"]);
|
||||
globalState.set("paymentID", response.body.payment_id);
|
||||
|
||||
expect(response.headers["content-type"]).to.include("application/json");
|
||||
expect(response.body.payment_id).to.equal(payment_id);
|
||||
expect(response.body.amount).to.equal(globalState.get("paymentAmount"));
|
||||
globalState.set("paymentID", response.body.payment_id);
|
||||
expect(response.body.profile_id, "profile_id").to.not.be.null;
|
||||
expect(response.body.billing, "billing_address").to.not.be.empty;
|
||||
expect(response.body.customer, "customer").to.not.be.empty;
|
||||
if (
|
||||
["succeeded", "processing", "requires_customer_action"].includes(
|
||||
response.body.status
|
||||
)
|
||||
) {
|
||||
expect(response.body.connector, "connector").to.equal(
|
||||
globalState.get("connectorId")
|
||||
);
|
||||
expect(response.body.payment_method_data, "payment_method_data").to.not
|
||||
.be.empty;
|
||||
expect(response.body.payment_method, "payment_method").to.not.be.null;
|
||||
expect(response.body.merchant_connector_id, "connector_id").to.equal(
|
||||
globalState.get("merchantConnectorId")
|
||||
);
|
||||
expect(
|
||||
response.body.connector_transaction_id,
|
||||
"connector_transaction_id"
|
||||
).to.not.be.null;
|
||||
}
|
||||
|
||||
if (autoretries) {
|
||||
expect(response.body).to.have.property("attempts");
|
||||
@ -1835,7 +1969,9 @@ Cypress.Commands.add(
|
||||
{ redirection_url, expected_url },
|
||||
connectorId,
|
||||
payment_method_type,
|
||||
{ next_action_type }
|
||||
{
|
||||
next_action_type,
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user