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

Chore/bin lookup pan length tests #2956

Merged
merged 20 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
8aa5303
Refactoring panLength.focus.regular.spec.ts to work in new framework
sponglord Nov 14, 2024
2660a01
Refactoring panLength.focus.regular.spec.ts to work in new framework …
sponglord Nov 14, 2024
b253d8e
Refactoring panLength.focus.regular.spec.ts to work in new framework …
sponglord Nov 14, 2024
ba668ad
Refactoring panLength.focus.regular.spec.ts to work in new framework …
sponglord Nov 14, 2024
46e1621
Cleaning up unused params
sponglord Nov 14, 2024
3f68ee4
Skip "paste" tet until it works in Firefox and Webkit
sponglord Nov 15, 2024
bc98055
Make clipboard permissions browser specific
sponglord Nov 15, 2024
4c0e904
Added pauses for test that behaved oddly in webkit
sponglord Nov 15, 2024
5f72fbf
Refactoring panLength.focus.ssn.spec.ts to work in new framework
sponglord Nov 15, 2024
edb9f47
Shortened test descriptions
sponglord Nov 15, 2024
b335b43
Refactoring panLength.focus.avs.spec.ts to work in new framework
sponglord Nov 15, 2024
0f4dab8
Use correct mock in avs.a11y.spec.ts
sponglord Nov 15, 2024
3598825
Refactoring panLength.focus.kcp.spec.ts to work in new framework
sponglord Nov 15, 2024
39d3311
Deleting old, testcafe, clientScripts files
sponglord Nov 15, 2024
da33f1d
Refactoring to make better use of the testing API and other models - …
sponglord Nov 18, 2024
d8987dd
Fix typo
sponglord Nov 18, 2024
47a61be
Refactoring to make better use of the testing API and other models - …
sponglord Nov 18, 2024
9e5cd47
Refactoring to make better use of the testing API and other models - …
sponglord Nov 18, 2024
02f92b3
Merge branch 'main' into chore/binLookup_panLength_tests
sponglord Nov 18, 2024
e96e4be
Changing test PAN to see if it is less flaky in Webkit CI
sponglord Nov 18, 2024
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
100 changes: 99 additions & 1 deletion packages/e2e-playwright/mocks/binLookup/binLookup.data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
const optionalDateAndCvcMock = {
brands: [
{
brand: 'mc',
enableLuhnCheck: true,
supported: true,
cvcPolicy: 'optional',
expiryDatePolicy: 'optional'
}
],
issuingCountryCode: 'US',
requestedId: null
};

