From c0b6125066908c68899ea4cf1a255fc4fa9d7e91 Mon Sep 17 00:00:00 2001 From: sponglord Date: Wed, 27 Nov 2024 14:07:52 +0100 Subject: [PATCH] Adding missing conditions from kcp tests (#2994) * Adding missing conditions from kcp tests * Adding missing conditions from kcp tests, part 2 --- .../tests/e2e/card/kcp/card.kcp.spec.ts | 39 ++++++++++++++++--- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/packages/e2e-playwright/tests/e2e/card/kcp/card.kcp.spec.ts b/packages/e2e-playwright/tests/e2e/card/kcp/card.kcp.spec.ts index fd4c3ffb8f..ed07bcb077 100644 --- a/packages/e2e-playwright/tests/e2e/card/kcp/card.kcp.spec.ts +++ b/packages/e2e-playwright/tests/e2e/card/kcp/card.kcp.spec.ts @@ -14,7 +14,7 @@ import { paymentSuccessfulMock } from '../../../../mocks/payments/payments.mock' test.describe('Card with KCP fields', () => { test.describe('Displaying KCP fields by default', () => { - test('should hide KCP fields if Card is not korean and make the payment', async ({ cardWithKCP }) => { + test('#1 should hide KCP fields if Card is not korean and make the payment', async ({ cardWithKCP }) => { await cardWithKCP.goto(URL_MAP.cardWithKcp); await cardWithKCP.typeCardNumber(REGULAR_TEST_CARD); @@ -28,7 +28,7 @@ test.describe('Card with KCP fields', () => { await expect(cardWithKCP.paymentResult).toContainText(PAYMENT_RESULT.authorised); }); - test('should hide KCP fields if Card is not korean, then show them again once the Card is replaced by korean card and make the payment', async ({ + test('#2 should hide KCP fields if Card is not korean, then show them again once the Card is replaced by korean card and make the payment', async ({ cardWithKCP, page }) => { @@ -58,7 +58,13 @@ test.describe('Card with KCP fields', () => { await expect(cardWithKCP.paymentResult).toContainText(PAYMENT_RESULT.authorised); }); - test('should fill in KCP fields, then replace with non-korean Card and make a payment', async ({ cardWithKCP }) => { + test('#3 should fill in KCP fields, then replace with non-korean Card and make a payment (seeing that kcp info has been cleared from card state)', async ({ + cardWithKCP, + page + }) => { + await paymentSuccessfulMock(page); + const paymentsRequestPromise = page.waitForRequest(request => request.url().includes('/payments') && request.method() === 'POST'); + await cardWithKCP.goto(URL_MAP.cardWithKcp); await cardWithKCP.typeCardNumber(KOREAN_TEST_CARD); @@ -75,6 +81,12 @@ test.describe('Card with KCP fields', () => { await cardWithKCP.pay(); + // Check that KCP fields are NOT passed in + const request = await paymentsRequestPromise; + const paymentMethod = await request.postDataJSON().paymentMethod; + expect(paymentMethod.encryptedPassword).toBeUndefined(); + expect(paymentMethod.taxNumber).toBeUndefined(); + await expect(cardWithKCP.paymentResult).toContainText(PAYMENT_RESULT.authorised); }); }); @@ -90,7 +102,7 @@ test.describe('Card with KCP fields', () => { } }); - test('should display KCP fields once korean card is entered and make the payment', async ({ cardWithKCP, page }) => { + test('#4 should display KCP fields once korean card is entered and make the payment', async ({ cardWithKCP, page }) => { await paymentSuccessfulMock(page); await cardWithKCP.goto(url); @@ -112,7 +124,13 @@ test.describe('Card with KCP fields', () => { await expect(cardWithKCP.paymentResult).toContainText(PAYMENT_RESULT.authorised); }); - test('should display KCP fields once korean card is entered, then replace by regular Card and make the payment', async ({ cardWithKCP }) => { + test('#5 should display KCP fields once korean card is entered, fill in kcp specific fields, then replace by regular Card and make the payment (seeing that kcp info has been cleared from card state)', async ({ + cardWithKCP, + page + }) => { + await paymentSuccessfulMock(page); + const paymentsRequestPromise = page.waitForRequest(request => request.url().includes('/payments') && request.method() === 'POST'); + await cardWithKCP.goto(url); await cardWithKCP.typeCardNumber(KOREAN_TEST_CARD); @@ -120,6 +138,9 @@ test.describe('Card with KCP fields', () => { await expect(cardWithKCP.passwordInput).toBeVisible(); await expect(cardWithKCP.taxNumberInput).toBeVisible(); + await cardWithKCP.typeTaxNumber(TEST_TAX_NUMBER_VALUE); + await cardWithKCP.typePassword(TEST_PWD_VALUE); // this confirms that dynamically added iframe is really there + await cardWithKCP.deleteCardNumber(); await cardWithKCP.typeCardNumber(REGULAR_TEST_CARD); @@ -131,10 +152,16 @@ test.describe('Card with KCP fields', () => { await cardWithKCP.pay(); + // Check that KCP fields are NOT passed in + const request = await paymentsRequestPromise; + const paymentMethod = await request.postDataJSON().paymentMethod; + expect(paymentMethod.encryptedPassword).toBeUndefined(); + expect(paymentMethod.taxNumber).toBeUndefined(); + await expect(cardWithKCP.paymentResult).toContainText(PAYMENT_RESULT.authorised); }); - test('should apply validation to KCP fields', async ({ cardWithKCP }) => { + test('#6 should apply validation to KCP fields', async ({ cardWithKCP }) => { await cardWithKCP.goto(url); await cardWithKCP.typeCardNumber(KOREAN_TEST_CARD);