-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added e2e tests for binLookup as it affects cvcPolicy
- Loading branch information
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
packages/e2e-playwright/tests/ui/card/binLookup/cvc/card.cvc.policies.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |