Skip to content

Commit

Permalink
threeds tests (#2976)
Browse files Browse the repository at this point in the history
  • Loading branch information
ribeiroguilherme authored Nov 22, 2024
1 parent 08fb012 commit 633355b
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 491 deletions.
1 change: 1 addition & 0 deletions packages/e2e-playwright/fixtures/URL_MAP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const URL_MAP = {
*/
card: '/iframe.html?args=&id=cards-card--default&viewMode=story',
cardWithSsn: '/iframe.html?globals=&id=cards-card--with-ssn&viewMode=story',
cardWithAdvancedFlow: '/iframe.html?args=useSessions:!false&globals=&id=cards-card--default&viewMode=story',
cardWithAvs: '/iframe.html?args=&globals=&id=cards-card--with-avs&viewMode=story',
cardWithPartialAvs: '/iframe.html?args=&globals=&id=cards-card--with-partial-avs&viewMode=story',
cardWithInstallments: '/iframe.html?args=&id=cards-card--with-installments&viewMode=story',
Expand Down
11 changes: 7 additions & 4 deletions packages/e2e-playwright/models/threeds2Challenge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import { Locator, Page } from '@playwright/test';
class ThreeDs2Challenge {
readonly rootElement: Locator;

constructor(
public readonly page: Page,
rootElementSelector: string = '.adyen-checkout__threeds2__challenge'
) {
constructor(public readonly page: Page, rootElementSelector: string = '.adyen-checkout__threeds2__challenge') {
this.rootElement = page.locator(rootElementSelector);
}

Expand All @@ -22,6 +19,12 @@ class ThreeDs2Challenge {
return this.threeDSIframe.locator('#buttonSubmit');
}

async getIframeSize() {
const iframe = this.page.locator('iframe[name="threeDSIframe"]');
const boundingBox = await iframe.boundingBox();
return { width: boundingBox.width, height: boundingBox.height };
}

async fillInPassword(password: string) {
await this.passwordInput.fill(password);
}
Expand Down
110 changes: 110 additions & 0 deletions packages/e2e-playwright/tests/e2e/card/threeDS2/card.threeDS2.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { expect, test } from '../../../../fixtures/card.fixture';
import { URL_MAP } from '../../../../fixtures/URL_MAP';
import {
PAYMENT_RESULT,
TEST_CVC_VALUE,
TEST_DATE_VALUE,
THREEDS2_CHALLENGE_ONLY_CARD,
THREEDS2_CHALLENGE_PASSWORD,
THREEDS2_FRICTIONLESS_CARD,
THREEDS2_FULL_FLOW_CARD
} from '../../../utils/constants';
import { getStoryUrl } from '../../../utils/getStoryUrl';

test.describe('Card with 3DS2', () => {
test.describe('Different 3DS2 flows', () => {
test('should handle frictionless flow', async ({ page, card }) => {
const submitFingerprintResponsePromise = page.waitForResponse(response => response.url().includes('/submitThreeDS2Fingerprint'));

// Frictionless flow seems to work only with Advanced flow
await card.goto(URL_MAP.cardWithAdvancedFlow);

await card.typeCardNumber(THREEDS2_FRICTIONLESS_CARD);
await card.typeCvc(TEST_CVC_VALUE);
await card.typeExpiryDate(TEST_DATE_VALUE);
await card.pay();

const fingerPrintResponse = await submitFingerprintResponsePromise;

await expect(card.paymentResult).toContainText(PAYMENT_RESULT.authorised);
expect(fingerPrintResponse.status()).toBe(200);
});

test('should handle full flow (fingerprint & challenge)', async ({ page, card }) => {
const submitFingerprintResponsePromise = page.waitForResponse(response => response.url().includes('/submitThreeDS2Fingerprint'));

await card.goto(URL_MAP.card);

await card.typeCardNumber(THREEDS2_FULL_FLOW_CARD);
await card.typeCvc(TEST_CVC_VALUE);
await card.typeExpiryDate(TEST_DATE_VALUE);
await card.pay();

await card.threeDs2Challenge.fillInPassword(THREEDS2_CHALLENGE_PASSWORD);
await card.threeDs2Challenge.submit();

const fingerPrintResponse = await submitFingerprintResponsePromise;

await expect(card.paymentResult).toContainText(PAYMENT_RESULT.authorised);
expect(fingerPrintResponse.status()).toBe(200);
});

test('should handle challenge-only flow', async ({ page, card }) => {
let submitFingerprintRequestWasMade = false;

page.on('request', request => {
if (request.url().includes('/submitThreeDS2Fingerprint')) submitFingerprintRequestWasMade = true;
});

await card.goto(URL_MAP.card);

await card.typeCardNumber(THREEDS2_CHALLENGE_ONLY_CARD);
await card.typeCvc(TEST_CVC_VALUE);
await card.typeExpiryDate(TEST_DATE_VALUE);
await card.pay();

await card.threeDs2Challenge.fillInPassword(THREEDS2_CHALLENGE_PASSWORD);
await card.threeDs2Challenge.submit();

await expect(card.paymentResult).toContainText(PAYMENT_RESULT.authorised);
await expect(submitFingerprintRequestWasMade).toBeFalsy();
});
});

test.describe('Different 3DS2 challenge window sizes', () => {
test('should use the default window size', async ({ card }) => {
await card.goto(URL_MAP.card);

await card.typeCardNumber(THREEDS2_CHALLENGE_ONLY_CARD);
await card.typeCvc(TEST_CVC_VALUE);
await card.typeExpiryDate(TEST_DATE_VALUE);
await card.pay();

const { width, height } = await card.threeDs2Challenge.getIframeSize();

expect(width).toBe(390);
expect(height).toBe(400);
});

test('should be possible to use a custom window size', async ({ card }) => {
await card.goto(
getStoryUrl({
baseUrl: URL_MAP.card,
componentConfig: {
challengeWindowSize: '04'
}
})
);

await card.typeCardNumber(THREEDS2_CHALLENGE_ONLY_CARD);
await card.typeCvc(TEST_CVC_VALUE);
await card.typeExpiryDate(TEST_DATE_VALUE);
await card.pay();

const { width, height } = await card.threeDs2Challenge.getIframeSize();

expect(width).toBe(600);
expect(height).toBe(400);
});
});
});

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 633355b

Please sign in to comment.