diff --git a/cypress-tests/cypress/e2e/multiple-card-test.cy.ts b/cypress-tests/cypress/e2e/multiple-card-test.cy.ts new file mode 100644 index 00000000..d76e6644 --- /dev/null +++ b/cypress-tests/cypress/e2e/multiple-card-test.cy.ts @@ -0,0 +1,88 @@ +import * as testIds from "../../../src/Utilities/TestUtils.bs"; +import { getClientURL } from "../support/utils"; +import { createPaymentBody } from "../support/utils"; +import { changeObjectKeyValue } from "../support/utils"; +import { stripeCards } from "cypress/support/cards"; + +describe("Card number validation test", () => { + + const publishableKey = Cypress.env('HYPERSWITCH_PUBLISHABLE_KEY') + const secretKey = Cypress.env('HYPERSWITCH_SECRET_KEY') + let getIframeBody: () => Cypress.Chainable>; + let iframeSelector = + "#orca-payment-element-iframeRef-orca-elements-payment-element-payment-element"; + + // changeObjectKeyValue(createPaymentBody,"profile_id","YOUR_PROFILE_ID") + changeObjectKeyValue(createPaymentBody,"customer_id","new_user") + + + beforeEach(() => { + getIframeBody = () => cy.iframe(iframeSelector); + cy.createPaymentIntent(secretKey, createPaymentBody).then(() => { + cy.getGlobalState("clientSecret").then((clientSecret) => { + + cy.visit(getClientURL(clientSecret, publishableKey)); + }); + + }) + }); + + + it("19 digit visa card", () => { + const { cardNo, card_exp_month, card_exp_year, cvc } = stripeCards.visaCard19; + + getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).type(cardNo); + getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type(card_exp_month); + getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type(card_exp_year); + getIframeBody().find(`[data-testid=${testIds.cardCVVInputTestId}]`).type(cvc); + + getIframeBody().get("#submit").click(); + + + cy.contains("Thanks for your order!").should("be.visible"); + }); + + + it("16 digit master card", () => { + const { cardNo, card_exp_month, card_exp_year, cvc } = stripeCards.masterCard16; + + getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).type(cardNo); + getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type(card_exp_month); + getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type(card_exp_year); + getIframeBody().find(`[data-testid=${testIds.cardCVVInputTestId}]`).type(cvc); + + getIframeBody().get("#submit").click(); + + + cy.contains("Thanks for your order!").should("be.visible"); + }); + + it("15 digit american express card", () => { + const { cardNo, card_exp_month, card_exp_year, cvc } = stripeCards.amexCard15; + + getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).type(cardNo); + getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type(card_exp_month); + getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type(card_exp_year); + getIframeBody().find(`[data-testid=${testIds.cardCVVInputTestId}]`).type(cvc); + + getIframeBody().get("#submit").click(); + + + cy.contains("Thanks for your order!").should("be.visible"); + }); + + it("14 digit diners club card", () => { + const { cardNo, card_exp_month, card_exp_year, cvc } = stripeCards.dinersClubCard14; + + getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).type(cardNo); + getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type(card_exp_month); + getIframeBody().find(`[data-testid=${testIds.expiryInputTestId}]`).type(card_exp_year); + getIframeBody().find(`[data-testid=${testIds.cardCVVInputTestId}]`).type(cvc); + + getIframeBody().get("#submit").click(); + + + cy.contains("Thanks for your order!").should("be.visible"); + }); + +}); \ No newline at end of file diff --git a/cypress-tests/cypress/support/cards.ts b/cypress-tests/cypress/support/cards.ts index c15b85e9..0716754c 100644 --- a/cypress-tests/cypress/support/cards.ts +++ b/cypress-tests/cypress/support/cards.ts @@ -37,4 +37,34 @@ export const stripeCards = { card_exp_month:"13", card_exp_year:"30", }, -} \ No newline at end of file + visaCard19: { + cardNo: "4479667352342682672", + cardScheme: "Visa", + cvc: "123", + card_exp_month: "12", + card_exp_year: "30", + }, + masterCard16: { + cardNo: "5555555555554444", + cardScheme: "MasterCard", + cvc: "123", + card_exp_month: "12", + card_exp_year: "30", + }, + amexCard15: { + cardNo: "378282246310005", + cardScheme: "American Express", + cvc: "1234", + card_exp_month: "12", + card_exp_year: "30", + }, + dinersClubCard14: { + cardNo: "36227206271667", + cardScheme: "Diners Club", + cvc: "123", + card_exp_month: "12", + card_exp_year: "30", + }, + +} +