Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './standard-card-button-classic-checkout.data';
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* Internal dependencies
*/
import {
payments,
orders,
customers,
guests,
merchants,
ShopOrder,
} from '../../../../resources';

const customer = customers.mexico;
const guest = guests.mexico;

/**
* BCDC (Branded Card Debit/Credit) — classic checkout only.
* Block checkout is NOT supported).
*/
const merchant = merchants.mexico;

export const standardCardButtonClassicCheckout: ShopOrder[] = [
{
// https://inpsyde.atlassian.net/browse/PCP-1211
title: 'PCP-1211 | Transaction - Classic checkout - Standard Card Button - Default order @Critical',
...orders.default,
payment: payments.standardCardButton,
customer: guest,
merchant,
},
{
// https://inpsyde.atlassian.net/browse/PCP-2747
title: 'PCP-2747 | Transaction - Classic checkout - Standard Card Button - Order by customer',
...orders.default,
payment: payments.standardCardButton,
customer,
merchant,
},
];

export const standardCardButtonClassicCheckoutExcludingTax: ShopOrder[] = [
{
// https://inpsyde.atlassian.net/browse/PCP-1253
title: 'PCP-1253 | Transaction - Classic checkout - Standard Card Button - Order with price excluding tax',
...orders.excludingTax,
payment: payments.standardCardButton,
customer: guest,
merchant,
},
];

