Skip to content

Commit

Permalink
Added e2e tests for binLookup as it affects cvcPolicy
Browse files Browse the repository at this point in the history
  • Loading branch information
sponglord committed Jan 27, 2025
1 parent 4fb104e commit f303426
Showing 1 changed file with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { test, expect } from '../../../../../fixtures/card.fixture';
import { MAESTRO_CARD, BCMC_CARD } from '../../../../utils/constants';
import { URL_MAP } from '../../../../../fixtures/URL_MAP';

import LANG from '../../../../../../server/translations/en-US.json';
const CVC_LABEL = LANG['creditCard.securityCode.label'];
const CVC_LABEL_OPTIONAL = LANG['creditCard.securityCode.label.optional'];

test.describe('Card - testing /binLookup as it affects the cvc field', () => {
test('#1 Should fill in a PAN that will lead to cvc being hidden', async ({ card, page }) => {
// Regular card
await card.goto(URL_MAP.card);

// Visible & required cvc field
await expect(card.cvcField).toBeVisible();
await expect(card.cvcField).toHaveClass(/adyen-checkout__field__cvc/); // Note: "relaxed" regular expression to detect one class amongst several that are set on the element
await expect(card.cvcField).not.toHaveClass(/adyen-checkout__field__cvc--optional/);

// PAN that will trigger /binLookup with cvcPolicy:"hidden"
await card.typeCardNumber(BCMC_CARD);

// Hidden cvc field
await expect(card.cvcField).not.toBeVisible();

// Reset UI by deleting number
await card.deleteCardNumber();

// Visible, required cvc field
await expect(card.cvcField).toBeVisible();
await expect(card.cvcField).toHaveClass(/adyen-checkout__field__cvc/);
await expect(card.cvcField).not.toHaveClass(/adyen-checkout__field__cvc--optional/);
});

test('#2 Should fill in a PAN that will lead to cvc being optional', async ({ card, page }) => {
// Regular card
await card.goto(URL_MAP.card);

// PAN that will trigger /binLookup with cvcPolicy:"optional"
await card.typeCardNumber(MAESTRO_CARD);

// Optional cvc field
await expect(card.cvcField).toBeVisible();
await expect(card.cvcLabelText).toHaveText(CVC_LABEL_OPTIONAL);
await expect(card.cvcField).toHaveClass(/adyen-checkout__field__cvc--optional/);

// Reset UI by deleting number
await card.deleteCardNumber();

// Visible, required cvc field
await expect(card.cvcField).toBeVisible();
await expect(card.cvcField).toHaveClass(/adyen-checkout__field__cvc/);
await expect(card.cvcField).not.toHaveClass(/adyen-checkout__field__cvc--optional/);
// with regular text
await expect(card.cvcLabelText).toHaveText(CVC_LABEL);
});
});

0 comments on commit f303426

Please sign in to comment.