Skip to content

Commit

Permalink
test: update card number validation test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
aritro2002 committed Dec 5, 2024
1 parent 0f47cd0 commit b4f6af0
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions cypress-tests/cypress/e2e/card-number-validation-test.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,65 +30,63 @@ describe("Card number validation test", () => {
it("should fail with an undetectable card brand", () => {
const { card_exp_month, card_exp_year, cvc } = stripeCards.successCard;

getIframeBody().find('[data-testid=cardNoInput]').type("111111");
getIframeBody().find('[data-testid=expiryInput]').type(card_exp_month);
getIframeBody().find('[data-testid=expiryInput]').type(card_exp_year);
getIframeBody().find('[data-testid=cvvInput]').type(cvc);
getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).type("111111");
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();

getIframeBody().find('.Error.pt-1').should('be.visible')
.and('contain.text', "Please enter a valid card number.");
getIframeBody().find('[data-testid=cardNoInput]').click();
getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).click();
getIframeBody().find('.Error.pt-1').should('not.exist');

});

it("should fail with a detectable but invalid card number", () => {
const { card_exp_month, card_exp_year, cvc } = stripeCards.successCard;

getIframeBody().find('[data-testid=cardNoInput]').type("424242");
getIframeBody().find('[data-testid=expiryInput]').type(card_exp_month);
getIframeBody().find('[data-testid=expiryInput]').type(card_exp_year);
getIframeBody().find('[data-testid=cvvInput]').type(cvc);
getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).type("424242");
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();

getIframeBody().find('.Error.pt-1').should('be.visible')
.and('contain.text', "Card number is invalid.");
getIframeBody().find('[data-testid=cardNoInput]').click();
getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).click();
getIframeBody().find('.Error.pt-1').should('not.exist');
});

it("should fail with an unsupported card brand (RuPay)", () => {
const { card_exp_month, card_exp_year, cvc } = stripeCards.successCard;

getIframeBody().find('[data-testid=cardNoInput]').type("6082015309577308");
getIframeBody().find('[data-testid=expiryInput]').type(card_exp_month);
getIframeBody().find('[data-testid=expiryInput]').type(card_exp_year);
getIframeBody().find('[data-testid=cvvInput]').type(cvc);
getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).type("6082015309577308");
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();

getIframeBody().find('.Error.pt-1').should('be.visible')
.and('contain.text', "RuPay is not supported at the moment.");
getIframeBody().find('[data-testid=cardNoInput]').click();
getIframeBody().find(`[data-testid=${testIds.cardNoInputTestId}]`).click();
getIframeBody().find('.Error.pt-1').should('not.exist');
});

it("should fail with an empty card number", () => {
const { card_exp_month, card_exp_year, cvc } = stripeCards.successCard;

getIframeBody().find('[data-testid=expiryInput]').type(card_exp_month);
getIframeBody().find('[data-testid=expiryInput]').type(card_exp_year);
getIframeBody().find('[data-testid=cvvInput]').type(cvc);
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();

getIframeBody().find('.Error.pt-1').should('be.visible')
.and('contain.text', "Card Number cannot be empty");
getIframeBody().find('[data-testid=cardNoInput]').click();
getIframeBody().find('.Error.pt-1').should('not.exist');
});

});

0 comments on commit b4f6af0

Please sign in to comment.