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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
test(cypress): Card Issuer Management Tests (#12087)
HS-QUALIBOTd68000403561
diff --git a/cypress-tests/cypress/e2e/spec/Misc/00002-CardIssuerManagement.cy.js b/cypress-tests/cypress/e2e/spec/Misc/00002-CardIssuerManagement.cy.jsnew file mode 100644index 0000000000..cde49e71f4--- /dev/null+++ b/cypress-tests/cypress/e2e/spec/Misc/00002-CardIssuerManagement.cy.js@@ -0,0 +1,85 @@+import * as fixtures from "../../../fixtures/imports";+import State from "../../../utils/State";++let globalState;++describe("Card Issuer Management", () => {+ before("seed global state and create merchant account", () => {+ cy.task("getGlobalState").then((state) => {+ globalState = new State(state);+ // Check if merchant account already exists+ if (!globalState.get("merchantId") || !globalState.get("apiKey")) {+ // Create merchant account using admin API key+ return cy+ .merchantCreateCallTest(fixtures.merchantCreateBody, globalState)+ .then(() => {+ // Create merchant API key for listCardIssuers calls+ return cy.apiKeyCreateTest(fixtures.apiKeyCreateBody, globalState);+ });+ }+ });+ });++ after("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ afterEach("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ context("Happy Path Tests", () => {+ it("should create a new card issuer", () => {+ const issuerName = `Test Issuer ${Date.now()}`;+ cy.createCardIssuer({ issuer_name: issuerName }, globalState);+ });++ it("should list card issuers", () => {+ cy.listCardIssuers("", 30, globalState);+ });++ it("should update an existing card issuer", () => {+ const newName = `Updated Issuer ${Date.now()}`;+ cy.updateCardIssuer(+ globalState.get("cardIssuerId"),+ { issuer_name: newName },+ globalState+ );+ });++ it("should list card issuers with query filter", () => {+ const query = "Updated";+ cy.listCardIssuers(query, 30, globalState);+ });+ });++ context("Negative Tests", () => {+ it("should fail to create issuer with missing required field", () => {+ cy.createCardIssuer({}, globalState);+ });++ it("should fail to create issuer with duplicate name", () => {+ const issuerName =+ globalState.get("cardIssuerName") || `Duplicate Test ${Date.now()}`;+ cy.createCardIssuer({ issuer_name: issuerName }, globalState);+ });+ });++ context("Edge Case Tests", () => {+ it("should handle listing with limit of 1", () => {+ cy.listCardIssuers("", 1, globalState);+ });++ it("should handle listing with empty query", () => {+ cy.listCardIssuers("", 50, globalState);+ });++ it("should fail to update non-existent issuer", () => {+ cy.updateCardIssuer(+ "non-existent-id-12345",+ { issuer_name: "New Name" },+ globalState+ );+ });+ });+});diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex 07ceffe150..5d573c7861 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -7150,3 +7150,103 @@ Cypress.Commands.add(}});++// ============================================+// Card Issuer Management Commands+// ============================================++Cypress.Commands.add("createCardIssuer", (body, globalState) => {+ const apiKey = globalState.get("adminApiKey");+ const baseUrl = globalState.get("baseUrl");++ cy.request({+ method: "POST",+ url: `${baseUrl}/card_issuers`,+ headers: {+ "Content-Type": "application/json",+ "api-key": apiKey,+ },+ body: body,+ failOnStatusCode: false,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ if (response.status === 200) {+ globalState.set("cardIssuerId", response.body.id);+ globalState.set("cardIssuerName", response.body.issuer_name);+ expect(response.body).to.have.property("id");+ expect(response.body).to.have.property("issuer_name");+ expect(response.body.issuer_name).to.equal(body.issuer_name);+ } else if (response.status === 400) {+ expect(response.body.error).to.exist;+ } else if (response.status === 409) {+ expect(response.body.error).to.exist;+ expect(response.body.error.code).to.equal("IR_00");+ }+ });+ });+});++Cypress.Commands.add("listCardIssuers", (query, limit, globalState) => {+ const apiKey = globalState.get("apiKey");+ const baseUrl = globalState.get("baseUrl");+ const queryParams = [];+ if (query) queryParams.push(`query=${encodeURIComponent(query)}`);+ if (limit) queryParams.push(`limit=${limit}`);+ const queryString = queryParams.length > 0 ? `?${queryParams.join("&")}` : "";++ cy.request({+ method: "GET",+ url: `${baseUrl}/card_issuers${queryString}`,+ headers: {+ "Content-Type": "application/json",+ "api-key": apiKey,+ },+ failOnStatusCode: false,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ expect(response.status).to.equal(200);+ if (response.body.data) {+ expect(Array.isArray(response.body.data)).to.be.true;+ if (limit && response.body.data.length > 0) {+ expect(response.body.data.length).to.be.at.most(limit);+ }+ }+ });+ });+});++Cypress.Commands.add("updateCardIssuer", (id, body, globalState) => {+ const apiKey = globalState.get("adminApiKey");+ const baseUrl = globalState.get("baseUrl");++ cy.request({+ method: "PUT",+ url: `${baseUrl}/card_issuers/${id}`,+ headers: {+ "Content-Type": "application/json",+ "api-key": apiKey,+ },+ body: body,+ failOnStatusCode: false,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ if (response.status === 200) {+ expect(response.body).to.have.property("id", id);+ expect(response.body).to.have.property("issuer_name");+ if (body.issuer_name) {+ expect(response.body.issuer_name).to.equal(body.issuer_name);+ }+ } else if (response.status === 404) {+ expect(response.status).to.equal(404);+ } else if (response.status === 400) {+ expect(response.body.error).to.exist;+ }+ });+ });+});