const optionalDateAndCvcWithPanLengthMock = {
brands: [
{
brand: 'mc',
Expand Down Expand Up @@ -27,4 +41,88 @@ const hiddenDateAndCvcMock = {
requestedId: null
};

export { optionalDateAndCvcMock, hiddenDateAndCvcMock };
const optionalDateWithPanLengthMock = {
brands: [
{
brand: 'mc',
enableLuhnCheck: true,
supported: true,
cvcPolicy: 'required',
expiryDatePolicy: 'optional',
panLength: 16
}
],
issuingCountryCode: 'US',
requestedId: null
};

const hiddenDateWithPanLengthMock = {
brands: [
{
brand: 'mc',
enableLuhnCheck: true,
supported: true,
cvcPolicy: 'required',
expiryDatePolicy: 'hidden',
panLength: 16
}
],
issuingCountryCode: 'US',
requestedId: null
};

const multiLengthMaestroWithPanLengthMock = {
brands: [
{
enableLuhnCheck: true,
supported: true,
brand: 'maestro',
cvcPolicy: 'required',
expiryDatePolicy: 'required',
panLength: 18
}
],
issuingCountryCode: 'US',
requestedId: null
};

const amexWithPanLengthMock = {
brands: [
{
enableLuhnCheck: true,
supported: true,
brand: 'amex',
cvcPolicy: 'required',
expiryDatePolicy: 'required',
panLength: 15
}
],
issuingCountryCode: 'US',
requestedId: null
};

const kcpMockOptionalDateAndCvcWithPanLengthMock = {
brands: [
{
enableLuhnCheck: true,
supported: true,
brand: 'korean_local_card',
cvcPolicy: 'optional',
expiryDatePolicy: 'optional',
panLength: 16
}
],
requestedId: null,
issuingCountryCode: 'KR'
};

export {
optionalDateAndCvcMock,
hiddenDateAndCvcMock,
optionalDateWithPanLengthMock,
hiddenDateWithPanLengthMock,
optionalDateAndCvcWithPanLengthMock,
multiLengthMaestroWithPanLengthMock,
amexWithPanLengthMock,
kcpMockOptionalDateAndCvcWithPanLengthMock
};
46 changes: 46 additions & 0 deletions packages/e2e-playwright/models/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,46 @@ class Card extends Base {

readonly cardNumberField: Locator;
readonly cardNumberLabelElement: Locator;
readonly cardNumberLabelWithFocus: Locator;
readonly cardNumberErrorElement: Locator;
readonly cardNumberInput: Locator;
readonly brandingIcon: Locator;

readonly expiryDateField: Locator;
readonly expiryDateLabelElement: Locator;
readonly expiryDateLabelText: Locator;
readonly expiryDateContextualElement: Locator;
readonly expiryDateLabelWithFocus: Locator;
readonly expiryDateInput: Locator;
readonly expiryDateIframeContextualElement: Locator;
readonly expiryDateErrorElement: Locator;

readonly cvcField: Locator;
readonly cvcLabelElement: Locator;
readonly cvcLabelText: Locator;
readonly cvcLabelWithFocus: Locator;
readonly cvcErrorElement: Locator;
readonly cvcContextualElement: Locator;
readonly cvcInput: Locator;
readonly cvcIframeContextualElement: Locator;

readonly holderNameField: Locator;
readonly holderNameLabelWithFocus: Locator;

readonly installmentsPaymentLabel: Locator;
readonly revolvingPaymentLabel: Locator;
readonly installmentsDropdown: Locator;
readonly selectorList: Locator;

readonly ssnField: Locator;
readonly ssnLabelWithFocus: Locator;

readonly addressField: Locator;
readonly addressLabelWithFocus: Locator;

readonly kcpTaxNumberField: Locator;
readonly kcpTaxNumberLabelWithFocus: Locator;

constructor(
public readonly page: Page,
rootElementSelector = '.adyen-checkout__card-input'
Expand All @@ -58,6 +75,7 @@ class Card extends Base {
this.cardNumberField = this.rootElement.locator('.adyen-checkout__field--cardNumber'); // Holder
this.cardNumberLabelElement = this.cardNumberField.locator('.adyen-checkout__label');
this.cardNumberErrorElement = this.cardNumberField.locator('.adyen-checkout-contextual-text--error');
this.cardNumberLabelWithFocus = this.cardNumberField.locator('.adyen-checkout__label--focused');

this.brandingIcon = this.rootElement.locator('.adyen-checkout__card__cardNumber__brandIcon');
/**
Expand All @@ -70,9 +88,11 @@ class Card extends Base {
* Expiry Date elements, in Checkout
*/
this.expiryDateField = this.rootElement.locator('.adyen-checkout__field--expiryDate'); // Holder
this.expiryDateLabelElement = this.expiryDateField.locator('.adyen-checkout__label');
this.expiryDateLabelText = this.expiryDateField.locator('.adyen-checkout__label__text');
this.expiryDateContextualElement = this.expiryDateField.locator('.adyen-checkout-contextual-text'); // Related contextual element
this.expiryDateErrorElement = this.expiryDateField.locator('.adyen-checkout-contextual-text--error'); // Related error element
this.expiryDateLabelWithFocus = this.expiryDateField.locator('.adyen-checkout__label--focused');

/**
* Expiry Date elements, in iframe
Expand All @@ -85,9 +105,11 @@ class Card extends Base {
* Security code elements, in Checkout
*/
this.cvcField = this.rootElement.locator('.adyen-checkout__field--securityCode'); // Holder
this.cvcLabelElement = this.cvcField.locator('.adyen-checkout__label');
this.cvcLabelText = this.cvcField.locator('.adyen-checkout__label__text');
this.cvcContextualElement = this.cvcField.locator('.adyen-checkout-contextual-text'); // Related contextual element
this.cvcErrorElement = this.cvcField.locator('.adyen-checkout-contextual-text--error'); // Related error element
this.cvcLabelWithFocus = this.cvcField.locator('.adyen-checkout__label--focused');

/**
* Security code elements, in iframe
Expand All @@ -96,13 +118,37 @@ class Card extends Base {
this.cvcInput = cvcIframe.locator(`input[aria-label="${CVC_IFRAME_LABEL}"]`);
this.cvcIframeContextualElement = cvcIframe.locator('.aria-context');

/**
* HolderName elements, in Checkout
*/
this.holderNameField = this.rootElement.locator('.adyen-checkout__card__holderName'); // Holder
this.holderNameLabelWithFocus = this.holderNameField.locator('.adyen-checkout__label--focused');

/**
* Installments related elements
*/
this.installmentsPaymentLabel = this.rootElement.getByText(INSTALLMENTS_PAYMENTS);
this.revolvingPaymentLabel = this.rootElement.getByText(REVOLVING_PAYMENT);
this.installmentsDropdown = this.rootElement.locator('.adyen-checkout__dropdown__button');
this.selectorList = this.rootElement.getByRole('listbox');

/**
* Social Security Number related elements
*/
this.ssnField = this.rootElement.locator('.adyen-checkout__field--socialSecurityNumber'); // Holder
this.ssnLabelWithFocus = this.ssnField.locator('.adyen-checkout__label--focused');

/**
* AVS related elements
*/
this.addressField = this.rootElement.locator('.adyen-checkout__field--street'); // Holder
sponglord marked this conversation as resolved.
Show resolved Hide resolved
this.addressLabelWithFocus = this.addressField.locator('.adyen-checkout__label--focused');

/**
* KCP related elements
*/
this.kcpTaxNumberField = this.rootElement.locator('.adyen-checkout__field--kcp-taxNumber'); // Holder
this.kcpTaxNumberLabelWithFocus = this.kcpTaxNumberField.locator('.adyen-checkout__label--focused');
}

get availableBrands() {
Expand Down
6 changes: 5 additions & 1 deletion packages/e2e-playwright/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ const config: PlaywrightTestConfig = {
{
name: 'chromium',
use: {
...devices['Desktop Chrome']
...devices['Desktop Chrome'],
contextOptions: {
// chromium-specific permissions
permissions: ['clipboard-read', 'clipboard-write']
}
}
},

Expand Down
4 changes: 2 additions & 2 deletions packages/e2e-playwright/tests/a11y/card/avs.a11y.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test as base, expect } from '@playwright/test';
import { binLookupMock } from '../../../mocks/binLookup/binLookup.mock';
import { optionalDateAndCvcMock } from '../../../mocks/binLookup/binLookup.data';
import { optionalDateAndCvcWithPanLengthMock } from '../../../mocks/binLookup/binLookup.data';
import { REGULAR_TEST_CARD } from '../../utils/constants';
import { CardWithAvs } from '../../../models/card-avs';
import { getStoryUrl } from '../../utils/getStoryUrl';
Expand All @@ -15,7 +15,7 @@ const test = base.extend<Fixture>({
const cardPage = new CardWithAvs(page);
const componentConfig = { billingAddressRequired: true, billingAddressRequiredFields: ['street', 'houseNumberOrName', 'postalCode', 'city'] };
await cardPage.goto(getStoryUrl({ baseUrl: URL_MAP.card, componentConfig }));
await binLookupMock(page, optionalDateAndCvcMock);
await binLookupMock(page, optionalDateAndCvcWithPanLengthMock);
await use(cardPage);
}
});
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,44 +1,24 @@
import { test } from '@playwright/test';
import { mocks } from './mocks';
import { binLookupUrl, getBinLookupMock, turnOffSDKMocking } from '../../cardMocks';
import { test, expect } from '../../../../../fixtures/card.fixture';
import { getStoryUrl } from '../../../../utils/getStoryUrl';
import { URL_MAP } from '../../../../../fixtures/URL_MAP';
import { binLookupMock } from '../../../../../mocks/binLookup/binLookup.mock';
import { optionalDateAndCvcWithPanLengthMock } from '../../../../../mocks/binLookup/binLookup.data';
import { REGULAR_TEST_CARD } from '../../../../utils/constants';

/**
* NOTE - we are mocking the response until such time as we have a genuine card that returns the properties we want to test
*/
test.describe('Test Card, binLookup w. panLength property & address fields', () => {
test('#1 Fill out PAN & see that focus moves to an address field since expiryDate & cvc are optional', async ({ card, page }) => {
await binLookupMock(page, optionalDateAndCvcWithPanLengthMock);
sponglord marked this conversation as resolved.
Show resolved Hide resolved

let currentMock = null;
const componentConfig = { billingAddressRequired: true, billingAddressRequiredFields: ['street', 'houseNumberOrName', 'postalCode', 'city'] };

const getMock = val => {
const mock = mocks[val];
currentMock = getBinLookupMock(binLookupUrl, mock);
return currentMock;
};
await card.goto(getStoryUrl({ baseUrl: URL_MAP.card, componentConfig }));

test.describe('Test how Card Component handles binLookup returning a panLength property for a card with address fields', () => {
// use config from panLength.avs.clientScripts.js
await card.isComponentVisible();

test.beforeEach(async () => {
// todo: go to the card page
// For individual test suites (that rely on binLookup & perhaps are being run in isolation)
// - provide a way to ensure SDK bin mocking is turned off
await turnOffSDKMocking();
});
await card.typeCardNumber(REGULAR_TEST_CARD);

test('#1 Fill out PAN (binLookup w. panLength) see that focus moves to an address field since expiryDate & cvc are optional', async () => {
// use mock await t.addRequestHooks(getMock('optionalDateAndCVC'));
// Wait for field to appear in DOM
// await cardPage.numHolder();
//
// const firstDigits = REGULAR_TEST_CARD.substring(0, 15);
// const lastDigits = REGULAR_TEST_CARD.substring(15, 16);
//
// await cardPage.cardUtils.fillCardNumber(t, firstDigits);
//
// await t.wait(INPUT_DELAY);
//
// await cardPage.cardUtils.fillCardNumber(t, lastDigits);
//
// // Expect focus to be place on address (street) field
// await t.expect(cardPage.addressLabelWithFocus.exists).ok();
// Expect focus to be place on address (street) field
await expect(card.cardNumberLabelWithFocus).not.toBeVisible();
await expect(card.addressLabelWithFocus).toBeVisible();
});
});
Loading
Loading