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

Added e2e tests for binLookup as it affects cvcPolicy #3109

Merged
merged 3 commits into from
Jan 30, 2025
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { test, expect } from '../../../../../fixtures/card.fixture';
import { MAESTRO_CARD, BCMC_CARD } from '../../../../utils/constants';
import { URL_MAP } from '../../../../../fixtures/URL_MAP';
import { getStoryUrl } from '../../../../utils/getStoryUrl';

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

const componentConfig = {
brands: ['mc', 'visa', 'amex', 'maestro', 'bcmc']
};

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(getStoryUrl({ baseUrl: URL_MAP.card, componentConfig }));

// Visible & required cvc field
await expect(card.cvcField).toBeVisible();
await expect(card.cvcLabelText).toHaveText(CVC_LABEL);
await expect(card.cvcLabelText).not.toHaveText(CVC_LABEL_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.cvcLabelText).toHaveText(CVC_LABEL);
await expect(card.cvcLabelText).not.toHaveText(CVC_LABEL_OPTIONAL);
});

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

// 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.cvcLabelText).not.toHaveText(CVC_LABEL);

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

// Visible, required cvc field
await expect(card.cvcField).toBeVisible();
await expect(card.cvcLabelText).toHaveText(CVC_LABEL);
await expect(card.cvcLabelText).not.toHaveText(CVC_LABEL_OPTIONAL);
});
});

This file was deleted.

This file was deleted.

This file was deleted.

Loading