diff --git a/packages/e2e-playwright/models/dropin.ts b/packages/e2e-playwright/models/dropin.ts index 3ea57a0d18..fade04e1f1 100644 --- a/packages/e2e-playwright/models/dropin.ts +++ b/packages/e2e-playwright/models/dropin.ts @@ -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(); diff --git a/packages/e2e-playwright/tests/e2e/card/avs.spec.ts b/packages/e2e-playwright/tests/e2e/card/avs.spec.ts index eb774d06f2..d202b61011 100644 --- a/packages/e2e-playwright/tests/e2e/card/avs.spec.ts +++ b/packages/e2e-playwright/tests/e2e/card/avs.spec.ts @@ -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); }); }); diff --git a/packages/e2e-playwright/tests/e2e/dropin/storedCard/stored-card-amex.spec.ts b/packages/e2e-playwright/tests/e2e/dropin/storedCard/stored-card-amex.spec.ts index fc39713e88..d85edc9056 100644 --- a/packages/e2e-playwright/tests/e2e/dropin/storedCard/stored-card-amex.spec.ts +++ b/packages/e2e-playwright/tests/e2e/dropin/storedCard/stored-card-amex.spec.ts @@ -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 () => { diff --git a/packages/e2e-playwright/tests/e2e/dropin/storedCard/stored-card-maestro.spec.ts b/packages/e2e-playwright/tests/e2e/dropin/storedCard/stored-card-maestro.spec.ts index c8d965fd21..c9805ce39b 100644 --- a/packages/e2e-playwright/tests/e2e/dropin/storedCard/stored-card-maestro.spec.ts +++ b/packages/e2e-playwright/tests/e2e/dropin/storedCard/stored-card-maestro.spec.ts @@ -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); + }); });