Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat(cypress): add test case for incorrect and empty card types #6550

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
28 changes: 28 additions & 0 deletions cypress-tests/cypress/e2e/PaymentTest/00022-Variations.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,34 @@ describe("Corner cases", () => {
);
});

it("[Payment] Incorrect card type", () => {
const data = getConnectorDetails(globalState.get("commons"))["card_pm"][
"IncorrectCardType"
];

cy.createConfirmPaymentTest(
paymentIntentBody,
data,
"no_three_ds",
"automatic",
globalState
);
});

it("[Payment] Empty card type", () => {
const data = getConnectorDetails(globalState.get("commons"))["card_pm"][
"EmptyCardType"
];

cy.createConfirmPaymentTest(
paymentIntentBody,
data,
"no_three_ds",
"automatic",
globalState
);
});

it("[Payment] Invalid `amount_to_capture`", () => {
const data = getConnectorDetails(globalState.get("commons"))["card_pm"][
"InvalidAmountToCapture"
Expand Down
66 changes: 66 additions & 0 deletions cypress-tests/cypress/e2e/PaymentUtils/Commons.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,35 @@ const multiUseMandateData = {
},
};

const billingAddress = {
address: {
line1: "1467",
line2: "Harrison Street",
line3: "Harrison Street",
city: "San Fransico",
state: "California",
zip: "94122",
country: "BR",
first_name: "john",
last_name: "doe",
},
};
Comment on lines +101 to +113
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is specific to a connector or a payment method, then i would recommend having country field empty and override it in respective fields wherever it is used.

also, if i'm not asking too much, can you please also apply the same changes to rest of the file where ever billing exist and is not null.

that way, we can do something like:

billing: {
  ...billingAddress,
  country: DE / GB / BR / IN / US
}


const browserInfo = {
user_agent:
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
accept_header:
"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
language: "nl-NL",
color_depth: 24,
screen_height: 723,
screen_width: 1536,
time_zone: 0,
java_enabled: true,
java_script_enabled: true,
ip_address: "127.0.0.1",
};

export const cardRequiredField = {
"payment_method_data.card.card_number": {
required_field: "payment_method_data.card.card_number",
Expand Down Expand Up @@ -1316,6 +1345,43 @@ export const connectorDetails = {
},
},
},
IncorrectCardType: {
Request: {
payment_method: "card",
payment_method_type: "debit",
setup_future_usage: "off_session",
confirm: true,
browser_info: browserInfo,
billing: billingAddress,
payment_method_data: {
kashif-m marked this conversation as resolved.
Show resolved Hide resolved
card: successfulNo3DSCardDetails,
},
},
Response: {
status: 200,
body: {
payment_method_type: "credit",
},
},
},
EmptyCardType: {
Request: {
payment_method: "card",
setup_future_usage: "off_session",
confirm: true,
browser_info: browserInfo,
billing: billingAddress,
payment_method_data: {
kashif-m marked this conversation as resolved.
Show resolved Hide resolved
card: successfulNo3DSCardDetails,
},
},
Response: {
status: 200,
body: {
payment_method_type: "credit",
},
},
},
InvalidAmountToCapture: {
Request: {
currency: "USD",
Expand Down
Loading