Skip to content

Commit

Permalink
All bcmc tests first make call to go to a URL (#3030)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sponglord authored Dec 19, 2024
1 parent 0e730a3 commit 8f64f50
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 19 deletions.
1 change: 0 additions & 1 deletion packages/e2e-playwright/fixtures/card.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const test = base.extend<Fixture>({
},
bcmc: async ({ page }, use) => {
const bcmc = new BCMC(page);
await bcmc.goto(URL_MAP.bcmc);
await use(bcmc);
}
});
Expand Down
4 changes: 2 additions & 2 deletions packages/e2e-playwright/models/bcmc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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();
});
Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -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();
Expand Down
44 changes: 32 additions & 12 deletions packages/e2e-playwright/tests/e2e/card/bcmc/dualBranding.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -31,16 +34,18 @@ 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();

await expect(bcmc.expiryDateErrorElement).toHaveText('Enter the expiry date');
});

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();
Expand All @@ -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');
Expand All @@ -68,16 +74,18 @@ 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();

await expect(bcmc.expiryDateErrorElement).toHaveText('Enter the expiry date');
});

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();
Expand All @@ -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');
Expand All @@ -108,16 +117,18 @@ 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();

await expect(bcmc.expiryDateErrorElement).toHaveText('Enter the expiry date');
});

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();
Expand All @@ -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');
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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');
Expand All @@ -190,16 +205,18 @@ 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();

await expect(bcmc.expiryDateErrorElement).toHaveText('Enter the expiry date');
});

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();
Expand All @@ -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');
Expand All @@ -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();
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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 }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 8f64f50

Please sign in to comment.