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 index 34717d587f..8762a4bb5c 100644 --- 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 @@ -1,15 +1,20 @@ 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(URL_MAP.card); + await card.goto(getStoryUrl({ baseUrl: URL_MAP.card, componentConfig })); // Visible & required cvc field await expect(card.cvcField).toBeVisible(); @@ -33,7 +38,7 @@ test.describe('Card - testing /binLookup as it affects the cvc field', () => { 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); + await card.goto(getStoryUrl({ baseUrl: URL_MAP.card, componentConfig })); // PAN that will trigger /binLookup with cvcPolicy:"optional" await card.typeCardNumber(MAESTRO_CARD); diff --git a/packages/e2e-playwright/tests/ui/card/binLookup/mocks/binLookup.cvc.hidden.spec.ts b/packages/e2e-playwright/tests/ui/card/binLookup/mocks/binLookup.cvc.hidden.spec.ts deleted file mode 100644 index 442bf2d635..0000000000 --- a/packages/e2e-playwright/tests/ui/card/binLookup/mocks/binLookup.cvc.hidden.spec.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { test } from '@playwright/test'; - -const cvcSpan = '.card-field .adyen-checkout__field__cvc'; -const optionalCVCSpan = '.card-field .adyen-checkout__field__cvc--optional'; -const cvcLabel = '.card-field .adyen-checkout__label__text'; -const brandingIcon = '.card-field .adyen-checkout__card__cardNumber__brandIcon'; -const iframeSelector = '.card-field iframe'; - -test.describe('Testing a card for a response that should indicate hidden cvc', () => { - // Use config from: binLookup.mocks.clientScripts.js - test( - 'Test card has hidden cvc field ' + 'then complete date and see card is valid ' + ' then delete card number and see card reset', - async () => { - // Start, allow time for iframes to load - // Expect generic card icon: expect(brandingIcon.getAttribute('src')).contains('nocard.svg') - // Expect visible cvc field: expect(cvcSpan.filterVisible().exists) - // Expect with regular text: expect(cvcLabel.withExactText('Security code').exists) - // Expect not optional: expect(optionalCVCSpan.exists).notOk(); - // Fill in Unknown card: cardUtils.fillCardNumber(t, BCMC_CARD); - // Expect bcmc card icon: expect(brandingIcon.getAttribute('src')).contains('bcmc.svg') - // Expect hidden cvc field: expect(cvcSpan.filterHidden().exists) - // Fill date: cardUtils.fillDate(t); - // Expect card is valid: t.expect(getIsValid('card')).eql(true); - // Delete number: cardUtils.deleteCardNumber(t); - // Expect generic card icon: expect(brandingIcon.getAttribute('src')).contains('nocard.svg') - // Expect visible cvc field: expect(cvcSpan.filterVisible().exists) - // Expect with regular text: expect(cvcLabel.withExactText('Security code').exists) - // Expect not optional: expect(optionalCVCSpan.exists).notOk(); - // Expect card is not valid: t.expect(getIsValid('card')).eql(false); - } - ); -}); diff --git a/packages/e2e-playwright/tests/ui/card/binLookup/mocks/binLookup.cvc.optional.spec.ts b/packages/e2e-playwright/tests/ui/card/binLookup/mocks/binLookup.cvc.optional.spec.ts deleted file mode 100644 index b4fb6ab807..0000000000 --- a/packages/e2e-playwright/tests/ui/card/binLookup/mocks/binLookup.cvc.optional.spec.ts +++ /dev/null @@ -1,104 +0,0 @@ -import { test } from '@playwright/test'; -import { BIN_LOOKUP_VERSION } from '../../../../utils/constants'; - -const cvcSpan = '.card-field .adyen-checkout__field__cvc'; -const optionalCVCSpan = '.card-field .adyen-checkout__field__cvc--optional'; -const cvcLabel = '.card-field .adyen-checkout__label__text'; -const brandingIcon = '.card-field .adyen-checkout__card__cardNumber__brandIcon'; -const requestURL = `https://checkoutshopper-test.adyen.com/checkoutshopper/${BIN_LOOKUP_VERSION}/bin/binLookup?token=${process.env.CLIENT_KEY}`; - -/** - * NOTE - we are mocking the response until such time as we have a genuine card, - * that's not in our local RegEx, that returns the properties we want to test - */ -// use the following mock: -const mockedResponse = { - brands: [ - { - brand: 'bcmc', // keep as a recognised card brand (bcmc) until we have a genuine card - to avoid logo loading errors - cvcPolicy: 'optional', - enableLuhnCheck: true, - showExpiryDate: true, - supported: true - } - ], - issuingCountryCode: 'US', - requestId: null -}; - -const iframe = '.card-field iframe'; - -test.describe('Testing a card, as detected by a mock/binLookup, for a response that should indicate optional cvc)', () => { - // use config from binLookup.mocks.clientScripts.js - // use mock - test( - 'Test card has optional cvc field ' + 'then complete date and see card is valid ' + ' then delete card number and see card reset', - async t => { - // Start, allow time for iframes to load - // await t - // // generic card icon - // .expect(brandingIcon.getAttribute('src')) - // .contains('nocard.svg') - // - // // visible cvc field - // .expect(cvcSpan.filterVisible().exists) - // .ok() - // - // // with regular text - // .expect(cvcLabel.withExactText('Security code').exists) - // .ok() - // - // // and not optional - // .expect(optionalCVCSpan.exists) - // .notOk(); - // - // // Unknown card - // await cardUtils.fillCardNumber(t, UNKNOWN_BIN_CARD); - // - // await t - // // bcmc card icon - // .expect(brandingIcon.getAttribute('src')) - // .contains('bcmc.svg') - // - // // visible cvc field - // .expect(cvcSpan.filterVisible().exists) - // .ok() - // - // // with "optional" text - // .expect(cvcLabel.withExactText('Security code (optional)').exists) - // .ok() - // // and optional class - // .expect(optionalCVCSpan.exists) - // .ok(); - // - // // Fill date - // await cardUtils.fillDate(t); - // - // // Is valid - // await t.expect(getIsValid('card')).eql(true); - // - // // Delete number - // await cardUtils.deleteCardNumber(t); - // - // // Card is reset - // await t - // // generic card icon - // .expect(brandingIcon.getAttribute('src')) - // .contains('nocard.svg') - // - // // visible cvc field - // .expect(cvcSpan.filterVisible().exists) - // .ok() - // - // // with regular text - // .expect(cvcLabel.withExactText('Security code').exists) - // .ok() - // - // // and not optional - // .expect(optionalCVCSpan.exists) - // .notOk(); - // - // await t.expect(getIsValid('card')).eql(false); - } - ); -}); diff --git a/packages/e2e-playwright/tests/ui/card/binLookup/mocks/binLookup.mocks.clientScripts.js b/packages/e2e-playwright/tests/ui/card/binLookup/mocks/binLookup.mocks.clientScripts.js deleted file mode 100644 index b9e428c81d..0000000000 --- a/packages/e2e-playwright/tests/ui/card/binLookup/mocks/binLookup.mocks.clientScripts.js +++ /dev/null @@ -1,4 +0,0 @@ -window.cardConfig = { - type: 'scheme', - brands: ['mc', 'visa', 'amex', 'bcmc'] -};