Skip to content
New issue

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

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

Already on GitHub? # to your account

feat(cypress): add core flow tests #5546

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 187 additions & 0 deletions cypress-tests/cypress/e2e/PaymentTest/00021-CoreFlows.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
import * as fixtures from "../../fixtures/imports";
import State from "../../utils/State";
import { payment_methods_enabled } from "../PaymentUtils/Commons";

let globalState;

describe("Core flows", () => {
context("Merchant core flows", () => {
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
});
});

after("flush global state", () => {
cy.task("setGlobalState", globalState.data);
});

it("merchant create call", () => {
cy.merchantCreateCallTest(fixtures.merchantCreateBody, globalState);
});

it("merchant retrieve call", () => {
cy.merchantRetrieveCall(globalState);
});

it("merchant list call", () => {
cy.merchantListCall(globalState);
});

it("merchant update call", () => {
cy.merchantUpdateCall(fixtures.merchantUpdateBody, globalState);
});
});

context("API key core flows", () => {
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
});
});

after("flush global state", () => {
cy.task("setGlobalState", globalState.data);
});

it("API key create call", () => {
cy.apiKeyCreateTest(fixtures.apiKeyCreateBody, globalState);
});

it("API key update call", () => {
cy.apiKeyUpdateCall(fixtures.apiKeyUpdateBody, globalState);
});

it("API key retrieve call", () => {
cy.apiKeyRetrieveCall(globalState);
});

it("API key list call", () => {
cy.apiKeyListCall(globalState);
});
});

context("Customer core flows", () => {
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
});
});

after("flush global state", () => {
cy.task("setGlobalState", globalState.data);
});

it("Customer create call", () => {
cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);
});
it("Customer list call", () => {
cy.customerListCall(globalState);
});

it("Customer retrieve call", () => {
cy.customerRetrieveCall(globalState);
});

it("Customer update call", () => {
cy.customerUpdateCall(fixtures.customerUpdateBody, globalState);
});

it("Ephemeral key generate call", () => {
cy.ephemeralGenerateCall(globalState);
});
});

context("Merchant Connector Account core flows", () => {
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
});
});

after("flush global state", () => {
cy.task("setGlobalState", globalState.data);
});

context("Create Multiple Merchant Connector Accounts", () => {
it("1st Connector create call", () => {
// `globalState` can only be accessed in the `it` block
const connector_id = globalState.data.connectorId;
cy.createNamedConnectorCallTest(
"payment_processor",
fixtures.createConnectorBody,
payment_methods_enabled,
globalState,
connector_id,
"first_" + connector_id
);
});

it("2nd Connector create call", () => {
// `globalState` can only be accessed in the `it` block
const connector_id = globalState.data.connectorId;
cy.createNamedConnectorCallTest(
"payment_processor",
fixtures.createConnectorBody,
payment_methods_enabled,
globalState,
connector_id,
"second_" + connector_id
);
});
});

it("Connector create call", () => {
cy.createConnectorCallTest(
"payment_processor",
fixtures.createConnectorBody,
payment_methods_enabled,
globalState
);
});

it("Connector retrieve call", () => {
cy.connectorRetrieveCall(globalState);
});

it("Connector update call", () => {
cy.connectorUpdateCall(
"payment_processor",
fixtures.updateConnectorBody,
globalState
);
});

it("List connectors by MID", () => {
cy.connectorListByMid(globalState);
});
});

context("Delete calls", () => {
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
});
});

after("flush global state", () => {
cy.task("setGlobalState", globalState.data);
});

it("Customer delete call", () => {
cy.customerDeleteCall(globalState);
});

it("API key delete call", () => {
cy.apiKeyDeleteCall(globalState);
});

it("Connector delete call", () => {
cy.connectorDeleteCall(globalState);
});

it("Merchant delete call", () => {
cy.merchantDeleteCall(globalState);
});
});
});
8 changes: 8 additions & 0 deletions cypress-tests/cypress/fixtures/imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ import createPayoutBody from "./create-payout-confirm-body.json";
import pmIdConfirmBody from "./create-pm-id-mit.json";
import listRefundCall from "./list-refund-call-body.json";
import merchantCreateBody from "./merchant-create-body.json";
import merchantUpdateBody from "./merchant-update-body.json";
import refundBody from "./refund-flow-body.json";
import routingConfigBody from "./routing-config-body.json";
import saveCardConfirmBody from "./save-card-confirm-body.json";
import apiKeyUpdateBody from "./update-api-key-body.json";
import updateConnectorBody from "./update-connector-body.json";
import customerUpdateBody from "./update-customer-body.json";
import voidBody from "./void-payment-body.json";

export {
apiKeyCreateBody,
apiKeyUpdateBody,
captureBody,
citConfirmBody,
confirmBody,
Expand All @@ -26,12 +31,15 @@ export {
createPaymentBody,
createPayoutBody,
customerCreateBody,
customerUpdateBody,
listRefundCall,
merchantCreateBody,
merchantUpdateBody,
mitConfirmBody,
pmIdConfirmBody,
refundBody,
routingConfigBody,
saveCardConfirmBody,
updateConnectorBody,
voidBody,
};
39 changes: 39 additions & 0 deletions cypress-tests/cypress/fixtures/merchant-update-body.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"merchant_id": "merchant_id",
"merchant_name": "NewAge Retailer",
"locker_id": "m0010",
"merchant_details": {
"primary_contact_person": "joseph Test",
"primary_email": "josephTest@test.com",
"primary_phone": "veniam aute officia ullamco esse",
"secondary_contact_person": "joseph Test2",
"secondary_email": "josephTest2@test.com",
"secondary_phone": "proident adipisicing officia nulla",
"website": "www.example.com",
"about_business": "Online Retail with a wide selection of organic products for North America",
"address": {
"line1": "1467",
"line2": "Harrison Street",
"line3": "Harrison Street",
"city": "San Fransico",
"state": "California",
"zip": "94122",
"country": "US"
}
},
"return_url": "https://duck.com",
"webhook_details": {
"webhook_version": "1.0.1",
"webhook_username": "ekart_retail",
"webhook_password": "password_ekart@123",
"payment_created_enabled": true,
"payment_succeeded_enabled": true,
"payment_failed_enabled": true
},
"sub_merchants_enabled": false,
"parent_merchant_id": "xkkdf909012sdjki2dkh5sdf",
"metadata": {
"city": "NY",
"unit": "245"
}
}
5 changes: 5 additions & 0 deletions cypress-tests/cypress/fixtures/update-api-key-body.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Updated API Key",
"description": "My very awesome API key",
"expiration": null
}
9 changes: 9 additions & 0 deletions cypress-tests/cypress/fixtures/update-connector-body.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"connector_label": "updated_connector_label",
"test_mode": true,
"disabled": false,
"metadata": {
"city": "LA",
"unit": "246"
}
}
11 changes: 11 additions & 0 deletions cypress-tests/cypress/fixtures/update-customer-body.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"email": "JohnTest@test.com",
"name": "John Test",
"phone_country_code": "+65",
"phone": "888888888",
"description": "First customer",
"metadata": {
"city": "NY",
"unit": "245"
}
}
Loading
Loading