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

POC: Tree shaking with new operator #2323

Merged
merged 140 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 139 commits
Commits
Show all changes
140 commits
Select commit Hold shift + click to select a range
a0177af
feat: passing component as prop
ribeiroguilherme Jun 20, 2023
26ae1dc
fix: fixed build
ribeiroguilherme Jun 20, 2023
0ba298e
feat: attempt with different rollup
ribeiroguilherme Jun 21, 2023
393543c
fix: reverting rollup
ribeiroguilherme Jun 21, 2023
9c9bf5f
feat: tree shaking kinda working with preserveModules
ribeiroguilherme Jun 26, 2023
0852ea5
fix: rendering proper components
ribeiroguilherme Jun 26, 2023
655ec0e
feat: using registry. auto option
ribeiroguilherme Jul 3, 2023
b8903a0
fix: mapping components
ribeiroguilherme Jul 3, 2023
4eb5501
feat: working with typescript
ribeiroguilherme Jul 5, 2023
191ae9f
feat: deleted unused files
ribeiroguilherme Jul 5, 2023
4c85734
feat: clean up
ribeiroguilherme Jul 5, 2023
41ff9f4
feat: more clean up
ribeiroguilherme Jul 6, 2023
241311f
fix: dev env. bcmc txVariants
ribeiroguilherme Jul 6, 2023
11c5d13
feat: adjusting Components
ribeiroguilherme Jul 6, 2023
140f3aa
fix: fixed createfromaction
ribeiroguilherme Jul 6, 2023
917f9f9
feat: fixed playground
ribeiroguilherme Jul 6, 2023
06f7c25
fix: circular dependency
ribeiroguilherme Jul 6, 2023
e3ef677
fix: improved registry. cleanup paypal
ribeiroguilherme Jul 6, 2023
ec85f33
feat: added browserlist
ribeiroguilherme Jul 6, 2023
aa0a0c7
feat: fixed type
ribeiroguilherme Aug 2, 2023
0214728
First PoC - Dropin & Card components are initialised directly with th…
sponglord Aug 10, 2023
9807812
Adding warnings if component initialised without ref to checkout
sponglord Aug 10, 2023
da23cfe
Adding Redirect to Card.dependencies
sponglord Aug 10, 2023
4a3b7d2
Bancontact card working
sponglord Aug 10, 2023
739817c
StoredCards working in Dropin
sponglord Aug 10, 2023
4fc5311
Bancontact card working in Dropin
sponglord Aug 10, 2023
24f654c
InstantPaymentMethods (googlePay) working in Dropin
sponglord Aug 10, 2023
e04c11c
Starting to handle Redirect PMs
sponglord Aug 10, 2023
2f19ea0
UIElement retrieves calculatedProps
sponglord Aug 10, 2023
6839a97
Dropin renders fully for NL & BE
sponglord Aug 10, 2023
e91f4a2
Dropin sessions working
sponglord Aug 11, 2023
093070c
All PMs now work (constructors altered to work against new UIElement)
sponglord Aug 11, 2023
0df6d3f
Adding missing types for props param
sponglord Aug 11, 2023
d5eb460
props param not obligatory in Bancontact. Removed superfluous setting…
sponglord Aug 11, 2023
9db0b81
Removing unnecessary txVariants from static prop in Card
sponglord Aug 11, 2023
24fcfdf
All PMs now work (constructors altered to work against new UIElement)
sponglord Aug 11, 2023
6f88ad7
Testing whether all subclasses of UIElement need their own constructor
sponglord Aug 11, 2023
b38f51f
Adding a warning for if props.type missing in UIElement
sponglord Aug 11, 2023
e41a85d
Remove circular dependencies caused by using instanceof Core in UIEle…
sponglord Aug 11, 2023
43f670a
Removing old constructors and other commented out code
sponglord Aug 16, 2023
0caeb27
Clearing calls to checkout.create from playground files
sponglord Aug 16, 2023
937114a
Testing Klarna
sponglord Aug 16, 2023
99a3e82
Klarna works as redirect or widget
sponglord Aug 16, 2023
cbec839
Adding comment about everything that extends UIElement "needing" a co…
sponglord Aug 16, 2023
b159193
updated comment
sponglord Aug 17, 2023
3d4ab42
Used init function to solve problem of accessing this.constructor.type
sponglord Aug 17, 2023
a7ff13a
Not necessary to pass checkoutRef to init function
sponglord Aug 17, 2023
6980242
Don't pass type in Bancontact constructor
sponglord Aug 17, 2023
d0ded68
props conditional for IssuerListContainer
sponglord Aug 17, 2023
10f4800
Initialise all playground issuer list comps with the new opeerator
sponglord Aug 18, 2023
c8e972a
No need to generate props._parentInstance in core.ts now that BaseEle…
sponglord Aug 18, 2023
643d8ea
Fixed typing for new component constructor
sponglord Aug 18, 2023
1a17130
Created NewableComponent type
sponglord Aug 18, 2023
3e8b780
Removed the create & handleCreate functions from core.ts
sponglord Aug 18, 2023
b78dc61
Reinstated a simplified create function (for use by UMD merchants). T…
sponglord Aug 18, 2023
ac04f1b
Renaming generateUIElementProps & generateUIElementForDropin functions
sponglord Aug 18, 2023
75e5a71
Distinguish UMD users and throw error if npm users use checkout.create
sponglord Aug 18, 2023
5f164ec
Comment out logs
sponglord Aug 21, 2023
d2aefef
feat: draft
ribeiroguilherme Aug 25, 2023
b08b479
feat: draft pt2
ribeiroguilherme Aug 28, 2023
b5f2d62
feat draft pt3
ribeiroguilherme Aug 28, 2023
a1bd369
feat: draft pt5
ribeiroguilherme Aug 28, 2023
a3561e5
feat: draft again
ribeiroguilherme Aug 29, 2023
100aace
feat: draft again
ribeiroguilherme Aug 30, 2023
25bc230
feat: more changes
ribeiroguilherme Aug 30, 2023
b9c28fb
feat: fixed storing component ref on core
ribeiroguilherme Aug 31, 2023
a8a79bd
feat: added testing UMD page and fixes
ribeiroguilherme Aug 31, 2023
f407471
feat: minor changes
ribeiroguilherme Aug 31, 2023
95f9906
fix: amount
ribeiroguilherme Aug 31, 2023
02b0a10
fix: umd name
ribeiroguilherme Sep 1, 2023
04ee992
feat: attempt to improve drop-in rendering redirects
ribeiroguilherme Sep 1, 2023
bdb3785
feat: using txvariants from file
ribeiroguilherme Sep 4, 2023
fee3105
feat: adjusted paymentmethodsconfiguration
ribeiroguilherme Sep 4, 2023
05f5405
fix: issuerlist types
ribeiroguilherme Sep 4, 2023
1718897
fix: removed paymentmethodsconfiguration from core
ribeiroguilherme Sep 4, 2023
bf62a8d
fix: redirect
ribeiroguilherme Sep 5, 2023
86684a6
feat: minor changes
ribeiroguilherme Sep 5, 2023
d5734d6
tree shaking translations. fixed secured fields. commented out some t…
ribeiroguilherme Sep 7, 2023
0e4836b
fix: createFromAction. not fetching config from api for stored payments
ribeiroguilherme Sep 8, 2023
21086ba
Merge branch 'v6' into poc/component-tree-shaking-new-operator-v2
ribeiroguilherme Sep 8, 2023
c151b2e
feat: autoregistering components. threeds added to registry by defaul…
ribeiroguilherme Sep 12, 2023
23bd24a
feat: locale as string, and added translationFile prop
ribeiroguilherme Sep 13, 2023
344fc8b
feat: moved icore to types file. cleaned up some code
ribeiroguilherme Sep 13, 2023
ef3b38e
feat: typescript bump
ribeiroguilherme Sep 14, 2023
b57f8c6
feat: default export added. fixed typescript on auto
ribeiroguilherme Sep 14, 2023
b27256e
Fixing types
sponglord Sep 20, 2023
bcb83dc
Make sure this.props.Dropin is available
sponglord Sep 20, 2023
3d90e04
Fixing type for SRPanel config
sponglord Sep 20, 2023
44cdde4
SecuredFields component and related files renamed to CustomCard
sponglord Sep 20, 2023
0d76d75
Fixing CustomCard types
sponglord Sep 20, 2023
8c4bffd
feat: removed babel, polyfils. adjusted rollup
ribeiroguilherme Sep 20, 2023
078d557
feat: populatting bundle type into core
ribeiroguilherme Sep 21, 2023
9fd9017
Make name optional in BrandsConfiguration type
sponglord Sep 21, 2023
acaf66a
fixed package json exports
ribeiroguilherme Sep 21, 2023
35cbc20
Removing AdyenWeb imports
sponglord Sep 22, 2023
f698aeb
Adding NODE_ENV back to package.json
sponglord Sep 22, 2023
98645f0
feat: removed default export from playground. fixed umd naming and pa…
ribeiroguilherme Sep 22, 2023
5981586
Correctly declare props that can be set on the Card component
sponglord Sep 22, 2023
b0c562c
Added data-uid attrs to the custom card fields (will allow prefilling…
sponglord Sep 22, 2023
a2e79b6
Keep paymentsConfig v69+ compatible
sponglord Sep 22, 2023
c800201
Allow maskSecurityCode config prop for CustomCard
sponglord Sep 22, 2023
24af2a0
fix: direct imports. error when not registering class
ribeiroguilherme Sep 22, 2023
61d9e99
Merge remote-tracking branch 'origin/poc/component-tree-shaking-new-o…
sponglord Sep 25, 2023
c957b1a
Create CustomCardProps type
sponglord Sep 25, 2023
ad540fc
fix: changed uielement validation on registry
ribeiroguilherme Sep 25, 2023
e394fe1
Made some RiskModule config props optional
sponglord Sep 25, 2023
55a43bf
Tidying up Card playground file
sponglord Sep 25, 2023
e69a159
Stopping names on window object from clashing
sponglord Sep 25, 2023
e739c69
feat: tests running
ribeiroguilherme Sep 26, 2023
c3ea7fb
feat: fixed tests of core folder
ribeiroguilherme Sep 27, 2023
807936f
test: uielement fix
ribeiroguilherme Sep 27, 2023
a75ee9a
test: fix baseelement
ribeiroguilherme Sep 27, 2023
94a1726
CustomCardProps don't inherit the 'configuration' prop
sponglord Sep 27, 2023
12d851d
Merge remote-tracking branch 'origin/poc/component-tree-shaking-new-o…
sponglord Sep 27, 2023
2718e82
remove brands array from card config in playground
sponglord Sep 27, 2023
b4d2b67
test: fixed click to pay tests
ribeiroguilherme Sep 27, 2023
c955879
test: fixed payment method list. afterpay
ribeiroguilherme Sep 27, 2023
aed2242
moved comment
sponglord Sep 28, 2023
36f40db
Merge remote-tracking branch 'origin/poc/component-tree-shaking-new-o…
sponglord Sep 28, 2023
cccb741
Removing old (API v66) 3DS2 e2e tests
sponglord Sep 28, 2023
ad1c008
tests: fixed many tests
ribeiroguilherme Sep 28, 2023
57622fd
tests: more tests
ribeiroguilherme Sep 29, 2023
ac101b1
tests: more fixes
ribeiroguilherme Sep 29, 2023
d9b0fba
tests: fixed all
ribeiroguilherme Sep 29, 2023
9fce638
fix: interfaces of components
ribeiroguilherme Oct 2, 2023
3251083
Merge branch 'v6' into poc/component-tree-shaking-new-operator-v2
ribeiroguilherme Oct 2, 2023
97fcd5c
Removing legacy action types relating to 3DS2. Preparing for MDFlow u…
sponglord Oct 2, 2023
9466ee3
cleanup: tx variants boleto, onlinebanking, entercash, visa
ribeiroguilherme Oct 4, 2023
9604d68
feat: umd source maps
ribeiroguilherme Oct 4, 2023
3170095
disableIOSArrowKeys config prop is false by default
sponglord Oct 4, 2023
ea08052
feat: sourcemaps for es modules too
ribeiroguilherme Oct 4, 2023
2de84c1
tests: partially fixed e2e playwright
ribeiroguilherme Oct 4, 2023
91e344a
tests: checking report on ci with list reporter
ribeiroguilherme Oct 4, 2023
c919970
fix: storybook
ribeiroguilherme Oct 6, 2023
668544b
feat: type loosing for ctp
ribeiroguilherme Oct 6, 2023
4693680
fix: storybook phone input
ribeiroguilherme Oct 9, 2023
1ef6165
feat: disable lint when parsing js. testing typescript generation. al…
ribeiroguilherme Oct 9, 2023
dac3239
fix: adding card missing types. type-checking before building
ribeiroguilherme Oct 10, 2023
b43280c
Merge branch 'v6' into poc/component-tree-shaking-new-operator-v2
ribeiroguilherme Oct 17, 2023
c766a50
Merge branch 'v6' into poc/component-tree-shaking-new-operator-v2
ribeiroguilherme Oct 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ dist
coverage
storybook-static

# Playwright reports
packages/playground/playwright-report/


*.log*
.env
.env*
Expand Down Expand Up @@ -32,4 +36,4 @@ Vagrantfile

# Certifictes
cert
*.pem
*.pem
52,978 changes: 52,978 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions packages/e2e-playwright/app/src/pages/ANCV/ANCV.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import AdyenCheckout from '@adyen/adyen-web';
import '@adyen/adyen-web/dist/es/adyen.css';
import { AdyenCheckout, ANCV, Card } from '@adyen/adyen-web';
import '@adyen/adyen-web/styles/adyen.css';
import { handleSubmit, handleAdditionalDetails, handleError, handleOrderRequest, showAuthorised } from '../../handlers';
import { amount, shopperLocale, countryCode } from '../../services/commonConfig';
import '../../style.scss';
Expand Down Expand Up @@ -38,7 +38,7 @@ const initCheckout = async () => {
onOrderCreated: data => {
console.log('=== onOrderCreated ===', data);

window.paymentMethod = checkout.create('card').mount('.ancv-field');
window.paymentMethod = new Card({ core: checkout }).mount('.ancv-field');
},
onPaymentCompleted: () => {
showAuthorised();
Expand All @@ -52,7 +52,7 @@ const initCheckout = async () => {
// ...window.mainConfiguration
});

window.paymentMethod = checkout.create('ancv').mount('.ancv-field');
window.paymentMethod = new ANCV({ core: checkout }).mount('.ancv-field');

document.querySelector('#ancv-pay-button').addEventListener('click', () => {
window.paymentMethod.submit();
Expand Down
51 changes: 25 additions & 26 deletions packages/e2e-playwright/app/src/pages/Cards/Cards.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import AdyenCheckout from '@adyen/adyen-web';
import '@adyen/adyen-web/dist/es/adyen.css';
import { AdyenCheckout, Card } from '@adyen/adyen-web';
import '@adyen/adyen-web/styles/adyen.css';
import { handleSubmit, handleAdditionalDetails, handleError } from '../../handlers';
import { amount, shopperLocale, countryCode } from '../../services/commonConfig';
import '../../style.scss';
Expand All @@ -20,30 +20,29 @@ const initCheckout = async () => {
});

// Credit card with installments
window.card = checkout
.create('card', {
brands: ['mc', 'visa', 'amex', 'maestro', 'bcmc'],
onChange: state => {
/**
* Needed now that, for v5, we enhance the securedFields state.errors object with a rootNode prop
* - Testcafe doesn't like a ClientFunction retrieving an object with a DOM node in it!?
*
* AND, for some reason, if you place this onChange function in expiryDate.clientScripts.js it doesn't always get read.
* It'll work when it's part of a small batch but if part of the full test suite it gets ignored - so the tests that rely on
* window.mappedStateErrors fail
*/
if (!!Object.keys(state.errors).length) {
// Replace any rootNode values in the objects in state.errors with an empty string
const nuErrors = Object.entries(state.errors).reduce((acc, [fieldType, error]) => {
acc[fieldType] = error ? { ...error, rootNode: '' } : error;
return acc;
}, {});
window.mappedStateErrors = nuErrors;
}
},
...window.cardConfig
})
.mount('.card-field');
window.card = new Card({
core: checkout,
brands: ['mc', 'visa', 'amex', 'maestro', 'bcmc'],
onChange: state => {
/**
* Needed now that, for v5, we enhance the securedFields state.errors object with a rootNode prop
* - Testcafe doesn't like a ClientFunction retrieving an object with a DOM node in it!?
*
* AND, for some reason, if you place this onChange function in expiryDate.clientScripts.js it doesn't always get read.
* It'll work when it's part of a small batch but if part of the full test suite it gets ignored - so the tests that rely on
* window.mappedStateErrors fail
*/
if (!!Object.keys(state.errors).length) {
// Replace any rootNode values in the objects in state.errors with an empty string
const nuErrors = Object.entries(state.errors).reduce((acc, [fieldType, error]) => {
acc[fieldType] = error ? { ...error, rootNode: '' } : error;
return acc;
}, {});
window.mappedStateErrors = nuErrors;
}
},
...window.cardConfig
}).mount('.card-field');
};

initCheckout();
27 changes: 13 additions & 14 deletions packages/e2e-playwright/app/src/pages/CustomCards/CustomCards.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import AdyenCheckout from '@adyen/adyen-web';
import '@adyen/adyen-web/dist/es/adyen.css';
import { AdyenCheckout, CustomCard } from '@adyen/adyen-web';
import '@adyen/adyen-web/styles/adyen.css';
import { handleSubmit, handleAdditionalDetails } from '../../handlers';
import { amount, shopperLocale, countryCode } from '../../services/commonConfig';
import '../../style.scss';
Expand All @@ -20,18 +20,17 @@ const initCheckout = async () => {
...window.mainConfiguration
});

window.securedFields = checkout
.create('customcard', {
type: 'card',
brands: ['mc', 'visa', 'amex', 'bcmc', 'maestro', 'cartebancaire'],
onConfigSuccess,
onBrand,
onFocus: setFocus,
onBinLookup,
onChange,
...window.cardConfig
})
.mount('.secured-fields');
window.securedFields = new CustomCard({
core: checkout,
type: 'card',
brands: ['mc', 'visa', 'amex', 'bcmc', 'maestro', 'cartebancaire'],
onConfigSuccess,
onBrand,
onFocus: setFocus,
onBinLookup,
onChange,
...window.cardConfig
}).mount('.secured-fields');

createPayButton('.secured-fields', window.securedFields, 'securedfields');

Expand Down
13 changes: 4 additions & 9 deletions packages/e2e-playwright/app/src/pages/IssuerLists/IssuerLists.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import AdyenCheckout from '@adyen/adyen-web';
import '@adyen/adyen-web/dist/es/adyen.css';
import { AdyenCheckout, Ideal } from '@adyen/adyen-web';
import '@adyen/adyen-web/styles/adyen.css';
import { handleSubmit, handleAdditionalDetails, handleError } from '../../handlers';
import { amount, shopperLocale, countryCode } from '../../services/commonConfig';
import '../../style.scss';
Expand All @@ -24,16 +24,11 @@ const initCheckout = async () => {
showPayButton: true,
onSubmit: handleSubmit,
onAdditionalDetails: handleAdditionalDetails,
onError: handleError,
paymentMethodsConfiguration: {
ideal: {
highlightedIssuers: ['1121', '1154', '1153']
}
}
onError: handleError
// ...window.mainConfiguration
});

