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
ci(cypress): fix Nuvei cypress test cases (#9908)
Ashish Kumar4c3f01cb1e24
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Nuvei.js b/cypress-tests/cypress/e2e/configs/Payment/Nuvei.jsindex 2761cc2c00..853009076f 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Nuvei.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Nuvei.js@@ -2,17 +2,17 @@ import { customerAcceptance } from "./Commons";import { getCurrency } from "./Modifiers";const successfulNo3DSCardDetails = {- card_number: "4111111111111111",- card_exp_month: "08",+ card_number: "4444333322221111",+ card_exp_month: "12",card_exp_year: "30",card_holder_name: "joseph Doe",- card_cvc: "999",+ card_cvc: "123",};// Test card details based on Nuvei test cards (from Rust tests)const successfulThreeDSCardDetails = {card_number: "4000027891380961",card_exp_month: "10",- card_exp_year: "25",+ card_exp_year: "30",card_holder_name: "CL-BRW1",card_cvc: "123",};@@ -35,32 +35,30 @@ const multiUseMandateData = {},},};-// Payment method data objects for responses-const payment_method_data_no3ds = {- card: {- authentication_data: { challengePreferenceReason: "12" },- last4: "1111",- card_type: "CREDIT",- card_network: "Visa",- card_issuer: "JP Morgan",- card_issuing_country: "INDIA",- card_isin: "411111",- card_extended_bin: null,- card_exp_month: "08",- card_exp_year: "30",- card_holder_name: "joseph Doe",- payment_checks: {- avs_description: null,- avs_result_code: "",- cvv_2_reply_code: "",- cvv_2_description: null,- merchant_advice_code: "",- merchant_advice_code_description: null,- },++// Billing address for manual capture flows+const billingAddress = {+ address: {+ line1: "1467",+ line2: "Harrison Street",+ line3: "Harrison Street",+ city: "San Francisco",+ state: "CA",+ zip: "94122",+ country: "US",+ first_name: "John",+ last_name: "Doe",+ },+ phone: {+ number: "9123456789",+ country_code: "+1",},- billing: null,+ email: "[email protected]",};+// Note: payment_method_data object removed as Nuvei returns dynamic card metadata+// Tests validate that payment_method_data exists and is not empty (via commands.js)+export const connectorDetails = {card_pm: {// Basic payment intent creation@@ -134,17 +132,23 @@ export const connectorDetails = {status: "succeeded",payment_method: "card",attempt_count: 1,- payment_method_data: payment_method_data_no3ds,},},},// No 3DS manual captureNo3DSManualCapture: {+ Configs: {+ DELAY: {+ STATUS: true,+ TIMEOUT: 5000,+ },+ },Request: {payment_method: "card",payment_method_data: {card: successfulNo3DSCardDetails,},+ billing: billingAddress,amount: 11500,currency: "USD",customer_acceptance: null,@@ -156,7 +160,7 @@ export const connectorDetails = {status: "requires_capture",payment_method: "card",attempt_count: 1,- payment_method_data: payment_method_data_no3ds,+ // payment_method_data removed - Nuvei returns dynamic card metadata (issuer, country) that varies per transaction},},},@@ -183,11 +187,18 @@ export const connectorDetails = {},// 3DS manual capture"3DSManualCapture": {+ Configs: {+ DELAY: {+ STATUS: true,+ TIMEOUT: 5000,+ },+ },Request: {payment_method: "card",payment_method_data: {card: successfulThreeDSCardDetails,},+ billing: billingAddress,amount: 11500,currency: "USD",customer_acceptance: null,@@ -203,6 +214,12 @@ export const connectorDetails = {},// Capture paymentCapture: {+ Configs: {+ DELAY: {+ STATUS: true,+ TIMEOUT: 5000,+ },+ },Request: {amount_to_capture: 11500,},@@ -218,6 +235,12 @@ export const connectorDetails = {},// Partial capturePartialCapture: {+ Configs: {+ DELAY: {+ STATUS: true,+ TIMEOUT: 5000,+ },+ },Request: {amount_to_capture: 5000,},@@ -233,6 +256,12 @@ export const connectorDetails = {},// Void paymentVoid: {+ Configs: {+ DELAY: {+ STATUS: true,+ TIMEOUT: 3000,+ },+ },Request: {},Response: {status: 200,@@ -243,6 +272,12 @@ export const connectorDetails = {},// Refund paymentRefund: {+ Configs: {+ DELAY: {+ STATUS: true,+ TIMEOUT: 5000,+ },+ },Request: {amount: 11500,},@@ -272,6 +307,12 @@ export const connectorDetails = {},// Manual payment refundmanualPaymentRefund: {+ Configs: {+ DELAY: {+ STATUS: true,+ TIMEOUT: 5000,+ },+ },Request: {amount: 11500,},@@ -442,7 +483,7 @@ export const connectorDetails = {status: 200,body: {status: "requires_capture",- payment_method_data: payment_method_data_no3ds,+ // Note: payment_method_data removed from response validation as Nuvei returns dynamic card metadatapayment_method: "card",},},@@ -477,11 +518,18 @@ export const connectorDetails = {},},SaveCardUseNo3DSManualCapture: {+ Configs: {+ DELAY: {+ STATUS: true,+ TIMEOUT: 5000,+ },+ },Request: {payment_method: "card",payment_method_data: {card: successfulNo3DSCardDetails,},+ billing: billingAddress,currency: "USD",setup_future_usage: "on_session",customer_acceptance: customerAcceptance,@@ -727,11 +775,11 @@ export const connectorDetails = {Request: {payment_method: "bank_redirect",payment_method_type: "ideal",- currency: "EUR", // iDEAL requires EUR currency+ currency: "EUR",payment_method_data: {bank_redirect: {ideal: {- bank_name: "ing", // Maps to INGBNL2A in Nuvei+ bank_name: "ing",},},},@@ -743,7 +791,7 @@ export const connectorDetails = {city: "Amsterdam",state: "North Holland",zip: "1012",- country: "NL", // Netherlands required for iDEAL+ country: "NL",first_name: "John",last_name: "Doe",},@@ -756,7 +804,7 @@ export const connectorDetails = {Response: {status: 200,body: {- status: "requires_customer_action", // Bank redirect requires customer action+ status: "requires_customer_action",error_code: null,error_message: null,},@@ -846,11 +894,11 @@ export const connectorDetails = {payment_method: "bank_redirect",payment_method_type: "eps",amount: 11500,- currency: "EUR", // EPS requires EUR currency+ currency: "EUR",payment_method_data: {bank_redirect: {eps: {- country: "AT", // Austria required for EPS+ country: "AT",},},},@@ -862,7 +910,7 @@ export const connectorDetails = {city: "Vienna",state: "Vienna",zip: "1010",- country: "AT", // Austria required for EPS+ country: "AT",first_name: "John",last_name: "Doe",},@@ -876,6 +924,8 @@ export const connectorDetails = {status: 200,body: {status: "requires_customer_action",+ error_code: null,+ error_message: null,},},},diff --git a/cypress-tests/cypress/support/redirectionHandler.js b/cypress-tests/cypress/support/redirectionHandler.jsindex 78970f5aae..b4ce579bbe 100644--- a/cypress-tests/cypress/support/redirectionHandler.js+++ b/cypress-tests/cypress/support/redirectionHandler.js@@ -891,6 +891,71 @@ function threeDsRedirection(redirectionUrl, expectedUrl, connectorId) {return;}+ // Nuvei 3DS: 2-step flow (auth button + redirect button)+ if (connectorId === "nuvei") {+ cy.visit(redirectionUrl.href, { failOnStatusCode: false });++ cy.document()+ .should("have.property", "readyState")+ .and("equal", "complete");++ cy.url().then((currentUrl) => {+ const currentOrigin = new URL(currentUrl).origin;+ const redirectOrigin = new URL(redirectionUrl.href).origin;++ if (currentOrigin !== redirectOrigin) {+ cy.origin(+ currentOrigin,+ {+ args: {+ WAIT_TIME: CONSTANTS.WAIT_TIME,+ },+ },+ ({ WAIT_TIME }) => {+ cy.wait(WAIT_TIME);++ cy.get("body").then(($body) => {+ if ($body.find("#btn1").length > 0) {+ cy.get("#btn1").click();+ cy.get(+ "a:contains('Redirect'), button:contains('Redirect'), input[value='Redirect']",+ { timeout: 10000 }+ )+ .should("be.visible")+ .first()+ .click();+ }+ });+ }+ );+ } else {+ cy.wait(CONSTANTS.WAIT_TIME);+ cy.get("body").then(($body) => {+ if ($body.find("#btn1").length > 0) {+ cy.get("#btn1").click();+ cy.get(+ "a:contains('Redirect'), button:contains('Redirect'), input[value='Redirect']",+ { timeout: 10000 }+ )+ .should("be.visible")+ .first()+ .click();+ }+ });+ }+ });++ cy.url({ timeout: CONSTANTS.TIMEOUT }).should(+ "include",+ new URL(expectedUrl.href).origin+ );+ cy.document()+ .should("have.property", "readyState")+ .and("equal", "complete");+ verifyReturnUrl(redirectionUrl, expectedUrl, true);+ return;+ }+// For all other connectors, use the standard flowwaitForRedirect(redirectionUrl.href);@@ -1055,87 +1120,16 @@ function threeDsRedirection(redirectionUrl, expectedUrl, connectorId) {});break;case "nuvei":- cy.wait(constants.WAIT_TIME); // Wait for the page to load-- // Check if we're on the Nuvei 3DS challenge page- cy.get("body").then(($body) => {- const bodyText = $body.text();-- if (- bodyText.includes("ThreeDS ACS Emulator") ||- bodyText.includes("Challenge Page")- ) {- // Look for success buttons (based on UI test patterns)- cy.get("body").then(() => {- // Try to find and click success buttons- if ($body.find("#btn1").length > 0) {- cy.get("#btn1").click();- }-- if ($body.find("#btn5").length > 0) {- cy.get("#btn5").click();- }-- // If no specific buttons found, try generic success patterns- if (- $body.find("#btn1").length === 0 &&- $body.find("#btn5").length === 0- ) {- // Look for any button with "success", "continue", or "submit" text- cy.get(- "button, input[type='button'], input[type='submit']"- ).then(($buttons) => {- $buttons.each((index, button) => {- const buttonText = Cypress.$(button).text().toLowerCase();- const buttonValue =- Cypress.$(button).val()?.toLowerCase() || "";-- if (- buttonText.includes("success") ||- buttonText.includes("continue") ||- buttonText.includes("submit") ||- buttonValue.includes("success")- ) {- cy.wrap(button).click();- return false; // Break the loop- }- });- });- }- });- } else if ($body.find("iframe").length > 0) {- cy.log("Found iframe, attempting to interact with it");- cy.get("iframe")- .first()- .its("0.contentDocument.body")- .within(() => {- // Look for 3DS challenge form elements- cy.get("body").then(($iframeBody) => {- const iframeText = $iframeBody.text();-- if (- iframeText.includes("ThreeDS") ||- iframeText.includes("Challenge")- ) {- // Try to find and interact with 3DS elements- cy.get(- "button, input[type='button'], input[type='submit']"- ).then(($buttons) => {- if ($buttons.length > 0) {- cy.log("Clicking first available button in iframe");- cy.wrap($buttons.first()).click();- }- });- }- });- });- } else {- cy.log(- "No specific 3DS elements found, waiting for automatic redirect"- );- cy.wait(constants.WAIT_TIME);- }- });+ cy.get("#btn1", { timeout: constants.WAIT_TIME })+ .should("be.visible")+ .click();+ cy.get(+ "a:contains('Redirect'), button:contains('Redirect'), input[value='Redirect']",+ { timeout: 10000 }+ )+ .should("be.visible")+ .first()+ .click();break;case "stripe":cy.get("iframe", { timeout: constants.TIMEOUT })