Skip to content

Commit

Permalink
feat(cypress): add 2 more payout connectors and bank transfer support…
Browse files Browse the repository at this point in the history
… for payout (#4993)
  • Loading branch information
pixincreate authored Jun 20, 2024
1 parent f84ed6a commit 45a908b
Show file tree
Hide file tree
Showing 16 changed files with 1,437 additions and 73 deletions.
6 changes: 6 additions & 0 deletions cypress-tests/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe("Account Create flow test", () => {
it("merchant-create-call-test", () => {
cy.merchantCreateCallTest(merchantCreateBody, globalState);
});

it("api-key-create-call-test", () => {
cy.apiKeyCreateTest(apiKeyCreateBody, globalState);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ describe("Customer Create flow test", () => {
globalState = new State(state);
});
});

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

it("customer-create-call-test", () => {
cy.createCustomerCallTest(customerCreateBody, globalState);
});
Expand Down
16 changes: 11 additions & 5 deletions cypress-tests/cypress/e2e/PayoutTest/00003-CardTest.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as utils from "../PayoutUtils/utils";

let globalState;

describe("Card - Auto Fulfill", () => {
describe("[Payout] Cards", () => {
let should_continue = true; // variable that will be used to skip tests if a previous test fails

before("seed global state", () => {
Expand All @@ -18,17 +18,18 @@ describe("Card - Auto Fulfill", () => {
});
});

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

beforeEach(function () {
if (!should_continue) {
this.skip();
}
});

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

context("Payout Card with Auto Fulfill", () => {
let should_continue = true; // variable that will be used to skip tests if a previous test fails
it("confirm-payout-call-with-auto-fulfill-test", () => {
let data = utils.getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
Expand All @@ -43,6 +44,7 @@ describe("Card - Auto Fulfill", () => {
true,
globalState
);

if (should_continue)
should_continue = utils.should_continue_further(res_data);
});
Expand All @@ -53,6 +55,8 @@ describe("Card - Auto Fulfill", () => {
});

context("Payout Card with Manual Fulfill - Create Confirm", () => {
let should_continue = true; // variable that will be used to skip tests if a previous test fails

it("confirm-payout-call-with-manual-fulfill-test", () => {
let data = utils.getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
Expand Down Expand Up @@ -88,6 +92,8 @@ describe("Card - Auto Fulfill", () => {
});

context("Payout Card with Manual Fulfill - Create Intent + Confirm", () => {
let should_continue = true; // variable that will be used to skip tests if a previous test fails

it("create-payout-call", () => {
let data = utils.getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
Expand Down
242 changes: 242 additions & 0 deletions cypress-tests/cypress/e2e/PayoutTest/00004-BankTransfer.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
import createPayoutBody from "../../fixtures/create-payout-confirm-body.json";
import State from "../../utils/State";
import * as utils from "../PayoutUtils/utils";

let globalState;

// TODO: Add test for Bank Transfer - ACH
describe("[Payout] [Bank Transfer - ACH]", () => {
let should_continue = true; // variable that will be used to skip tests if a previous test fails

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

// Check if the connector supports card payouts (based on the connector configuration in creds)
if (!globalState.get("payoutsExecution")) {
should_continue = false;
}
});
});

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

beforeEach(function () {
if (!should_continue) {
this.skip();
}
});
});

// TODO: Add test for Bank Transfer - BACS
describe("[Payout] [Bank Transfer - BACS]", () => {
let should_continue = true; // variable that will be used to skip tests if a previous test fails

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

// Check if the connector supports card payouts (based on the connector configuration in creds)
if (!globalState.get("payoutsExecution")) {
should_continue = false;
}
});
});

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

beforeEach(function () {
if (!should_continue) {
this.skip();
}
});
});

describe("[Payout] [Bank Transfer - SEPA]", () => {
let should_continue = true; // variable that will be used to skip tests if a previous test fails

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

// Check if the connector supports card payouts (based on the connector configuration in creds)
if (!globalState.get("payoutsExecution")) {
should_continue = false;
}
});
});

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

beforeEach(function () {
if (!should_continue) {
this.skip();
}
});

context("[Payout] [Bank transfer - SEPA] Auto Fulfill", () => {
let should_continue = true; // variable that will be used to skip tests if a previous test fails

it("confirm-payout-call-with-auto-fulfill-test", () => {
let data = utils.getConnectorDetails(globalState.get("connectorId"))[
"bank_transfer_pm"
]["sepa"]["Fulfill"];

let req_data = data["Request"];
let res_data = data["Response"];
cy.createConfirmPayoutTest(
createPayoutBody,
req_data,
res_data,
true,
true,
globalState
);
if (should_continue)
should_continue = utils.should_continue_further(res_data);
});

it("retrieve-payout-call-test", () => {
cy.retrievePayoutCallTest(globalState);
});
});

context("[Payout] [Bank transfer - SEPA] Manual Fulfill", () => {
let should_continue = true; // variable that will be used to skip tests if a previous test fails

it("confirm-payout-call-with-manual-fulfill-test", () => {
let data = utils.getConnectorDetails(globalState.get("connectorId"))[
"bank_transfer_pm"
]["sepa"]["Confirm"];
let req_data = data["Request"];
let res_data = data["Response"];
cy.createConfirmPayoutTest(
createPayoutBody,
req_data,
res_data,
true,
false,
globalState
);
if (should_continue)
should_continue = utils.should_continue_further(res_data);
});

it("fulfill-payout-call-test", () => {
let data = utils.getConnectorDetails(globalState.get("connectorId"))[
"bank_transfer_pm"
]["sepa"]["Fulfill"];
let req_data = data["Request"];
let res_data = data["Response"];
cy.fulfillPayoutCallTest({}, req_data, res_data, globalState);
if (should_continue)
should_continue = utils.should_continue_further(res_data);
});

it("retrieve-payout-call-test", () => {
cy.retrievePayoutCallTest(globalState);
});
});

context("[Payout] [Bank transfer - SEPA] Manual Confirm", () => {
let should_continue = true; // variable that will be used to skip tests if a previous test fails

it("confirm-payout-call-with-manual-confirm-test", () => {
let data = utils.getConnectorDetails(globalState.get("connectorId"))[
"bank_transfer_pm"
]["sepa"]["Create"];
let req_data = data["Request"];
let res_data = data["Response"];
cy.createConfirmPayoutTest(
createPayoutBody,
req_data,
res_data,
false,
true,
globalState
);
if (should_continue)
should_continue = utils.should_continue_further(res_data);
});

it("confirm-payout-call", () => {
let data = utils.getConnectorDetails(globalState.get("connectorId"))[
"bank_transfer_pm"
]["sepa"]["Confirm"];
let req_data = data["Request"];
let res_data = data["Response"];
cy.updatePayoutCallTest({}, req_data, res_data, false, globalState);
if (should_continue)
should_continue = utils.should_continue_further(res_data);
});

it("fulfill-payout-call-test", () => {
let data = utils.getConnectorDetails(globalState.get("connectorId"))[
"bank_transfer_pm"
]["sepa"]["Fulfill"];
let req_data = data["Request"];
let res_data = data["Response"];
cy.fulfillPayoutCallTest({}, req_data, res_data, globalState);
if (should_continue)
should_continue = utils.should_continue_further(res_data);
});

it("retrieve-payout-call-test", () => {
cy.retrievePayoutCallTest(globalState);
});
});

context("[Payout] [Bank transfer - SEPA] Manual", () => {
let should_continue = true; // variable that will be used to skip tests if a previous test fails

it("create-payout-call", () => {
let data = utils.getConnectorDetails(globalState.get("connectorId"))[
"bank_transfer_pm"
]["sepa"]["Create"];
let req_data = data["Request"];
let res_data = data["Response"];
cy.createConfirmPayoutTest(
createPayoutBody,
req_data,
res_data,
false,
false,
globalState
);
if (should_continue)
should_continue = utils.should_continue_further(res_data);
});

it("confirm-payout-call", () => {
let data = utils.getConnectorDetails(globalState.get("connectorId"))[
"bank_transfer_pm"
]["sepa"]["Confirm"];
let req_data = data["Request"];
let res_data = data["Response"];
cy.updatePayoutCallTest({}, req_data, res_data, false, globalState);
if (should_continue)
should_continue = utils.should_continue_further(res_data);
});

it("fulfill-payout-call-test", () => {
let data = utils.getConnectorDetails(globalState.get("connectorId"))[
"bank_transfer_pm"
]["sepa"]["Fulfill"];
let req_data = data["Request"];
let res_data = data["Response"];
cy.fulfillPayoutCallTest({}, req_data, res_data, globalState);
if (should_continue)
should_continue = utils.should_continue_further(res_data);
});

it("retrieve-payout-call-test", () => {
cy.retrievePayoutCallTest(globalState);
});
});
});
Loading

0 comments on commit 45a908b

Please sign in to comment.