Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding missing conditions from kcp tests #2994

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading