Skip to content

Commit

Permalink
test(stored-card-maestro): added
Browse files Browse the repository at this point in the history
  • Loading branch information
longyulongyu committed Nov 26, 2024
1 parent 0b69cc8 commit a0e4866
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/e2e-playwright/models/dropin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ class Dropin extends Base {

// Stored payment methods
async selectFirstStoredPaymentMethod(pmType: string, lastFour?: string) {
const pmLabel = this.paymentMethods.find((pm: { type: string }) => pm.type === pmType).name;
const pmLabel = this.paymentMethods.find((pm: { type: string }) => pm.type === pmType)?.name;
await this.page
.locator('.adyen-checkout__payment-method')
.filter({ has: this.page.getByRole('img', { name: pmLabel }) }) // filter the payment methods which have the correct logo
.filter({ has: this.page.getByRole('img', { name: pmLabel ?? pmType }) }) // filter the payment methods which have the correct logo
.getByRole('radio', { name: lastFour, exact: false })
.first()
.click();
Expand Down
1 change: 0 additions & 1 deletion packages/e2e-playwright/tests/e2e/card/avs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ test.describe('Card payments with full avs', () => {
// wait for the form is valid
await page.waitForFunction(() => globalThis.component.isValid === true);
await cardWithAvs.pay();
await cardWithAvs.paymentResult.waitFor({ state: 'visible' });
await expect(cardWithAvs.paymentResult).toContainText(PAYMENT_RESULT.authorised);
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test, expect } from '../../../../fixtures/dropin.fixture';
import { test } from '@playwright/test';

test.describe('Stored Amex card - cvc required', () => {
test('#1 Can fill out the cvc fields in the stored card and make a successful payment', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,44 @@
import { test } from '@playwright/test';
import { cardInDropin as test, expect } from '../../../../fixtures/dropin.fixture';
import { URL_MAP } from '../../../../fixtures/URL_MAP';
import { PAYMENT_RESULT, TEST_CVC_VALUE, THREEDS2_CHALLENGE_PASSWORD } from '../../../utils/constants';

test.describe('Stored Maestro card - cvc optional', () => {
// When user do not fill in the cvc
test('should make a successful payment without the cvc code', async () => {});
test('should make a successful payment without the cvc code', async ({ dropinWithSession, card }) => {
await dropinWithSession.goto(URL_MAP.dropinWithSession);
await dropinWithSession.selectFirstStoredPaymentMethod('maestro', '0029');

await card.cvcInput.waitFor({ state: 'visible' });
await card.pay({ name: /^Pay/i });
await card.threeDs2Challenge.fillInPassword(THREEDS2_CHALLENGE_PASSWORD);
await card.threeDs2Challenge.submit();

await expect(card.paymentResult).toContainText(PAYMENT_RESULT.success);
});
// When user fills in the cvc
test('should make a successful payment after filling in the correct 3ds challenge password', async () => {});
test('should decline the payment after filling in the wrong 3ds challenge password', async () => {});
test('should make a successful payment after filling in the correct 3ds challenge password', async ({ dropinWithSession, card }) => {
await dropinWithSession.goto(URL_MAP.dropinWithSession);
await dropinWithSession.selectFirstStoredPaymentMethod('maestro', '0029');

await card.cvcInput.waitFor({ state: 'visible' });
await card.fillCvc(TEST_CVC_VALUE);
await card.pay({ name: /^Pay/i });
await card.threeDs2Challenge.fillInPassword(THREEDS2_CHALLENGE_PASSWORD);
await card.threeDs2Challenge.submit();

await expect(card.paymentResult).toContainText(PAYMENT_RESULT.success);
});

test('should decline the payment after filling in the wrong 3ds challenge password', async ({ dropinWithSession, card }) => {
await dropinWithSession.goto(URL_MAP.dropinWithSession);
await dropinWithSession.selectFirstStoredPaymentMethod('maestro', '0029');

await card.cvcInput.waitFor({ state: 'visible' });
await card.fillCvc(TEST_CVC_VALUE);
await card.pay({ name: /^Pay/i });
await card.threeDs2Challenge.fillInPassword('dummy');
await card.threeDs2Challenge.submit();

await expect(card.paymentResult).toContainText(PAYMENT_RESULT.fail);
});
});

0 comments on commit a0e4866

Please sign in to comment.