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 c4605fb
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 10 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
2 changes: 1 addition & 1 deletion packages/e2e-playwright/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const config: PlaywrightTestConfig = {
trace: 'on-first-retry',
ignoreHTTPSErrors: true,
screenshot: 'only-on-failure',
video: 'on-first-retry'
video: 'retain-on-failure'
},

/* Configure projects for major browsers */
Expand Down
5 changes: 3 additions & 2 deletions packages/e2e-playwright/tests/e2e/card/avs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ test.describe('Card payments with address lookup', () => {

test.describe('Card payments with partial avs', () => {
test.describe('When fill in a valid the post code', () => {
test('should make a successful card payment', async ({ cardWithAvs }) => {
test('should make a successful card payment', async ({ cardWithAvs, page }) => {
await cardWithAvs.goto(URL_MAP.cardWithPartialAvs);
await cardWithAvs.typeCardNumber(REGULAR_TEST_CARD);
await cardWithAvs.typeExpiryDate(TEST_DATE_VALUE);
await cardWithAvs.typeCvc(TEST_CVC_VALUE);
await cardWithAvs.billingAddress.fillInPostCode(TEST_POSTCODE);
// 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 Expand Up @@ -58,7 +60,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 c4605fb

Please sign in to comment.