Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cypress): fix cypress throwing error when connectorId is not passed and miscellaneous fixes #5746

Merged
merged 7 commits into from
Sep 2, 2024
Merged
2 changes: 1 addition & 1 deletion cypress-tests/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const path = require("path");

let globalState;
// Fetch from environment variable
const connectorId = process.env.CYPRESS_CONNECTOR;
const connectorId = process.env.CYPRESS_CONNECTOR || "service";
const reportName = process.env.REPORT_NAME || `${connectorId}_report`;

module.exports = defineConfig({
Expand Down
10 changes: 6 additions & 4 deletions cypress-tests/cypress/e2e/PaymentUtils/Commons.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ function normalise(input) {
// Add more known exceptions here
};

if (exceptions[input.toLowerCase()]) {
return exceptions[input.toLowerCase()];
} else {
return input;
if (typeof input !== "string") {
const spec_name = Cypress.spec.name.split("-")[1].split(".")[0];
return `${spec_name}`;
}

const lowerCaseInput = input.toLowerCase();
return exceptions[lowerCaseInput] || input;
}

const successfulNo3DSCardDetails = {
Expand Down
281 changes: 140 additions & 141 deletions cypress-tests/cypress/e2e/PaymentUtils/Fiservemea.js
Original file line number Diff line number Diff line change
@@ -1,164 +1,163 @@
const successfulNo3DSCardDetails = {
card_number: "5204740000001002",
card_exp_month: "10",
card_exp_year: "24",
card_holder_name: "Joseph Doe",
card_cvc: "002",
};

export const connectorDetails = {
card_pm: {
PaymentIntent: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
currency: "EUR",
customer_acceptance: null,
setup_future_usage: "on_session",
},
Response: {
status: 200,
body: {
status: "requires_payment_method",
},
},
card_number: "5204740000001002",
card_exp_month: "10",
card_exp_year: "24",
card_holder_name: "Joseph Doe",
card_cvc: "002",
};

export const connectorDetails = {
card_pm: {
PaymentIntent: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
currency: "EUR",
customer_acceptance: null,
setup_future_usage: "on_session",
},
No3DSManualCapture: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
currency: "EUR",
customer_acceptance: null,
setup_future_usage: "on_session",
},
Response: {
status: 200,
body: {
status: "requires_capture",
},
Response: {
status: 200,
body: {
status: "requires_payment_method",
},
},
No3DSAutoCapture: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
currency: "EUR",
customer_acceptance: null,
setup_future_usage: "on_session",
},
Response: {
status: 200,
body: {
status: "succeeded",
},
},
},
No3DSManualCapture: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
currency: "EUR",
customer_acceptance: null,
setup_future_usage: "on_session",
},
Capture: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
currency: "EUR",
customer_acceptance: null,
},
Response: {
status: 200,
body: {
status: "succeeded",
amount: 6500,
amount_capturable: 0,
amount_received: 6500,
},
Response: {
status: 200,
body: {
status: "requires_capture",
},
},
PartialCapture: {
Request: {},
Response: {
status: 200,
body: {
status: "partially_captured",
amount: 6500,
amount_capturable: 0,
amount_received: 100,
},
},
},
No3DSAutoCapture: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
currency: "EUR",
customer_acceptance: null,
setup_future_usage: "on_session",
},
Void: {
Request: {},
Response: {
status: 200,
body: {
status: "cancelled",
},
Response: {
status: 200,
body: {
status: "succeeded",
},
},
Refund: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
currency: "EUR",
customer_acceptance: null,
},
Capture: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
currency: "EUR",
customer_acceptance: null,
},
Response: {
status: 200,
body: {
status: "succeeded",
amount: 6500,
amount_capturable: 0,
amount_received: 6500,
},
Response: {
status: 200,
body: {
status: "succeeded",
},
},
},
PartialCapture: {
Request: {},
Response: {
status: 200,
body: {
status: "partially_captured",
amount: 6500,
amount_capturable: 0,
amount_received: 100,
},
},
PartialRefund: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
currency: "EUR",
customer_acceptance: null,
},
Void: {
Request: {},
Response: {
status: 200,
body: {
status: "cancelled",
},
Response: {
status: 200,
body: {
status: "succeeded",
},
},
},
Refund: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
currency: "EUR",
customer_acceptance: null,
},
Response: {
status: 200,
body: {
status: "succeeded",
},
},
SyncRefund: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
currency: "EUR",
customer_acceptance: null,
},
PartialRefund: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
currency: "EUR",
customer_acceptance: null,
},
Response: {
status: 200,
body: {
status: "succeeded",
},
Response: {
status: 200,
body: {
status: "succeeded",
},
},
},
SyncRefund: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
currency: "EUR",
customer_acceptance: null,
},
Response: {
status: 200,
body: {
status: "succeeded",
},
},
ZeroAuthMandate: {
Response: {
status: 501,
body: {
error: {
type: "invalid_request",
message: "Setup Mandate flow for Fiservemea is not implemented",
code: "IR_00",
},
},
ZeroAuthMandate: {
Response: {
status: 501,
body: {
error: {
type: "invalid_request",
message: "Setup Mandate flow for Fiservemea is not implemented",
code: "IR_00",
},
},
},
},
};
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ describe("Rule Based Routing Test", () => {
let res_data = data["Response"];

cy.createJWTToken(req_data, res_data, globalState);
if (should_continue)
should_continue = utils.should_continue_further(res_data);
});

it("merchant retrieve call", () => {
Expand Down
8 changes: 8 additions & 0 deletions cypress-tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ Cypress.Commands.add(
"merchantConnectorId",
response.body.merchant_connector_id
);
globalState.set("connectorId", connectorName);
} else {
cy.task(
"cli_log",
Expand Down Expand Up @@ -391,6 +392,7 @@ Cypress.Commands.add(
"merchantConnectorId",
response.body.merchant_connector_id
);
globalState.set("connectorId", response.body.connector_name);
} else {
cy.task(
"cli_log",
Expand Down Expand Up @@ -459,6 +461,7 @@ Cypress.Commands.add(
expect(globalState.get("connectorId")).to.equal(
response.body.connector_name
);
globalState.set("connectorId", response.body.connector_name);
globalState.set(
"merchantConnectorId",
response.body.merchant_connector_id
Expand Down Expand Up @@ -2121,6 +2124,7 @@ Cypress.Commands.add(
expect(response.headers["content-type"]).to.include("application/json");

if (response.status === 200) {
globalState.set("connectorId", response.body.connector_name);
expect(response.body).to.have.property("id");
globalState.set("routingConfigId", response.body.id);
for (const key in res_data.body) {
Expand Down Expand Up @@ -2180,6 +2184,10 @@ Cypress.Commands.add(
expect(response.headers["content-type"]).to.include("application/json");

if (response.status === 200) {
if (globalState.get("connectorId") === undefined) {
globalState.set("connectorId", response.body.connector_name);
}

expect(response.body.id).to.equal(routing_config_id);
for (const key in res_data.body) {
expect(res_data.body[key]).to.equal(response.body[key]);
Expand Down
Loading
Loading