Skip to content

Commit

Permalink
Adding missing conditions from kcp tests (#2994)
Browse files Browse the repository at this point in the history
* Adding missing conditions from kcp tests

* Adding missing conditions from kcp tests, part 2
  • Loading branch information
sponglord authored Nov 27, 2024
1 parent e863f37 commit c0b6125
Showing 1 changed file with 33 additions and 6 deletions.
39 changes: 33 additions & 6 deletions packages/e2e-playwright/tests/e2e/card/kcp/card.kcp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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
}) => {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
});
});
Expand All @@ -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);
Expand All @@ -112,14 +124,23 @@ 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);

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);
Expand All @@ -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);
Expand Down

0 comments on commit c0b6125

Please sign in to comment.