From f303426d7fb155ba5288ddc949e18ebbbef76be3 Mon Sep 17 00:00:00 2001 From: nicholas Date: Mon, 27 Jan 2025 14:13:46 +0100 Subject: [PATCH] Added e2e tests for binLookup as it affects cvcPolicy --- .../binLookup/cvc/card.cvc.policies.spec.ts | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 packages/e2e-playwright/tests/ui/card/binLookup/cvc/card.cvc.policies.spec.ts diff --git a/packages/e2e-playwright/tests/ui/card/binLookup/cvc/card.cvc.policies.spec.ts b/packages/e2e-playwright/tests/ui/card/binLookup/cvc/card.cvc.policies.spec.ts new file mode 100644 index 0000000000..34717d587f --- /dev/null +++ b/packages/e2e-playwright/tests/ui/card/binLookup/cvc/card.cvc.policies.spec.ts @@ -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); + }); +});