From 8f64f5005693128b8b899fb799613f7291f3e193 Mon Sep 17 00:00:00 2001 From: sponglord Date: Thu, 19 Dec 2024 10:14:08 +0100 Subject: [PATCH] All bcmc tests first make call to go to a URL (#3030) * All bcmc tests first make call to go to a URL. This is consistent with how other tests work * Removed unnecessary 2nd arg in call to card.typeCardNumber * Fix: 3DS2 test checks correct endpoint before assessing final result * Renamed waitForVisibleDualBrands to waitForVisibleBrands and pass it the number of brands you expect * Added missing calls to load url --- .../e2e-playwright/fixtures/card.fixture.ts | 1 - packages/e2e-playwright/models/bcmc.ts | 4 +- .../a11y/bcmc/bancontact.visa.a11y.spec.ts | 6 +++ .../tests/e2e/card/bcmc/dualBranding.spec.ts | 44 ++++++++++++++----- .../e2e/card/threeDS2/card.threeDS2.spec.ts | 6 +-- .../panLength/panLength.focus.regular.spec.ts | 2 +- 6 files changed, 44 insertions(+), 19 deletions(-) diff --git a/packages/e2e-playwright/fixtures/card.fixture.ts b/packages/e2e-playwright/fixtures/card.fixture.ts index 4190b89226..ceba785ad5 100644 --- a/packages/e2e-playwright/fixtures/card.fixture.ts +++ b/packages/e2e-playwright/fixtures/card.fixture.ts @@ -33,7 +33,6 @@ const test = base.extend({ }, bcmc: async ({ page }, use) => { const bcmc = new BCMC(page); - await bcmc.goto(URL_MAP.bcmc); await use(bcmc); } }); diff --git a/packages/e2e-playwright/models/bcmc.ts b/packages/e2e-playwright/models/bcmc.ts index 4249920f80..774e65a613 100644 --- a/packages/e2e-playwright/models/bcmc.ts +++ b/packages/e2e-playwright/models/bcmc.ts @@ -5,10 +5,10 @@ class BCMC extends Card { return this.cardNumberField.locator('.adyen-checkout__card__cardNumber__brandIcon').all(); } - async waitForVisibleDualBrands() { + async waitForVisibleBrands(expectedNumber = 2) { return await this.page.waitForFunction( expectedLength => [...document.querySelectorAll('.adyen-checkout__card__cardNumber__brandIcon')].length === expectedLength, - 2 + expectedNumber ); } diff --git a/packages/e2e-playwright/tests/a11y/bcmc/bancontact.visa.a11y.spec.ts b/packages/e2e-playwright/tests/a11y/bcmc/bancontact.visa.a11y.spec.ts index b089b5c6a9..1ddeb91f3c 100644 --- a/packages/e2e-playwright/tests/a11y/bcmc/bancontact.visa.a11y.spec.ts +++ b/packages/e2e-playwright/tests/a11y/bcmc/bancontact.visa.a11y.spec.ts @@ -1,12 +1,15 @@ import { test, expect } from '../../../fixtures/card.fixture'; import { BCMC_DUAL_BRANDED_VISA, DUAL_BRANDED_CARD, TEST_CVC_VALUE, TEST_DATE_VALUE, VISA_CARD } from '../../utils/constants'; +import { URL_MAP } from '../../../fixtures/URL_MAP'; test('BCMC logo should have correct alt text', async ({ bcmc }) => { + await bcmc.goto(URL_MAP.bcmc); await bcmc.typeCardNumber('41'); expect(bcmc.rootElement.getByAltText(/bancontact card/i)).toBeTruthy(); }); test('Visa logo should have correct alt text', async ({ bcmc }) => { + await bcmc.goto(URL_MAP.bcmc); await bcmc.typeCardNumber(VISA_CARD); expect(bcmc.rootElement.getByAltText(/visa/i)).toBeTruthy(); }); @@ -17,6 +20,7 @@ test( 'then click Visa logo and expect comp to not be valid' + 'then click BCMC logo and expect comp to be valid again', async ({ page, bcmc }) => { + await bcmc.goto(URL_MAP.bcmc); await bcmc.typeCardNumber(BCMC_DUAL_BRANDED_VISA); await bcmc.typeExpiryDate(TEST_DATE_VALUE); expect(bcmc.cvcField).toBeHidden(); @@ -42,6 +46,7 @@ test( 'then click Visa logo and expect comp to not be valid' + 'then enter CVC and expect comp to be valid', async ({ bcmc, page }) => { + await bcmc.goto(URL_MAP.bcmc); await bcmc.typeCardNumber(BCMC_DUAL_BRANDED_VISA); await bcmc.typeExpiryDate(TEST_DATE_VALUE); await page.waitForFunction(() => globalThis.component.isValid === true); @@ -60,6 +65,7 @@ test( 'then re-add it' + 'and expect Visa logo to be shown a second time (showing CSF has reset state)', async ({ bcmc }) => { + await bcmc.goto(URL_MAP.bcmc); await bcmc.typeCardNumber(DUAL_BRANDED_CARD); expect(bcmc.rootElement.getByAltText(/visa/i)).toBeTruthy(); await bcmc.deleteCardNumber(); diff --git a/packages/e2e-playwright/tests/e2e/card/bcmc/dualBranding.spec.ts b/packages/e2e-playwright/tests/e2e/card/bcmc/dualBranding.spec.ts index cc0d245994..c0618993d8 100644 --- a/packages/e2e-playwright/tests/e2e/card/bcmc/dualBranding.spec.ts +++ b/packages/e2e-playwright/tests/e2e/card/bcmc/dualBranding.spec.ts @@ -8,16 +8,19 @@ import { TEST_DATE_VALUE, THREEDS2_CHALLENGE_PASSWORD } from '../../../utils/constants'; +import { URL_MAP } from '../../../../fixtures/URL_MAP'; test.describe('Bcmc payments with dual branding', () => { test.describe('Bancontact (BCMC) / Maestro brands', () => { test.describe('Selecting the Bancontact brand', () => { test('should submit the bcmc payment', async ({ bcmc }) => { + await bcmc.goto(URL_MAP.bcmc); + await bcmc.isComponentVisible(); await bcmc.fillCardNumber(BCMC_CARD); await bcmc.fillExpiryDate(TEST_DATE_VALUE); - await bcmc.waitForVisibleDualBrands(); + await bcmc.waitForVisibleBrands(); const [firstBrand, secondBrand] = await bcmc.brands; expect(firstBrand).toHaveAttribute('data-value', 'bcmc'); @@ -31,9 +34,10 @@ test.describe('Bcmc payments with dual branding', () => { }); test('should not submit the bcmc payment with incomplete form data', async ({ bcmc }) => { + await bcmc.goto(URL_MAP.bcmc); await bcmc.isComponentVisible(); await bcmc.fillCardNumber(BCMC_CARD); - await bcmc.waitForVisibleDualBrands(); + await bcmc.waitForVisibleBrands(); await bcmc.selectBrand('Bancontact card'); await bcmc.pay(); @@ -41,6 +45,7 @@ test.describe('Bcmc payments with dual branding', () => { }); test('should not submit the bcmc payment with invalid bcmc card number', async ({ bcmc }) => { + await bcmc.goto(URL_MAP.bcmc); await bcmc.isComponentVisible(); await bcmc.fillCardNumber(`${BCMC_CARD}111`); await bcmc.pay(); @@ -51,11 +56,12 @@ test.describe('Bcmc payments with dual branding', () => { test.describe('Selecting the maestro brand', () => { test('should submit the maestro payment', async ({ bcmc }) => { + await bcmc.goto(URL_MAP.bcmc); await bcmc.isComponentVisible(); await bcmc.fillCardNumber(BCMC_CARD); await bcmc.fillExpiryDate(TEST_DATE_VALUE); - await bcmc.waitForVisibleDualBrands(); + await bcmc.waitForVisibleBrands(); const [firstBrand, secondBrand] = await bcmc.brands; expect(firstBrand).toHaveAttribute('data-value', 'bcmc'); @@ -68,9 +74,10 @@ test.describe('Bcmc payments with dual branding', () => { }); test('should not submit the maestro payment with incomplete form data', async ({ bcmc }) => { + await bcmc.goto(URL_MAP.bcmc); await bcmc.isComponentVisible(); await bcmc.fillCardNumber(BCMC_CARD); - await bcmc.waitForVisibleDualBrands(); + await bcmc.waitForVisibleBrands(); await bcmc.selectBrand('Maestro'); await bcmc.pay(); @@ -78,6 +85,7 @@ test.describe('Bcmc payments with dual branding', () => { }); test('should not submit the maestro payment with invalid maestro card number', async ({ bcmc }) => { + await bcmc.goto(URL_MAP.bcmc); await bcmc.isComponentVisible(); await bcmc.fillCardNumber(`${BCMC_CARD}111`); await bcmc.pay(); @@ -90,11 +98,12 @@ test.describe('Bcmc payments with dual branding', () => { test.describe('Bancontact (BCMC) / Visa Debit brands', () => { test.describe('Selecting the Bancontact brand', () => { test('should submit the bcmc payment', async ({ bcmc }) => { + await bcmc.goto(URL_MAP.bcmc); await bcmc.isComponentVisible(); await bcmc.fillCardNumber(BCMC_DUAL_BRANDED_VISA); await bcmc.fillExpiryDate(TEST_DATE_VALUE); - await bcmc.waitForVisibleDualBrands(); + await bcmc.waitForVisibleBrands(); const [firstBrand, secondBrand] = await bcmc.brands; expect(firstBrand).toHaveAttribute('data-value', 'bcmc'); @@ -108,9 +117,10 @@ test.describe('Bcmc payments with dual branding', () => { }); test('should not submit the bcmc payment with incomplete form data', async ({ bcmc }) => { + await bcmc.goto(URL_MAP.bcmc); await bcmc.isComponentVisible(); await bcmc.fillCardNumber(BCMC_DUAL_BRANDED_VISA); - await bcmc.waitForVisibleDualBrands(); + await bcmc.waitForVisibleBrands(); await bcmc.selectBrand('Bancontact card'); await bcmc.pay(); @@ -118,6 +128,7 @@ test.describe('Bcmc payments with dual branding', () => { }); test('should not submit the bcmc payment with invalid bcmc card number', async ({ bcmc }) => { + await bcmc.goto(URL_MAP.bcmc); await bcmc.isComponentVisible(); await bcmc.fillCardNumber(`${BCMC_DUAL_BRANDED_VISA}111`); await bcmc.pay(); @@ -128,11 +139,12 @@ test.describe('Bcmc payments with dual branding', () => { test.describe('Selecting the visa brand', () => { test('should submit the visa payment', async ({ bcmc }) => { + await bcmc.goto(URL_MAP.bcmc); await bcmc.isComponentVisible(); await bcmc.fillCardNumber(BCMC_DUAL_BRANDED_VISA); await bcmc.fillExpiryDate(TEST_DATE_VALUE); - await bcmc.waitForVisibleDualBrands(); + await bcmc.waitForVisibleBrands(); const [firstBrand, secondBrand] = await bcmc.brands; expect(firstBrand).toHaveAttribute('data-value', 'bcmc'); @@ -148,11 +160,12 @@ test.describe('Bcmc payments with dual branding', () => { }); test('should not submit the visa payment with incomplete form data', async ({ bcmc }) => { + await bcmc.goto(URL_MAP.bcmc); await bcmc.isComponentVisible(); await bcmc.fillCardNumber(BCMC_DUAL_BRANDED_VISA); await bcmc.fillExpiryDate(TEST_DATE_VALUE); - await bcmc.waitForVisibleDualBrands(); + await bcmc.waitForVisibleBrands(); await bcmc.selectBrand(/visa/i); await bcmc.pay(); @@ -161,6 +174,7 @@ test.describe('Bcmc payments with dual branding', () => { }); test('should not submit the visa payment with invalid visa card number', async ({ bcmc }) => { + await bcmc.goto(URL_MAP.bcmc); await bcmc.isComponentVisible(); await bcmc.fillCardNumber(`${BCMC_DUAL_BRANDED_VISA}111`); await bcmc.pay(); @@ -173,11 +187,12 @@ test.describe('Bcmc payments with dual branding', () => { test.describe('Bancontact (BCMC) / MC brands', () => { test.describe('Selecting the Bancontact brand', () => { test('should submit the bcmc payment', async ({ bcmc }) => { + await bcmc.goto(URL_MAP.bcmc); await bcmc.isComponentVisible(); await bcmc.fillCardNumber(BCMC_DUAL_BRANDED_MC); await bcmc.fillExpiryDate(TEST_DATE_VALUE); - await bcmc.waitForVisibleDualBrands(); + await bcmc.waitForVisibleBrands(); const [firstBrand, secondBrand] = await bcmc.brands; expect(firstBrand).toHaveAttribute('data-value', 'bcmc'); @@ -190,9 +205,10 @@ test.describe('Bcmc payments with dual branding', () => { }); test('should not submit the bcmc payment with incomplete form data', async ({ bcmc }) => { + await bcmc.goto(URL_MAP.bcmc); await bcmc.isComponentVisible(); await bcmc.fillCardNumber(BCMC_DUAL_BRANDED_MC); - await bcmc.waitForVisibleDualBrands(); + await bcmc.waitForVisibleBrands(); await bcmc.selectBrand('Bancontact card'); await bcmc.pay(); @@ -200,6 +216,7 @@ test.describe('Bcmc payments with dual branding', () => { }); test('should not submit the bcmc payment with invalid bcmc card number', async ({ bcmc }) => { + await bcmc.goto(URL_MAP.bcmc); await bcmc.isComponentVisible(); await bcmc.fillCardNumber(`${BCMC_DUAL_BRANDED_MC}111`); await bcmc.pay(); @@ -210,11 +227,12 @@ test.describe('Bcmc payments with dual branding', () => { test.describe('Selecting the mc brand', () => { test('should submit the mc payment', async ({ bcmc }) => { + await bcmc.goto(URL_MAP.bcmc); await bcmc.isComponentVisible(); await bcmc.fillCardNumber(BCMC_DUAL_BRANDED_MC); await bcmc.fillExpiryDate(TEST_DATE_VALUE); - await bcmc.waitForVisibleDualBrands(); + await bcmc.waitForVisibleBrands(); const [firstBrand, secondBrand] = await bcmc.brands; expect(firstBrand).toHaveAttribute('data-value', 'bcmc'); @@ -228,11 +246,12 @@ test.describe('Bcmc payments with dual branding', () => { }); test('should not submit the mc payment with incomplete form data', async ({ bcmc }) => { + await bcmc.goto(URL_MAP.bcmc); await bcmc.isComponentVisible(); await bcmc.fillCardNumber(BCMC_DUAL_BRANDED_MC); await bcmc.fillExpiryDate(TEST_DATE_VALUE); - await bcmc.waitForVisibleDualBrands(); + await bcmc.waitForVisibleBrands(); await bcmc.selectBrand('MasterCard'); await bcmc.pay(); @@ -241,6 +260,7 @@ test.describe('Bcmc payments with dual branding', () => { }); test('should not submit the mc payment with invalid mc card number', async ({ bcmc }) => { + await bcmc.goto(URL_MAP.bcmc); await bcmc.isComponentVisible(); await bcmc.fillCardNumber(`${BCMC_DUAL_BRANDED_MC}111`); await bcmc.pay(); diff --git a/packages/e2e-playwright/tests/e2e/card/threeDS2/card.threeDS2.spec.ts b/packages/e2e-playwright/tests/e2e/card/threeDS2/card.threeDS2.spec.ts index 9e1b6fdd09..4288f9b6b1 100644 --- a/packages/e2e-playwright/tests/e2e/card/threeDS2/card.threeDS2.spec.ts +++ b/packages/e2e-playwright/tests/e2e/card/threeDS2/card.threeDS2.spec.ts @@ -31,7 +31,7 @@ test.describe('Card with 3DS2', () => { }); test('should handle full flow (fingerprint & challenge)', async ({ page, card }) => { - const submitFingerprintResponsePromise = page.waitForResponse(response => response.url().includes('/submitThreeDS2Fingerprint')); + const makeDetailsCallResponsePromise = page.waitForResponse(response => response.url().includes('/paymentDetails')); // Check for sessions' /paymentDetails call await card.goto(URL_MAP.card); @@ -43,10 +43,10 @@ test.describe('Card with 3DS2', () => { await card.threeDs2Challenge.fillInPassword(THREEDS2_CHALLENGE_PASSWORD); await card.threeDs2Challenge.submit(); - const fingerPrintResponse = await submitFingerprintResponsePromise; + const detailsCallResponse = await makeDetailsCallResponsePromise; await expect(card.paymentResult).toContainText(PAYMENT_RESULT.authorised); - expect(fingerPrintResponse.status()).toBe(200); + expect(detailsCallResponse.status()).toBe(200); }); test('should handle challenge-only flow', async ({ page, card }) => { diff --git a/packages/e2e-playwright/tests/ui/card/binLookup/panLength/panLength.focus.regular.spec.ts b/packages/e2e-playwright/tests/ui/card/binLookup/panLength/panLength.focus.regular.spec.ts index f107a91488..2a06dcdf41 100644 --- a/packages/e2e-playwright/tests/ui/card/binLookup/panLength/panLength.focus.regular.spec.ts +++ b/packages/e2e-playwright/tests/ui/card/binLookup/panLength/panLength.focus.regular.spec.ts @@ -108,7 +108,7 @@ test.describe('Test Card, & binLookup w. panLength property', () => { // Card out of date await card.fillExpiryDate('12/90'); - await card.typeCardNumber(CARD_WITH_PAN_LENGTH, 300); + await card.typeCardNumber(CARD_WITH_PAN_LENGTH); // Expect UI change - expiryDate field has focus await expect(card.cardNumberInput).not.toBeFocused();