Skip to content

Commit

Permalink
ci: add tests that make use of locker (juspay#6735)
Browse files Browse the repository at this point in the history
  • Loading branch information
pixincreate authored Dec 26, 2024
1 parent 313661b commit 295d3dd
Show file tree
Hide file tree
Showing 13 changed files with 638 additions and 208 deletions.
37 changes: 17 additions & 20 deletions cypress-tests/cypress/e2e/PaymentTest/00003-ConnectorCreate.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as fixtures from "../../fixtures/imports";
import State from "../../utils/State";
import { payment_methods_enabled } from "../PaymentUtils/Commons";
import * as utils from "../PaymentUtils/Utils";

let globalState;
describe("Connector Account Create flow test", () => {
Expand All @@ -14,7 +15,7 @@ describe("Connector Account Create flow test", () => {
cy.task("setGlobalState", globalState.data);
});

it("connector-create-call-test", () => {
it("Create merchant connector account", () => {
cy.createConnectorCallTest(
"payment_processor",
fixtures.createConnectorBody,
Expand All @@ -23,31 +24,27 @@ describe("Connector Account Create flow test", () => {
);
});

it("check and create multiple connectors", () => {
const multiple_connectors = Cypress.env("MULTIPLE_CONNECTORS");
// multiple_connectors will be undefined if not set in the env
if (multiple_connectors?.status) {
// Create multiple connectors based on the count
// The first connector is already created when creating merchant account, so start from 1
for (let i = 1; i < multiple_connectors.count; i++) {
cy.createBusinessProfileTest(
// subsequent profile and mca ids should check for the existence of multiple connectors
context(
"Create another business profile and merchant connector account if MULTIPLE_CONNECTORS flag is true",
() => {
it("Create business profile", () => {
utils.createBusinessProfile(
fixtures.businessProfile.bpCreate,
globalState,
"profile" + i
{ nextConnector: true }
);
cy.createConnectorCallTest(
});

it("Create merchant connector account", () => {
utils.createMerchantConnectorAccount(
"payment_processor",
fixtures.createConnectorBody,
payment_methods_enabled,
globalState,
`profile${i}`,
`merchantConnector${i}`
payment_methods_enabled,
{ nextConnector: true }
);
}
} else {
cy.log(
"Multiple connectors not enabled. Skipping creation of multiple profiles and respective MCAs"
);
});
}
});
);
});
19 changes: 19 additions & 0 deletions cypress-tests/cypress/e2e/PaymentTest/00023-PaymentMethods.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,23 @@ describe("Payment Methods Tests", () => {
cy.setDefaultPaymentMethodTest(globalState);
});
});

context("Delete payment method for customer", () => {
it("Create customer", () => {
cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);
});

it("Create Payment Method", () => {
const data = getConnectorDetails("commons")["card_pm"]["PaymentMethod"];
cy.createPaymentMethodTest(globalState, data);
});

it("List PM for customer", () => {
cy.listCustomerPMCallTest(globalState);
});

it("Delete Payment Method for a customer", () => {
cy.deletePaymentMethodTest(globalState);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,32 @@ import getConnectorDetails, * as utils from "../PaymentUtils/Utils";

let globalState;

/*
Flow:
- Create Business Profile with connector agnostic feature disabled
- Create Merchant Connector Account and Customer
- Make a Payment
- List Payment Method for Customer using Client Secret (will get PMID)
- Create Business Profile with connector agnostic feature enabled
- Create Merchant Connector Account
- Create Payment Intent
- List Payment Method for Customer -- Empty list; i.e., no payment method should be listed
- Confirm Payment with PMID from previous step (should fail as Connector Mandate ID is not present in the newly created Profile)
- Create Business Profile with connector agnostic feature enabled
- Create Merchant Connector Account and Customer
- Make a Payment
- List Payment Method for Customer using Client Secret (will get PMID)
- Create Business Profile with connector agnostic feature enabled
- Create Merchant Connector Account
- Create Payment Intent
- List Payment Method for Customer using Client Secret (will get PMID which is same as the one from previous step along with Payment Token)
- Confirm Payment with PMID from previous step (should pass as NTID is present in the DB)
*/

describe("Connector Agnostic Tests", () => {
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
Expand All @@ -26,19 +52,19 @@ describe("Connector Agnostic Tests", () => {
}
});

it("Create Business Profile", () => {
cy.createBusinessProfileTest(
it("Create business profile", () => {
utils.createBusinessProfile(
fixtures.businessProfile.bpCreate,
globalState
);
});

it("connector-create-call-test", () => {
cy.createConnectorCallTest(
it("Create merchant connector account", () => {
utils.createMerchantConnectorAccount(
"payment_processor",
fixtures.createConnectorBody,
payment_methods_enabled,
globalState
globalState,
payment_methods_enabled
);
});

Expand Down Expand Up @@ -78,24 +104,24 @@ describe("Connector Agnostic Tests", () => {
cy.listCustomerPMByClientSecret(globalState);
});

it("Create Business Profile", () => {
cy.createBusinessProfileTest(
it("Create business profile", () => {
utils.createBusinessProfile(
fixtures.businessProfile.bpCreate,
globalState
);
});

it("connector-create-call-test", () => {
cy.createConnectorCallTest(
it("Create merchant connector account", () => {
utils.createMerchantConnectorAccount(
"payment_processor",
fixtures.createConnectorBody,
payment_methods_enabled,
globalState
globalState,
payment_methods_enabled
);
});

it("Enable Connector Agnostic for Business Profile", () => {
cy.UpdateBusinessProfileTest(
utils.updateBusinessProfile(
fixtures.businessProfile.bpUpdate,
true, // is_connector_agnostic_enabled
false, // collect_billing_address_from_wallet_connector
Expand Down Expand Up @@ -126,6 +152,80 @@ describe("Connector Agnostic Tests", () => {
it("List Payment Method for Customer", () => {
cy.listCustomerPMByClientSecret(globalState);
});

it("Confirm No 3DS MIT (PMID)", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["MITAutoCapture"];
const commonData = getConnectorDetails(globalState.get("commons"))[
"card_pm"
]["MITAutoCapture"];

const newData = {
...data,
Response: utils.getConnectorFlowDetails(
data,
commonData,
"ResponseCustom"
),
};

cy.mitUsingPMId(
fixtures.pmIdConfirmBody,
newData,
7000,
true,
"automatic",
globalState
);
});

it("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntentOffSession"];

cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"no_three_ds",
"automatic",
globalState
);

if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});

it("List Payment Method for Customer", () => {
cy.listCustomerPMByClientSecret(globalState);
});

it("Confirm No 3DS MIT (Token)", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["SaveCardConfirmAutoCaptureOffSession"];
const commonData = getConnectorDetails(globalState.get("commons"))[
"card_pm"
]["SaveCardConfirmAutoCaptureOffSession"];

const newData = {
...data,
Response: utils.getConnectorFlowDetails(
data,
commonData,
"ResponseCustom"
),
};
cy.saveCardConfirmCallTest(
fixtures.saveCardConfirmBody,
newData,
globalState
);

if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});
}
);

Expand All @@ -138,19 +238,19 @@ describe("Connector Agnostic Tests", () => {
}
});

it("Create Business Profile", () => {
cy.createBusinessProfileTest(
it("Create business profile", () => {
utils.createBusinessProfile(
fixtures.businessProfile.bpCreate,
globalState
);
});

it("connector-create-call-test", () => {
cy.createConnectorCallTest(
it("Create merchant connector account", () => {
utils.createMerchantConnectorAccount(
"payment_processor",
fixtures.createConnectorBody,
payment_methods_enabled,
globalState
globalState,
payment_methods_enabled
);
});

Expand All @@ -159,7 +259,7 @@ describe("Connector Agnostic Tests", () => {
});

it("Enable Connector Agnostic for Business Profile", () => {
cy.UpdateBusinessProfileTest(
utils.updateBusinessProfile(
fixtures.businessProfile.bpUpdate,
true, // is_connector_agnostic_enabled
false, // collect_billing_address_from_wallet_connector
Expand Down Expand Up @@ -200,24 +300,24 @@ describe("Connector Agnostic Tests", () => {
cy.listCustomerPMByClientSecret(globalState);
});

it("Create Business Profile", () => {
cy.createBusinessProfileTest(
it("Create business profile", () => {
utils.createBusinessProfile(
fixtures.businessProfile.bpCreate,
globalState
);
});

it("connector-create-call-test", () => {
cy.createConnectorCallTest(
it("Create merchant connector account", () => {
utils.createMerchantConnectorAccount(
"payment_processor",
fixtures.createConnectorBody,
payment_methods_enabled,
globalState
globalState,
payment_methods_enabled
);
});

it("Enable Connector Agnostic for Business Profile", () => {
cy.UpdateBusinessProfileTest(
utils.updateBusinessProfile(
fixtures.businessProfile.bpUpdate,
true, // is_connector_agnostic_enabled
false, // collect_billing_address_from_wallet_connector
Expand Down Expand Up @@ -247,5 +347,54 @@ describe("Connector Agnostic Tests", () => {
it("List Payment Method for Customer", () => {
cy.listCustomerPMByClientSecret(globalState);
});

it("Confirm No 3DS MIT (PMID)", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["MITAutoCapture"];

cy.mitUsingPMId(
fixtures.pmIdConfirmBody,
data,
7000,
true,
"automatic",
globalState
);
});

it("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntentOffSession"];

cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"no_three_ds",
"automatic",
globalState
);

if (shouldContinue) shouldContinue = utils.should_continue_further(data);
});

it("List Payment Method for Customer", () => {
cy.listCustomerPMByClientSecret(globalState);
});

it("Confirm No 3DS MIT (Token)", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["SaveCardConfirmAutoCaptureOffSession"];

cy.saveCardConfirmCallTest(
fixtures.saveCardConfirmBody,
data,
globalState
);

if (shouldContinue) shouldContinue = utils.should_continue_further(data);
});
});
});
Loading

0 comments on commit 295d3dd

Please sign in to comment.