export const standardCardButtonClassicCheckoutIntentAuthorized: ShopOrder[] = [
{
// https://inpsyde.atlassian.net/browse/PCP-2759
title: 'PCP-2759 | Transaction - Classic checkout - Standard Card Button - Order with Intent Authorized',
...orders.default,
payment: {
...payments.standardCardButton,
isAuthorized: true,
},
orderStatus: 'on-hold',
customer: guest,
merchant,
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* Internal dependencies
*/
import { test } from '../../utils';
import {
merchants,
storeConfigMexico,
gateways,
taxSettings,
customers,
} from '../../resources';
import { transactionsOnClassicCheckout } from './_test-scenarios';
import {
standardCardButtonClassicCheckout,
standardCardButtonClassicCheckoutExcludingTax,
standardCardButtonClassicCheckoutIntentAuthorized,
} from './_test-data/standard-card-button';

/**
* Standard Card Button / BCDC
* BCDC is classic-checkout only — block checkout is not supported.
*/

const { payPal, standardCardButton } = gateways;

test.beforeAll( async ( { utils, pcpApi, wooCommerceApi } ) => {
await utils.configureStore( {
...storeConfigMexico,
enableClassicPages: true,
customer: customers.mexico,
} );
await utils.installAndActivatePcp();
await pcpApi.resetDb();
await pcpApi.connectMerchant(
merchants.mexico.client_id,
merchants.mexico.client_secret
);
await pcpApi.updatePcpPaymentMethods( {
[ payPal.id ]: { id: payPal.id, enabled: true },
[ standardCardButton.id ]: {
id: standardCardButton.id,
enabled: true,
},
} );
await wooCommerceApi.deleteAllOrders();
} );

for ( const testOrder of standardCardButtonClassicCheckout ) {
transactionsOnClassicCheckout( testOrder );
}

// Excluding Tax
test.describe( () => {
test.beforeAll( async ( { wooCommerceUtils } ) => {
await wooCommerceUtils.setTaxes( taxSettings.excluding );
} );

for ( const testOrder of standardCardButtonClassicCheckoutExcludingTax ) {
transactionsOnClassicCheckout( testOrder );
}

test.afterAll( async ( { wooCommerceUtils } ) => {
await wooCommerceUtils.setTaxes( taxSettings.including );
} );
} );

// Intent Authorized
test.describe( () => {
test.beforeAll( async ( { pcpApi } ) => {
await pcpApi.updatePcpSettings( { authorizeOnly: true } );
} );

for ( const testOrder of standardCardButtonClassicCheckoutIntentAuthorized ) {
transactionsOnClassicCheckout( testOrder );
}

test.afterAll( async ( { pcpApi } ) => {
await pcpApi.updatePcpSettings( { authorizeOnly: false } );
} );
} );
84 changes: 84 additions & 0 deletions tests/qa/utils/frontend/paypal-ui-classic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ export class PayPalUiClassic extends PayPalUi {
this.standardCardButtonDetailsIframe().locator(
'[id="billingAddress.city"]'
);
standardCardButtonCountryInput = () =>
this.standardCardButtonDetailsIframe().locator(
'[id="billingAddress.country"]'
);
standardCardButtonStateInput = () =>
this.standardCardButtonDetailsIframe().locator(
'[id="billingAddress.state"]'
Expand Down Expand Up @@ -546,6 +550,86 @@ export class PayPalUiClassic extends PayPalUi {
).toBeVisible();
await this.standardCardButtonCSCInput().fill( card.card_cvv );

// Latin America (Mexico) uses minimal mode: PayPal shows its own billing form inside the modal
// Fill those fields from the WC checkout form when they are visible.
const firstNameInput = this.standardCardButtonFirstNameInput();
Comment thread
mishautkin marked this conversation as resolved.
Outdated
if ( await firstNameInput.isVisible() ) {
const firstName = await this.page
Comment thread
mishautkin marked this conversation as resolved.
Outdated
.locator( '#billing_first_name' )
.inputValue();
const lastName = await this.page
.locator( '#billing_last_name' )
.inputValue();
const street = await this.page
.locator( '#billing_address_1' )
.inputValue();
const city = await this.page
.locator( '#billing_city' )
.inputValue();
const postcode = await this.page
.locator( '#billing_postcode' )
.inputValue();
const email = await this.page
.locator( '#billing_email' )
.inputValue();
const phone = await this.page
.locator( '#billing_phone' )
.inputValue()
.catch( () => '' );
const country = await this.page
.locator( '#billing_country' )
.inputValue()
.catch( () => '' );
const stateValue = await this.page
.locator( '#billing_state' )
.inputValue()
.catch( () => '' );

// Set country first — PayPal populates state options based on country.
const countryInput = this.standardCardButtonCountryInput();
// Wait for the billing address fields to fully load.
const stateInput = this.standardCardButtonStateInput();
await stateInput.waitFor( { state: 'visible', timeout: 30000 } );

if ( country ) {
await countryInput.selectOption( { value: country }, { force: true } );
}

await firstNameInput.fill( firstName );
await this.standardCardButtonLastNameInput().fill( lastName );
await this.standardCardButtonStreetInput().fill( street );
await this.standardCardButtonCityInput().fill( city );
await this.standardCardButtonZipCodeInput().fill( postcode );
if ( email ) {
await this.standardCardButtonEmailInput().fill( email );
}
if ( phone ) {
const phoneInput = this.standardCardButtonPhoneInput();
if ( await phoneInput.isVisible() ) {
await phoneInput.fill( phone );
}
}

const stateOptions = await stateInput.evaluate(
( el: HTMLSelectElement ) =>
el.tagName.toLowerCase() === 'select'
? Array.from( el.options )
.filter( ( o ) => o.value )
.map( ( o ) => ( { v: o.value, t: o.text } ) )
: []
);
const code = stateValue.trim();
if ( stateOptions.length > 0 ) {
const match =
stateOptions.find( ( o ) => o.v === code ) ||
stateOptions.find( ( o ) => o.t.toLowerCase().includes( code.toLowerCase() ) ) ||
stateOptions[ 0 ];
await stateInput.selectOption( { value: match.v }, { force: true } );
} else if ( code ) {
await stateInput.fill( code );
}
}

await expect(
this.standardCardButtonPayNowButton(),
'Assert standard card button pay now button is visible'
Expand Down
Loading