Skip to content

Commit

Permalink
Migrating bcmc e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sponglord committed Dec 19, 2024
1 parent 8f64f50 commit 89bf7a1
Show file tree
Hide file tree
Showing 5 changed files with 219 additions and 325 deletions.
94 changes: 76 additions & 18 deletions packages/e2e-playwright/tests/e2e/card/bcmc/dualBranding.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ 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 }) => {
test('#1a should submit the bcmc payment', async ({ bcmc, page }) => {
const paymentsRequestPromise = page.waitForRequest(request => request.url().includes('/payments') && request.method() === 'POST');

await bcmc.goto(URL_MAP.bcmc);

await bcmc.isComponentVisible();
Expand All @@ -28,12 +30,18 @@ test.describe('Bcmc payments with dual branding', () => {

await bcmc.selectBrand('Bancontact card');
await bcmc.pay();

// check brand has been set in paymentMethod data
const request = await paymentsRequestPromise;
const paymentMethod = await request.postDataJSON().paymentMethod;
expect(paymentMethod.brand).toEqual('bcmc');

await bcmc.threeDs2Challenge.fillInPassword(THREEDS2_CHALLENGE_PASSWORD);
await bcmc.threeDs2Challenge.submit();
await expect(bcmc.paymentResult).toContainText(PAYMENT_RESULT.authorised);
});

test('should not submit the bcmc payment with incomplete form data', async ({ bcmc }) => {
test('#1b 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);
Expand All @@ -44,7 +52,7 @@ test.describe('Bcmc payments with dual branding', () => {
await expect(bcmc.expiryDateErrorElement).toHaveText('Enter the expiry date');
});

test('should not submit the bcmc payment with invalid bcmc card number', async ({ bcmc }) => {
test('#1c 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`);
Expand All @@ -55,7 +63,9 @@ test.describe('Bcmc payments with dual branding', () => {
});

test.describe('Selecting the maestro brand', () => {
test('should submit the maestro payment', async ({ bcmc }) => {
test('#2a should submit the maestro payment', async ({ bcmc, page }) => {
const paymentsRequestPromise = page.waitForRequest(request => request.url().includes('/payments') && request.method() === 'POST');

await bcmc.goto(URL_MAP.bcmc);
await bcmc.isComponentVisible();

Expand All @@ -70,10 +80,14 @@ test.describe('Bcmc payments with dual branding', () => {
await bcmc.selectBrand('Maestro');
await bcmc.pay();

const request = await paymentsRequestPromise;
const paymentMethod = await request.postDataJSON().paymentMethod;
expect(paymentMethod.brand).toEqual('maestro');

await expect(bcmc.paymentResult).toContainText(PAYMENT_RESULT.authorised);
});

test('should not submit the maestro payment with incomplete form data', async ({ bcmc }) => {
test('#2b 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);
Expand All @@ -84,7 +98,7 @@ test.describe('Bcmc payments with dual branding', () => {
await expect(bcmc.expiryDateErrorElement).toHaveText('Enter the expiry date');
});

test('should not submit the maestro payment with invalid maestro card number', async ({ bcmc }) => {
test('#2c 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`);
Expand All @@ -97,7 +111,7 @@ 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 }) => {
test('#3a should submit the bcmc payment (without needing to fill CVC field)', async ({ bcmc }) => {
await bcmc.goto(URL_MAP.bcmc);
await bcmc.isComponentVisible();

Expand All @@ -116,7 +130,7 @@ test.describe('Bcmc payments with dual branding', () => {
await expect(bcmc.paymentResult).toContainText(PAYMENT_RESULT.authorised);
});

test('should not submit the bcmc payment with incomplete form data', async ({ bcmc }) => {
test('#3b 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);
Expand All @@ -127,7 +141,7 @@ test.describe('Bcmc payments with dual branding', () => {
await expect(bcmc.expiryDateErrorElement).toHaveText('Enter the expiry date');
});

test('should not submit the bcmc payment with invalid bcmc card number', async ({ bcmc }) => {
test('#3c 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`);
Expand All @@ -138,7 +152,9 @@ test.describe('Bcmc payments with dual branding', () => {
});

test.describe('Selecting the visa brand', () => {
test('should submit the visa payment', async ({ bcmc }) => {
test('#4a should submit the visa payment', async ({ bcmc, page }) => {
const paymentsRequestPromise = page.waitForRequest(request => request.url().includes('/payments') && request.method() === 'POST');

await bcmc.goto(URL_MAP.bcmc);
await bcmc.isComponentVisible();

Expand All @@ -154,12 +170,16 @@ test.describe('Bcmc payments with dual branding', () => {
await bcmc.fillCvc(TEST_CVC_VALUE);
await bcmc.pay();

const request = await paymentsRequestPromise;
const paymentMethod = await request.postDataJSON().paymentMethod;
expect(paymentMethod.brand).toEqual('visa');

await bcmc.threeDs2Challenge.fillInPassword(THREEDS2_CHALLENGE_PASSWORD);
await bcmc.threeDs2Challenge.submit();
await expect(bcmc.paymentResult).toContainText(PAYMENT_RESULT.authorised);
});

test('should not submit the visa payment with incomplete form data', async ({ bcmc }) => {
test('#4b should not submit the visa payment with incomplete form data', async ({ bcmc }) => {
await bcmc.goto(URL_MAP.bcmc);
await bcmc.isComponentVisible();

Expand All @@ -173,7 +193,7 @@ test.describe('Bcmc payments with dual branding', () => {
await expect(bcmc.cvcErrorElement).toHaveText('Enter the security code');
});

test('should not submit the visa payment with invalid visa card number', async ({ bcmc }) => {
test('#4c 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`);
Expand All @@ -186,7 +206,7 @@ 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 }) => {
test('#5a should submit the bcmc payment', async ({ bcmc }) => {
await bcmc.goto(URL_MAP.bcmc);
await bcmc.isComponentVisible();

Expand All @@ -204,7 +224,7 @@ test.describe('Bcmc payments with dual branding', () => {
await expect(bcmc.paymentResult).toContainText(PAYMENT_RESULT.authorised);
});

test('should not submit the bcmc payment with incomplete form data', async ({ bcmc }) => {
test('#5b 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);
Expand All @@ -215,7 +235,7 @@ test.describe('Bcmc payments with dual branding', () => {
await expect(bcmc.expiryDateErrorElement).toHaveText('Enter the expiry date');
});

test('should not submit the bcmc payment with invalid bcmc card number', async ({ bcmc }) => {
test('#5c 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`);
Expand All @@ -226,7 +246,9 @@ test.describe('Bcmc payments with dual branding', () => {
});

test.describe('Selecting the mc brand', () => {
test('should submit the mc payment', async ({ bcmc }) => {
test('#6a should submit the mc payment', async ({ bcmc, page }) => {
const paymentsRequestPromise = page.waitForRequest(request => request.url().includes('/payments') && request.method() === 'POST');

await bcmc.goto(URL_MAP.bcmc);
await bcmc.isComponentVisible();

Expand All @@ -242,10 +264,14 @@ test.describe('Bcmc payments with dual branding', () => {
await bcmc.fillCvc(TEST_CVC_VALUE);
await bcmc.pay();

const request = await paymentsRequestPromise;
const paymentMethod = await request.postDataJSON().paymentMethod;
expect(paymentMethod.brand).toEqual('mc');

await expect(bcmc.paymentResult).toContainText(PAYMENT_RESULT.authorised);
});

test('should not submit the mc payment with incomplete form data', async ({ bcmc }) => {
test('#6b should not submit the mc payment with incomplete form data', async ({ bcmc }) => {
await bcmc.goto(URL_MAP.bcmc);
await bcmc.isComponentVisible();

Expand All @@ -259,7 +285,7 @@ test.describe('Bcmc payments with dual branding', () => {
await expect(bcmc.cvcErrorElement).toHaveText('Enter the security code');
});

test('should not submit the mc payment with invalid mc card number', async ({ bcmc }) => {
test('#6c 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`);
Expand All @@ -269,4 +295,36 @@ test.describe('Bcmc payments with dual branding', () => {
});
});
});
test.describe('Selecting the mc brand', () => {
test.describe('Then deleting the PAN and retyping it without selecting a brand', () => {
test('#7 should submit a non-branded payment payment', async ({ bcmc, page }) => {
const paymentsRequestPromise = page.waitForRequest(request => request.url().includes('/payments') && request.method() === 'POST');

await bcmc.goto(URL_MAP.bcmc);
await bcmc.isComponentVisible();

await bcmc.fillCardNumber(BCMC_DUAL_BRANDED_MC);
await bcmc.fillExpiryDate(TEST_DATE_VALUE);
await bcmc.waitForVisibleBrands();

const [firstBrand, secondBrand] = await bcmc.brands;
expect(firstBrand).toHaveAttribute('data-value', 'bcmc');
expect(secondBrand).toHaveAttribute('data-value', 'mc');

await bcmc.selectBrand('MasterCard');
await bcmc.fillCvc(TEST_CVC_VALUE);

await bcmc.deleteCardNumber();
await bcmc.fillCardNumber(BCMC_DUAL_BRANDED_MC);

await bcmc.pay();

const request = await paymentsRequestPromise;
const paymentMethod = await request.postDataJSON().paymentMethod;
expect(paymentMethod.brand).toBeUndefined();

await expect(bcmc.paymentResult).toContainText(PAYMENT_RESULT.authorised);
});
});
});
});
143 changes: 143 additions & 0 deletions packages/e2e-playwright/tests/ui/card/bcmc/dualBranding.reset.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
import { test, expect } from '../../../../fixtures/card.fixture';
import { URL_MAP } from '../../../../fixtures/URL_MAP';
import { BCMC_CARD, BCMC_DUAL_BRANDED_VISA, UNKNOWN_VISA_CARD } from '../../../utils/constants';

test.describe('Testing Bancontact, with dual branded cards, how UI resets', () => {
test(
'#1 Fill in dual branded card then ' +
'check that brands have been sorted to place Bcmc first then ' +
'ensure only bcmc logo shows after deleting digits',
async ({ bcmc }) => {
await bcmc.goto(URL_MAP.bcmc);

await bcmc.isComponentVisible();

await bcmc.fillCardNumber(BCMC_CARD);

await bcmc.waitForVisibleBrands();

let [firstBrand, secondBrand] = await bcmc.brands;

// Correct order
expect(firstBrand).toHaveAttribute('data-value', 'bcmc');
expect(secondBrand).toHaveAttribute('data-value', 'maestro');

await bcmc.deleteCardNumber();

await bcmc.waitForVisibleBrands(1);

[firstBrand, secondBrand] = await bcmc.brands;

// Now only a single brand
expect(firstBrand).toHaveAttribute('alt', /bancontact/i);
expect(secondBrand).toBeUndefined();
}
);

test('#2 Fill in dual branded card then ' + 'select maestro & see that cvc field is hidden even though it is maestro ', async ({ bcmc }) => {
await bcmc.goto(URL_MAP.bcmc);

await bcmc.isComponentVisible();

await bcmc.fillCardNumber(BCMC_CARD);

await bcmc.waitForVisibleBrands();

await bcmc.selectBrand('Maestro');

// Due to brand sorting and priority being given to the Bcmc brand - cvc should remain hidden
// even tho' maestro has been selected
await bcmc.cvcField.waitFor({ state: 'hidden' });
});

test(
'#3 Fill in dual branded card then ' +
'paste in number not recognised by binLookup (but that our local regEx will recognise as Visa)' +
'see that UI stays looking like a BCMC card i.e. bcmc logo remains showing',
async ({ bcmc }) => {
await bcmc.goto(URL_MAP.bcmc);

await bcmc.isComponentVisible();

await bcmc.typeCardNumber(BCMC_CARD);

// "paste"
await bcmc.fillCardNumber(UNKNOWN_VISA_CARD);

await bcmc.waitForVisibleBrands(1);

const [firstBrand, secondBrand] = await bcmc.brands;

// Remains a single brand
expect(firstBrand).toHaveAttribute('alt', /bancontact/i);
expect(secondBrand).toBeUndefined();
}
);

test(
'#4 Fill in dual branded card then ' +
'select visa & see that cvc field shows then' +
'paste in number not recognised by binLookup (but that our local regEx will recognise as Visa) ' +
'see that UI stays looking like a BCMC card i.e. bcmc logo remains showing and cvc field is hidden again',
async ({ bcmc }) => {
await bcmc.goto(URL_MAP.bcmc);

await bcmc.isComponentVisible();

await bcmc.fillCardNumber(BCMC_DUAL_BRANDED_VISA);

await bcmc.waitForVisibleBrands();

await bcmc.selectBrand('Visa');

await bcmc.cvcField.waitFor({ state: 'visible' });

// "paste"
await bcmc.fillCardNumber(UNKNOWN_VISA_CARD);

await bcmc.waitForVisibleBrands(1);

const [firstBrand, secondBrand] = await bcmc.brands;

// Returns to a Bcmc
expect(firstBrand).toHaveAttribute('alt', /bancontact/i);
expect(secondBrand).toBeUndefined();

// with hidden cvc
await bcmc.cvcField.waitFor({ state: 'hidden' });
}
);

test(
'#5 Fill in dual branded card then ' +
'select visa & see that cvc field shows then' +
'delete number and see that bcmc logo remains showing and cvc field is hidden again',
async ({ bcmc }) => {
await bcmc.goto(URL_MAP.bcmc);

await bcmc.isComponentVisible();

await bcmc.fillCardNumber(BCMC_DUAL_BRANDED_VISA);

await bcmc.waitForVisibleBrands();

await bcmc.selectBrand('Visa');

await bcmc.cvcField.waitFor({ state: 'visible' });

// "paste"
await bcmc.deleteCardNumber();

await bcmc.waitForVisibleBrands(1);

const [firstBrand, secondBrand] = await bcmc.brands;

// Returns to a Bcmc
expect(firstBrand).toHaveAttribute('alt', /bancontact/i);
expect(secondBrand).toBeUndefined();

// with hidden cvc
await bcmc.cvcField.waitFor({ state: 'hidden' });
}
);
});
Loading

0 comments on commit 89bf7a1

Please sign in to comment.