Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

fix(cypress): stop customerId from leaking across specs, fix confirmCallTest mandate tracking (#13935)

HS-QUALIBOT6b08996a86fa
diff --git a/cypress-tests/cypress/e2e/configs/Payment/StripeConnect.js b/cypress-tests/cypress/e2e/configs/Payment/StripeConnect.js
index 82f34b66cb..5990baf822 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/StripeConnect.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/StripeConnect.js
@@ -318,8 +318,8 @@ export const connectorDetails = {
error_code: "card_declined",
error_message:
"message - Your card was declined., decline_code - generic_decline",
- unified_code: "UE_1000",
- unified_message: "Issue with Payment Method details",
+ unified_code: "UE_3000",
+ unified_message: "Technical issue with PSP",
},
},
},
diff --git a/cypress-tests/cypress/e2e/spec/Payment/11-CreateSingleuseMandate.cy.js b/cypress-tests/cypress/e2e/spec/Payment/11-CreateSingleuseMandate.cy.js
index 16270e3285..4d53706d1e 100644
--- a/cypress-tests/cypress/e2e/spec/Payment/11-CreateSingleuseMandate.cy.js
+++ b/cypress-tests/cypress/e2e/spec/Payment/11-CreateSingleuseMandate.cy.js
@@ -3,6 +3,7 @@ import State from "../../../utils/State";
import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
let globalState;
+let originalCustomerId;
describe("Card - SingleUse Mandates flow test", () => {
before(function () {
@@ -12,6 +13,7 @@ describe("Card - SingleUse Mandates flow test", () => {
cy.task("getGlobalState")
.then((state) => {
globalState = new State(state);
+ originalCustomerId = globalState.get("customerId");
// Skip running test against a connector that is added in the exclude list
if (
@@ -31,6 +33,11 @@ describe("Card - SingleUse Mandates flow test", () => {
});
after("flush global state", () => {
+ // This spec's contexts create their own customers for local mandate
+ // testing, overwriting globalState.customerId. Restore the original
+ // customer before flushing so later specs don't inherit one scoped to
+ // this spec's own mandate tests.
+ globalState.set("customerId", originalCustomerId);
cy.task("setGlobalState", globalState.data);
});
diff --git a/cypress-tests/cypress/e2e/spec/Payment/14-SaveCardFlow.cy.js b/cypress-tests/cypress/e2e/spec/Payment/14-SaveCardFlow.cy.js
index 97a52209bd..4a0663797f 100644
--- a/cypress-tests/cypress/e2e/spec/Payment/14-SaveCardFlow.cy.js
+++ b/cypress-tests/cypress/e2e/spec/Payment/14-SaveCardFlow.cy.js
@@ -4,6 +4,7 @@ import State from "../../../utils/State";
import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
let globalState;
+let originalCustomerId;
describe("Card - SaveCard payment flow test", () => {
before("seed global state", function () {
@@ -12,6 +13,7 @@ describe("Card - SaveCard payment flow test", () => {
cy.task("getGlobalState")
.then((state) => {
globalState = new State(state);
+ originalCustomerId = globalState.get("customerId");
const connector = globalState.get("connectorId");
if (
utils.shouldExcludeConnector(
@@ -30,6 +32,11 @@ describe("Card - SaveCard payment flow test", () => {
});
after("flush global state", () => {
+ // This spec's contexts create their own customers for local save-card
+ // testing, overwriting globalState.customerId. Restore the original
+ // customer before flushing so later specs don't inherit one scoped to
+ // this spec's own tests.
+ globalState.set("customerId", originalCustomerId);
cy.task("setGlobalState", globalState.data);
});
diff --git a/cypress-tests/cypress/e2e/spec/Payment/15-ZeroAuthMandate.cy.js b/cypress-tests/cypress/e2e/spec/Payment/15-ZeroAuthMandate.cy.js
index aab3931983..0f03a54b43 100644
--- a/cypress-tests/cypress/e2e/spec/Payment/15-ZeroAuthMandate.cy.js
+++ b/cypress-tests/cypress/e2e/spec/Payment/15-ZeroAuthMandate.cy.js
@@ -3,6 +3,7 @@ import State from "../../../utils/State";
import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
let globalState;
+let originalCustomerId;
describe("Card - SingleUse Mandates flow test", () => {
before("seed global state", function () {
@@ -11,6 +12,7 @@ describe("Card - SingleUse Mandates flow test", () => {
cy.task("getGlobalState")
.then((state) => {
globalState = new State(state);
+ originalCustomerId = globalState.get("customerId");
// Skip running test against a connector that is added in the exclude list
if (
@@ -30,6 +32,12 @@ describe("Card - SingleUse Mandates flow test", () => {
});
after("flush global state", () => {
+ // This spec's contexts create their own customers for local mandate/PMID
+ // testing, overwriting globalState.customerId along the way. Restore the
+ // original customer before flushing so later specs (which just read
+ // globalState.customerId) don't inherit a customer scoped to this spec's
+ // own mandate tests.
+ globalState.set("customerId", originalCustomerId);
cy.task("setGlobalState", globalState.data);
});
diff --git a/cypress-tests/cypress/e2e/spec/Payment/20-MandatesUsingPMID.cy.js b/cypress-tests/cypress/e2e/spec/Payment/20-MandatesUsingPMID.cy.js
index 0e0d9aa9d7..9ac00dd31b 100644
--- a/cypress-tests/cypress/e2e/spec/Payment/20-MandatesUsingPMID.cy.js
+++ b/cypress-tests/cypress/e2e/spec/Payment/20-MandatesUsingPMID.cy.js
@@ -3,11 +3,13 @@ import State from "../../../utils/State";
import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
let globalState;
+let originalCustomerId;
describe("Card - Mandates using Payment Method Id flow test", () => {
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
+ originalCustomerId = globalState.get("customerId");
});
});
@@ -15,6 +17,16 @@ describe("Card - Mandates using Payment Method Id flow test", () => {
cy.task("setGlobalState", globalState.data);
});
+ after("restore customerId", () => {
+ // Most tests in this spec intentionally continue using a customer
+ // created by an earlier test in the same file, so customerId can't be
+ // restored after every test. Restore it only once, after the whole
+ // spec finishes, so later specs don't inherit a customer scoped to
+ // this spec's own tests.
+ globalState.set("customerId", originalCustomerId);
+ cy.task("setGlobalState", globalState.data);
+ });
+
context(
"Card - NoThreeDS Create and Confirm Automatic CIT and MIT payment flow test",
() => {
diff --git a/cypress-tests/cypress/e2e/spec/Payment/23-Variations.cy.js b/cypress-tests/cypress/e2e/spec/Payment/23-Variations.cy.js
index cebb63b26f..0f78c1830f 100644
--- a/cypress-tests/cypress/e2e/spec/Payment/23-Variations.cy.js
+++ b/cypress-tests/cypress/e2e/spec/Payment/23-Variations.cy.js
@@ -897,13 +897,21 @@ describe("Corner cases", () => {
});
context("Duplicate Customer ID", () => {
+ let originalCustomerId;
+
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
+ originalCustomerId = globalState.get("customerId");
});
});
after("flush global state", () => {
+ // This context creates its own customers to test duplicate-ID
+ // handling, overwriting globalState.customerId. Restore the original
+ // customer before flushing so later specs don't inherit one scoped
+ // to this test.
+ globalState.set("customerId", originalCustomerId);
cy.task("setGlobalState", globalState.data);
});
diff --git a/cypress-tests/cypress/e2e/spec/Payment/24-PaymentMethods.cy.js b/cypress-tests/cypress/e2e/spec/Payment/24-PaymentMethods.cy.js
index 163e282055..27c9ad5cb8 100644
--- a/cypress-tests/cypress/e2e/spec/Payment/24-PaymentMethods.cy.js
+++ b/cypress-tests/cypress/e2e/spec/Payment/24-PaymentMethods.cy.js
@@ -3,11 +3,13 @@ import State from "../../../utils/State";
import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
let globalState;
+let originalCustomerId;
describe("Payment Methods Tests", () => {
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
+ originalCustomerId = globalState.get("customerId");
});
});
@@ -15,6 +17,17 @@ describe("Payment Methods Tests", () => {
cy.task("setGlobalState", globalState.data);
});
+ after("restore customerId", () => {
+ // Some tests in this spec intentionally continue using a customer
+ // created by an earlier test in the same file (e.g. "Set default
+ // payment method" reuses "Create payment method for customer"'s
+ // customer), so customerId can't be restored after every test.
+ // Restore it only once, after the whole spec finishes, so later specs
+ // don't inherit a customer scoped to this spec's own tests.
+ globalState.set("customerId", originalCustomerId);
+ cy.task("setGlobalState", globalState.data);
+ });
+
context("Create payment method for customer", () => {
it("Create customer -> Create Payment Method -> List PM for customer", () => {
cy.step("Create customer", () => {
diff --git a/cypress-tests/cypress/e2e/spec/Payment/25-ConnectorAgnosticNTID.cy.js b/cypress-tests/cypress/e2e/spec/Payment/25-ConnectorAgnosticNTID.cy.js
index 4e247fee68..5cb2d048e1 100644
--- a/cypress-tests/cypress/e2e/spec/Payment/25-ConnectorAgnosticNTID.cy.js
+++ b/cypress-tests/cypress/e2e/spec/Payment/25-ConnectorAgnosticNTID.cy.js
@@ -5,6 +5,7 @@ import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
let globalState;
let connector;
+let originalCustomerId;
/*
Flow:
@@ -64,6 +65,7 @@ describe("Connector Agnostic Tests", () => {
cy.task("getGlobalState")
.then((state) => {
globalState = new State(state);
+ originalCustomerId = globalState.get("customerId");
connector = globalState.get("connectorId");
if (
@@ -83,6 +85,11 @@ describe("Connector Agnostic Tests", () => {
});
after("flush global state", () => {
+ // This spec's contexts create their own customers for local NTID
+ // testing, overwriting globalState.customerId. Restore the original
+ // customer before flushing so later specs don't inherit one scoped to
+ // this spec's own tests.
+ globalState.set("customerId", originalCustomerId);
cy.task("setGlobalState", globalState.data);
});
diff --git a/cypress-tests/cypress/e2e/spec/Payment/27-DeletedCustomerPsyncFlow.cy.js b/cypress-tests/cypress/e2e/spec/Payment/27-DeletedCustomerPsyncFlow.cy.js
index 6330819abe..8e5bc59237 100644
--- a/cypress-tests/cypress/e2e/spec/Payment/27-DeletedCustomerPsyncFlow.cy.js
+++ b/cypress-tests/cypress/e2e/spec/Payment/27-DeletedCustomerPsyncFlow.cy.js
@@ -3,15 +3,23 @@ import State from "../../../utils/State";
import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
let globalState;
+let originalCustomerId;
describe("Card - Customer Deletion and Psync", () => {
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
+ originalCustomerId = globalState.get("customerId");
});
});
afterEach("flush global state", () => {
+ // Every test in this spec creates its own customer and deletes it via
+ // customerDeleteCall, which doesn't clear globalState.customerId
+ // afterward. Restore the pre-spec customer before flushing so later
+ // specs (which just read globalState.customerId) don't inherit an ID
+ // that's just been deleted.
+ globalState.set("customerId", originalCustomerId);
cy.task("setGlobalState", globalState.data);
});
diff --git a/cypress-tests/cypress/e2e/spec/Payment/28-BusinessProfileConfigs.cy.js b/cypress-tests/cypress/e2e/spec/Payment/28-BusinessProfileConfigs.cy.js
index 03306fb4fe..eea0c13076 100644
--- a/cypress-tests/cypress/e2e/spec/Payment/28-BusinessProfileConfigs.cy.js
+++ b/cypress-tests/cypress/e2e/spec/Payment/28-BusinessProfileConfigs.cy.js
@@ -4,15 +4,22 @@ import { payment_methods_enabled } from "../../configs/Payment/Commons";
import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
let globalState;
+let originalCustomerId;
describe("Config Tests", () => {
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
+ originalCustomerId = globalState.get("customerId");
});
});
after("flush global state", () => {
+ // Some contexts in this spec create their own customers, overwriting
+ // globalState.customerId. Restore the original customer before
+ // flushing so later specs don't inherit one scoped to this spec's
+ // own tests.
+ globalState.set("customerId", originalCustomerId);
cy.task("setGlobalState", globalState.data);
});
diff --git a/cypress-tests/cypress/e2e/spec/Payment/32-DDCRaceCondition.cy.js b/cypress-tests/cypress/e2e/spec/Payment/32-DDCRaceCondition.cy.js
index c7f17605b9..23fca1f5f6 100644
--- a/cypress-tests/cypress/e2e/spec/Payment/32-DDCRaceCondition.cy.js
+++ b/cypress-tests/cypress/e2e/spec/Payment/32-DDCRaceCondition.cy.js
@@ -24,6 +24,7 @@ import * as utils from "../../configs/Payment/Utils";
let connector;
let globalState;
+let originalCustomerId;
describe("[Payment] DDC Race Condition", () => {
before(function () {
@@ -32,6 +33,7 @@ describe("[Payment] DDC Race Condition", () => {
cy.task("getGlobalState")
.then((state) => {
globalState = new State(state);
+ originalCustomerId = globalState.get("customerId");
connector = globalState.get("connectorId");
if (
@@ -75,6 +77,11 @@ describe("[Payment] DDC Race Condition", () => {
});
afterEach("comprehensive cleanup", () => {
+ // This spec creates its own customer for local DDC testing, overwriting
+ // globalState.customerId. Restore the original customer before
+ // flushing so later specs don't inherit one scoped to this spec's own
+ // tests.
+ globalState.set("customerId", originalCustomerId);
cy.task("setGlobalState", globalState.data);
});
diff --git a/cypress-tests/cypress/e2e/spec/Payment/40-ExternalVault.cy.js b/cypress-tests/cypress/e2e/spec/Payment/40-ExternalVault.cy.js
index 02edd94d9a..fe4a94c914 100644
--- a/cypress-tests/cypress/e2e/spec/Payment/40-ExternalVault.cy.js
+++ b/cypress-tests/cypress/e2e/spec/Payment/40-ExternalVault.cy.js
@@ -4,6 +4,7 @@ import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
import { isMockServer } from "../../../support/mitmProxy";
let globalState;
+let originalCustomerId;
const VGS_CONNECTOR_NAME = "vgs";
@@ -11,10 +12,16 @@ describe("External Vault (VGS) - Connector Integration Tests", () => {
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
+ originalCustomerId = globalState.get("customerId");
});
});
after("flush global state", () => {
+ // This spec's contexts create their own customers for local vault
+ // testing, overwriting globalState.customerId. Restore the original
+ // customer before flushing so later specs don't inherit one scoped to
+ // this spec's own tests.
+ globalState.set("customerId", originalCustomerId);
cy.task("setGlobalState", globalState.data);
});
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index 91b5ad0910..f4a7193519 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -3261,6 +3261,16 @@ Cypress.Commands.add(
).to.not.be.empty;
}
globalState.set("paymentIntentStatus", response.body.status);
+ // Lets mitUsingPMId know whether the connector actually supports
+ // mandates, or was silently downgraded to on_session. Mirrors the
+ // same tracking done in citForMandatesCallTest, so MIT tests that
+ // follow a plain confirmCallTest CIT (e.g. zero-auth PMID flows)
+ // check the real response from this confirm instead of a stale or
+ // unset value.
+ globalState.set(
+ "mandateSetupFutureUsage",
+ response.body.setup_future_usage
+ );
// Compare connector with backend connector name (handles stripeconnect -> stripe mapping)
const expectedConnector = getOriginalConnectorName(
globalState.get("connectorId")