diff --git a/modules/ppcp-card-fields/resources/js/Render.js b/modules/ppcp-card-fields/resources/js/Render.js index 8b46f17d7..a77874159 100644 --- a/modules/ppcp-card-fields/resources/js/Render.js +++ b/modules/ppcp-card-fields/resources/js/Render.js @@ -1,6 +1,13 @@ import { cardFieldStyles } from './CardFieldsHelper'; +let fieldsRendered = false; + export function renderFields( cardFields ) { + if ( fieldsRendered === true ) { + return; + } + fieldsRendered = true; + const nameField = document.getElementById( 'ppcp-credit-card-gateway-card-name' ); diff --git a/tests/Playwright/playwright.config.js b/tests/Playwright/playwright.config.js index 7273db2a0..402a04bb4 100644 --- a/tests/Playwright/playwright.config.js +++ b/tests/Playwright/playwright.config.js @@ -7,7 +7,7 @@ require( 'dotenv' ).config( { path: '.env' } ); * @see https://playwright.dev/docs/test-configuration */ module.exports = defineConfig( { - timeout: 60000, + timeout: 30000, testDir: './tests', /* Run tests in files in parallel */ fullyParallel: false, diff --git a/tests/Playwright/tests/free-trial-subscriptions.js b/tests/Playwright/tests/free-trial-subscriptions.js new file mode 100644 index 000000000..c4cc68baf --- /dev/null +++ b/tests/Playwright/tests/free-trial-subscriptions.js @@ -0,0 +1,22 @@ +const { test, expect } = require( '@playwright/test' ); +const { loginAsCustomer } = require( './utils/user' ); +const { openPaypalPopup, loginIntoPaypal } = require( './utils/paypal-popup' ); + +test( 'PayPal logged-in user free trial subscription without payment token', async ( { + page, +} ) => { + await loginAsCustomer( page ); + + await page.goto( '/product/free-trial' ); + await page.click( 'text=Sign up now' ); + await page.goto( '/classic-checkout' ); + + const popup = await openPaypalPopup( page ); + await loginIntoPaypal( popup ); + popup.locator( '#consentButton' ).click(); + + await page.click( 'text=Proceed to PayPal' ); + + const title = await page.locator( '.entry-title' ); + await expect( title ).toHaveText( 'Order received' ); +} ); diff --git a/tests/Playwright/tests/place-order.spec.js b/tests/Playwright/tests/place-order.spec.js index 086d8e9c7..d6d9a40cf 100644 --- a/tests/Playwright/tests/place-order.spec.js +++ b/tests/Playwright/tests/place-order.spec.js @@ -93,19 +93,20 @@ test.describe( 'Classic checkout', () => { await page.click( 'text=Credit Cards' ); - const creditCardNumber = page - .frameLocator( '#braintree-hosted-field-number' ) - .locator( '#credit-card-number' ); + const creditCardNumber = await page + .frameLocator( '[title="paypal_card_number_field"]' ) + .locator( '.card-field-number' ); await creditCardNumber.fill( CREDIT_CARD_NUMBER ); - const expirationDate = page - .frameLocator( '#braintree-hosted-field-expirationDate' ) - .locator( '#expiration' ); - await expirationDate.fill( CREDIT_CARD_EXPIRATION ); + const expirationDate = await page + .frameLocator( 'iframe[title="paypal_card_expiry_field"]' ) + .locator( 'input.card-field-expiry' ); + await expirationDate.click(); + await page.keyboard.type( CREDIT_CARD_EXPIRATION ); - const cvv = page - .frameLocator( '#braintree-hosted-field-cvv' ) - .locator( '#cvv' ); + const cvv = await page + .frameLocator( '[title="paypal_card_cvv_field"]' ) + .locator( '.card-field-cvv' ); await cvv.fill( CREDIT_CARD_CVV ); await Promise.all( [ diff --git a/tests/Playwright/tests/save-payment-methods.spec.js b/tests/Playwright/tests/save-payment-methods.spec.js index 092bd8ee4..077207141 100644 --- a/tests/Playwright/tests/save-payment-methods.spec.js +++ b/tests/Playwright/tests/save-payment-methods.spec.js @@ -82,22 +82,3 @@ test( 'ACDC add payment method', async ( { page } ) => { await page.waitForURL( '/my-account/payment-methods' ); } ); - -test( 'PayPal logged-in user free trial subscription without payment token', async ( { - page, -} ) => { - await loginAsCustomer( page ); - - await page.goto( '/product/free-trial' ); - await page.click( 'text=Sign up now' ); - await page.goto( '/classic-checkout' ); - - const popup = await openPaypalPopup( page ); - await loginIntoPaypal( popup ); - popup.locator( '#consentButton' ).click(); - - await page.click( 'text=Proceed to PayPal' ); - - const title = await page.locator( '.entry-title' ); - await expect( title ).toHaveText( 'Order received' ); -} );