window.ideal = checkout.create('ideal').mount('.ideal-field');
window.ideal = new Ideal({ core: checkout, highlightedIssuers: ['1121', '1154', '1153'] }).mount('.ideal-field');
};

initCheckout();
4 changes: 2 additions & 2 deletions packages/e2e-playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"html-webpack-plugin": "5.5.1",
"sass-loader": "^10.2.0",
"style-loader": "^2.0.0",
"ts-loader": "^8.1.0",
"typescript": "^4.4.4",
"ts-loader": "9.4.4",
"typescript": "5.2.2",
"webpack": "5.81.0",
"webpack-cli": "5.0.2",
"webpack-dev-server": "4.13.3"
Expand Down
4 changes: 2 additions & 2 deletions packages/e2e-playwright/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dotenv.config({ path: path.resolve('../../', '.env') });
* See https://playwright.dev/docs/test-configuration.
*/
const config: PlaywrightTestConfig = {
testDir: './tests',
testDir: './tests/',
/* Maximum time one test can run for. */
timeout: 10 * 2000,
expect: {
Expand All @@ -29,7 +29,7 @@ const config: PlaywrightTestConfig = {
workers: process.env.CI ? 1 : 1,

/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: [['html', { open: 'never' }]],
reporter: [['html', { open: 'never' }], ['list']],

/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
Expand Down
20 changes: 11 additions & 9 deletions packages/e2e-playwright/tests/card/card.avs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ import { REGULAR_TEST_CARD } from '../utils/constants';
import { binLookupMock } from '../../mocks/binLookup/binLookup.mock';
import { optionalDateAndCvcMock } from '../../mocks/binLookup/binLookup.data';

test('should move the focus to the address field since expiryDate & cvc are optional', async ({ cardAvsPage }) => {
const { cardWithAvs, page } = cardAvsPage;
test.describe('Card - AVS', () => {
test('should move the focus to the address field since expiryDate & cvc are optional', async ({ cardAvsPage }) => {
const { cardWithAvs, page } = cardAvsPage;

await binLookupMock(page, optionalDateAndCvcMock);
await binLookupMock(page, optionalDateAndCvcMock);

await cardWithAvs.isComponentVisible();
await cardWithAvs.isComponentVisible();

const firstDigits = REGULAR_TEST_CARD.substring(0, 15);
const lastDigits = REGULAR_TEST_CARD.substring(15, 16);
const firstDigits = REGULAR_TEST_CARD.substring(0, 15);
const lastDigits = REGULAR_TEST_CARD.substring(15, 16);

await cardWithAvs.typeCardNumber(firstDigits);
await cardWithAvs.typeCardNumber(lastDigits);
await cardWithAvs.typeCardNumber(firstDigits);
await cardWithAvs.typeCardNumber(lastDigits);

await expect(cardWithAvs.billingAddress.addressInput).toBeFocused();
await expect(cardWithAvs.billingAddress.addressInput).toBeFocused();
});
});
134 changes: 68 additions & 66 deletions packages/e2e-playwright/tests/card/card.contextualTexts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,96 +7,98 @@ const CVC_CONTEXTUAL_TEXT_3_DIGITS = LANG['creditCard.securityCode.contextualTex
const CVC_CONTEXTUAL_TEXT_4_DIGITS = LANG['creditCard.securityCode.contextualText.4digits'];
const CVC_ERROR = LANG['error.va.sf-cc-cvc.01'];

test('#1 Should inspect the card inputs and see they have contextual elements set', async ({ cardPage }) => {
const { card, page } = cardPage;
test.describe('Card - Contextual text', () => {
test('#1 Should inspect the card inputs and see they have contextual elements set', async ({ cardPage }) => {
const { card, page } = cardPage;

await card.isComponentVisible();
await card.isComponentVisible();

// checkout expiryDate element
await expect(card.expiryDateContextualElement).toHaveText(EXPIRY_DATE_CONTEXTUAL_TEXT);
const expiryDateAriaHidden = await card.expiryDateContextualElement.getAttribute('aria-hidden');
await expect(expiryDateAriaHidden).toEqual('true');
// checkout expiryDate element
await expect(card.expiryDateContextualElement).toHaveText(EXPIRY_DATE_CONTEXTUAL_TEXT);
const expiryDateAriaHidden = await card.expiryDateContextualElement.getAttribute('aria-hidden');
await expect(expiryDateAriaHidden).toEqual('true');

// iframe expiryDate element
await expect(card.expiryDateIframeContextualElement).toHaveText(EXPIRY_DATE_CONTEXTUAL_TEXT);
// iframe expiryDate element
await expect(card.expiryDateIframeContextualElement).toHaveText(EXPIRY_DATE_CONTEXTUAL_TEXT);

// checkout security code contextual element
await expect(card.cvcContextualElement).toHaveText(CVC_CONTEXTUAL_TEXT_3_DIGITS);
const cvcAriaHidden = await card.cvcContextualElement.getAttribute('aria-hidden');
await expect(cvcAriaHidden).toEqual('true');
// checkout security code contextual element
await expect(card.cvcContextualElement).toHaveText(CVC_CONTEXTUAL_TEXT_3_DIGITS);
const cvcAriaHidden = await card.cvcContextualElement.getAttribute('aria-hidden');
await expect(cvcAriaHidden).toEqual('true');

// iframe security code element
await expect(card.cvcIframeContextualElement).toHaveText(CVC_CONTEXTUAL_TEXT_3_DIGITS);
// iframe security code element
await expect(card.cvcIframeContextualElement).toHaveText(CVC_CONTEXTUAL_TEXT_3_DIGITS);

// Type amex number and see the contextual element change in the CVC field
await card.typeCardNumber(AMEX_CARD);
// Type amex number and see the contextual element change in the CVC field
await card.typeCardNumber(AMEX_CARD);

await expect(card.cvcContextualElement).toHaveText(CVC_CONTEXTUAL_TEXT_4_DIGITS);
await expect(card.cvcIframeContextualElement).toHaveText(CVC_CONTEXTUAL_TEXT_4_DIGITS);
await expect(card.cvcContextualElement).toHaveText(CVC_CONTEXTUAL_TEXT_4_DIGITS);
await expect(card.cvcIframeContextualElement).toHaveText(CVC_CONTEXTUAL_TEXT_4_DIGITS);

// Delete the card number and see the contextual element reset in the CVC field
await card.deleteCardNumber();
// Delete the card number and see the contextual element reset in the CVC field
await card.deleteCardNumber();

await expect(card.cvcContextualElement).toHaveText(CVC_CONTEXTUAL_TEXT_3_DIGITS);
await expect(card.cvcIframeContextualElement).toHaveText(CVC_CONTEXTUAL_TEXT_3_DIGITS);
});
await expect(card.cvcContextualElement).toHaveText(CVC_CONTEXTUAL_TEXT_3_DIGITS);
await expect(card.cvcIframeContextualElement).toHaveText(CVC_CONTEXTUAL_TEXT_3_DIGITS);
});

test('#2 Should inspect the cvc input for a contextual text set, then it should be replaced by an error, then reset', async ({ cardPage }) => {
const { card, page } = cardPage;
test('#2 Should inspect the cvc input for a contextual text set, then it should be replaced by an error, then reset', async ({ cardPage }) => {
const { card, page } = cardPage;

await card.isComponentVisible();
await card.isComponentVisible();

// checkout security code contextual element
await expect(card.cvcContextualElement).toHaveText(CVC_CONTEXTUAL_TEXT_3_DIGITS);
let cvcAriaHidden = await card.cvcContextualElement.getAttribute('aria-hidden');
await expect(cvcAriaHidden).toEqual('true');
// checkout security code contextual element
await expect(card.cvcContextualElement).toHaveText(CVC_CONTEXTUAL_TEXT_3_DIGITS);
let cvcAriaHidden = await card.cvcContextualElement.getAttribute('aria-hidden');
await expect(cvcAriaHidden).toEqual('true');

// error element hidden
await expect(card.cvcErrorElement).not.toBeVisible();
// error element hidden
await expect(card.cvcErrorElement).not.toBeVisible();

// iframe security code contextual element
await expect(card.cvcIframeContextualElement).toHaveText(CVC_CONTEXTUAL_TEXT_3_DIGITS);
// iframe security code contextual element
await expect(card.cvcIframeContextualElement).toHaveText(CVC_CONTEXTUAL_TEXT_3_DIGITS);

// press pay to generate errors
await cardPage.pay();
// press pay to generate errors
await cardPage.pay();

// checkout security code error element
await expect(card.cvcErrorElement).toBeVisible();
await expect(card.cvcErrorElement).toHaveText(CVC_ERROR);
cvcAriaHidden = await card.cvcErrorElement.getAttribute('aria-hidden');
await expect(cvcAriaHidden).toEqual('true');
// checkout security code error element
await expect(card.cvcErrorElement).toBeVisible();
await expect(card.cvcErrorElement).toHaveText(CVC_ERROR);
cvcAriaHidden = await card.cvcErrorElement.getAttribute('aria-hidden');
await expect(cvcAriaHidden).toEqual('true');

// contextual element being hidden
await expect(card.cvcContextualElement).not.toBeVisible();
// contextual element being hidden
await expect(card.cvcContextualElement).not.toBeVisible();

// iframe contextual (error) element
await expect(card.cvcIframeContextualElement).toHaveText(CVC_ERROR);
// iframe contextual (error) element
await expect(card.cvcIframeContextualElement).toHaveText(CVC_ERROR);

// Allow default focusing after validation to happen
await page.waitForTimeout(1000);
// Allow default focusing after validation to happen
await page.waitForTimeout(1000);

// type
await card.typeCvc('737');
// type
await card.typeCvc('737');

// reset
await expect(card.cvcContextualElement).toBeVisible();
await expect(card.cvcContextualElement).toHaveText(CVC_CONTEXTUAL_TEXT_3_DIGITS);
// error element hidden
await expect(card.cvcErrorElement).not.toBeVisible();
// reset
await expect(card.cvcContextualElement).toBeVisible();
await expect(card.cvcContextualElement).toHaveText(CVC_CONTEXTUAL_TEXT_3_DIGITS);
// error element hidden
await expect(card.cvcErrorElement).not.toBeVisible();

await expect(card.cvcIframeContextualElement).toHaveText(CVC_CONTEXTUAL_TEXT_3_DIGITS);
});
await expect(card.cvcIframeContextualElement).toHaveText(CVC_CONTEXTUAL_TEXT_3_DIGITS);
});

test('#3 Should find no contextualElements because the config says to not show them', async ({ cardNoContextualElementPage }) => {
const { card, page } = cardNoContextualElementPage;
test('#3 Should find no contextualElements because the config says to not show them', async ({ cardNoContextualElementPage }) => {
const { card, page } = cardNoContextualElementPage;

await card.isComponentVisible();
await card.isComponentVisible();

// checkout contextual elements not present
await expect(card.expiryDateContextualElement).not.toBeVisible();
await expect(card.cvcContextualElement).not.toBeVisible();
// checkout contextual elements not present
await expect(card.expiryDateContextualElement).not.toBeVisible();
await expect(card.cvcContextualElement).not.toBeVisible();

// iframe contextual elements - present but without text
await expect(card.expiryDateIframeContextualElement).toHaveText('');
await expect(card.cvcIframeContextualElement).toHaveText('');
// iframe contextual elements - present but without text
await expect(card.expiryDateIframeContextualElement).toHaveText('');
await expect(card.cvcIframeContextualElement).toHaveText('');
});
});
Loading
Loading