Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
35 changes: 18 additions & 17 deletions tests/qa/resources/pcp-gateways.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const payPal: Pcp.Gateway = {
id: 'ppcp-gateway',
description: '',
title: 'PayPal',
titleInModal: 'PayPal',
titleInPcpSettings: 'PayPal',
titleInWcSettings: 'PayPal',
hasSettingsButton: true,
Expand All @@ -27,6 +28,7 @@ const venmo: Pcp.Gateway = {
id: 'venmo',
description: '',
title: 'Venmo',
titleInModal: 'Venmo',
titleInPcpSettings: 'Venmo',
titleInWcSettings: 'Venmo',
hasSettingsButton: false,
Expand All @@ -41,6 +43,7 @@ const payLater: Pcp.Gateway = {
id: 'pay-later',
description: '',
title: 'PayPal Pay Later',
titleInModal: 'PayPal Pay Later',
titleInPcpSettings: 'Pay Later',
hasSettingsButton: false,
enabled: false,
Expand Down Expand Up @@ -95,6 +98,7 @@ const applepay: Pcp.Gateway = {
id: 'ppcp-applepay',
description: '',
title: 'Apple Pay',
titleInModal: 'Apple Pay',
titleInPcpSettings: 'Apple Pay',
titleInWcSettings: 'Apple Pay (via PayPal)',
hasSettingsButton: true,
Expand All @@ -110,6 +114,7 @@ const googlepay: Pcp.Gateway = {
id: 'ppcp-googlepay',
description: '',
title: 'Google Pay',
titleInModal: 'Google Pay',
titleInPcpSettings: 'Google Pay',
titleInWcSettings: ' (via PayPal)',
hasSettingsButton: true,
Expand All @@ -126,6 +131,7 @@ const bancontact: Pcp.Gateway = {
id: 'ppcp-bancontact',
description: '',
title: 'Bancontact',
titleInModal: 'Bancontact',
titleInPcpSettings: 'Bancontact',
titleInWcSettings: 'Bancontact (via PayPal)',
hasSettingsButton: true,
Expand All @@ -142,6 +148,7 @@ const blik: Pcp.Gateway = {
id: 'ppcp-blik',
description: '',
title: 'Blik',
titleInModal: 'Blik',
titleInPcpSettings: 'Blik',
titleInWcSettings: ' (via PayPal)',
hasSettingsButton: true,
Expand All @@ -158,6 +165,7 @@ const eps: Pcp.Gateway = {
id: 'ppcp-eps',
description: '',
title: 'EPS',
titleInModal: 'EPS',
titleInPcpSettings: 'EPS',
titleInWcSettings: 'EPS (via PayPal)',
hasSettingsButton: true,
Expand All @@ -174,6 +182,7 @@ const ideal: Pcp.Gateway = {
id: 'ppcp-ideal',
description: '',
title: 'iDeal',
titleInModal: 'iDeal',
titleInPcpSettings: 'iDeal',
titleInWcSettings: ' (via PayPal)',
hasSettingsButton: true,
Expand All @@ -189,6 +198,7 @@ const mybank: Pcp.Gateway = {
id: 'ppcp-mybank',
description: '',
title: 'MyBank',
titleInModal: 'MyBank',
titleInPcpSettings: 'MyBank',
titleInWcSettings: ' (via PayPal)',
hasSettingsButton: true,
Expand All @@ -204,6 +214,7 @@ const przelewy24: Pcp.Gateway = {
id: 'ppcp-p24',
description: '',
title: 'Przelewy24',
titleInModal: 'Przelewy24',
titleInPcpSettings: 'Przelewy24',
titleInWcSettings: ' (via PayPal)',
hasSettingsButton: true,
Expand All @@ -220,6 +231,7 @@ const trustly: Pcp.Gateway = {
id: 'ppcp-trustly',
description: '',
title: 'Trustly',
titleInModal: 'Trustly',
titleInPcpSettings: 'Trustly',
titleInWcSettings: 'Trustly (via PayPal)',
hasSettingsButton: true,
Expand All @@ -235,6 +247,7 @@ const multibanco: Pcp.Gateway = {
id: 'ppcp-multibanco',
description: '',
title: 'Multibanco',
titleInModal: 'Multibanco',
titleInPcpSettings: 'Multibanco',
titleInWcSettings: 'Multibanco (via PayPal)',
hasSettingsButton: true,
Expand All @@ -250,6 +263,7 @@ const oxxo: Pcp.Gateway = {
id: 'ppcp-oxxo-gateway',
description: '',
title: 'OXXO',
titleInModal: 'OXXO',
titleInPcpSettings: 'OXXO',
titleInWcSettings: 'OXXO (via PayPal)',
hasSettingsButton: true,
Expand All @@ -267,35 +281,23 @@ const payUponInvoice: Pcp.Gateway = {
id: 'ppcp-pay-upon-invoice-gateway',
description: '',
title: 'Pay upon Invoice',
titleInModal: 'Pay upon Invoice',
titleInPcpSettings: 'Pay upon Invoice',
titleInWcSettings: 'Pay upon Invoice',
hasSettingsButton: true,
// Disabled by default after a fresh connect; enabled only in country-specific test setups.
enabled: false,
};

const debitOrCreditCard: Pcp.Gateway = {
shortcut: 'card',
country: 'usa',
currency: 'USD',

id: 'ppcp-gateway',
description: '',
title: 'Credit or debit cards (via PayPal)',
titleInPcpSettings: 'Credit or debit cards',
titleInWcSettings: 'Credit or debit cards (via PayPal)',
hasSettingsButton: true,
enabled: true,
};

const standardCardButton: Pcp.Gateway = {
const bcdc: Pcp.Gateway = {
shortcut: 'card',
country: 'usa',
currency: 'USD',

id: 'ppcp-card-button-gateway',
description: '',
title: 'Debit & Credit Cards',
titleInModal: 'Debit & Credit Cards',
titleInPcpSettings: 'Debit & Credit Cards',
titleInWcSettings: 'Debit & Credit Cards',
hasSettingsButton: true,
Expand Down Expand Up @@ -323,6 +325,5 @@ export const gateways = {
multibanco,
oxxo,
payUponInvoice,
debitOrCreditCard,
Comment thread
mishautkin marked this conversation as resolved.
standardCardButton,
Comment thread
mishautkin marked this conversation as resolved.
bcdc,
};
12 changes: 3 additions & 9 deletions tests/qa/resources/pcp-payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,8 @@ const fastlaneRyan: Pcp.Payment = {
card: cards.visaFastlane,
};

const debitOrCreditCard: Pcp.Payment = {
gateway: gateways.debitOrCreditCard,
card: cards.visa,
};

const standardCardButton: Pcp.Payment = {
gateway: gateways.standardCardButton,
const bcdc: Pcp.Payment = {
gateway: gateways.bcdc,
card: cards.visa,
};

Expand All @@ -85,8 +80,7 @@ export const payments = {
acdc3ds,
fastlaneGary,
fastlaneRyan,
debitOrCreditCard,
standardCardButton,
bcdc,
payUponInvoice,
googlePay,
};
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ test.beforeAll( async ( { utils, pcpApi, wooCommerceApi } ) => {
[ acdc.id ]: { id: acdc.id, enabled: true },
[ googlepay.id ]: { id: googlepay.id, enabled: true },
} );
await wooCommerceApi.deleteAllOrders();
} );

for ( const order of googlePayCheckout ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ test.beforeAll( async ( { utils, pcpApi, wooCommerceApi } ) => {
[ acdc.id ]: { id: acdc.id, enabled: true },
[ fastlane.id ]: { id: fastlane.id, enabled: false },
} );
await wooCommerceApi.deleteAllOrders();
} );

for ( const testOrder of payPalClassicCheckout ) {
Expand Down
1 change: 0 additions & 1 deletion tests/qa/tests/05-transactions/transaction-usa.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ test.beforeAll( async ( { utils, pcpApi, wooCommerceApi } ) => {
[ acdc.id ]: { id: acdc.id, enabled: true },
[ fastlane.id ]: { id: fastlane.id, enabled: false },
} );
await wooCommerceApi.deleteAllOrders();
} );

for ( const testOrder of payPalCheckout ) {
Expand Down
38 changes: 28 additions & 10 deletions tests/qa/tests/06-refund/_test-scenarios/refund.scenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const testRefund = ( testData: ShopRefund ) => {
currency,
isApiOrder,
merchant,
products,
} = testData;

test(
Expand All @@ -32,12 +33,16 @@ export const testRefund = ( testData: ShopRefund ) => {
async ( {
wooCommerceUtils,
utils,
classicCheckout,
payForOrder,
orderReceived,
wooCommerceOrderEdit,
wooCommerceApi,
payPalApi,
} ) => {
test.setTimeout( 2 * 60_000 );
let order: WooCommerce.Order; // TODO: fix type in playwright-utils
let orderId: number;
const total = await countTotals( testData );
const refundAvailable = total.order;
const refundAmount = getAmountPercentage(
Expand All @@ -49,18 +54,31 @@ export const testRefund = ( testData: ShopRefund ) => {
await test.step( 'Precondition: create WooCommerce order', async () => {
if ( isApiOrder ) {
order = await wooCommerceUtils.createApiOrder( testData );
order = await utils.payForApiOrder(
order.id,
order.order_key,
testData
);
await payForOrder.visit( order.id, order.order_key );
await payForOrder.payPalUi.makePayment( { merchant, payment } );
} else {
order = await utils.completeOrderOnCheckout( testData );
await utils.fillVisitorsCart( products );
await classicCheckout.visit();
await classicCheckout.completeCheckoutDetails( testData );
await classicCheckout.payPalUi.makePayment( {merchant, payment } );
}
await expect(
order.status,
'Assert order status is processing'
).toEqual( 'processing' );

await orderReceived.page.waitForLoadState();
orderId = await orderReceived.getOrderNumber();
// Assert order status is processing (sometimes takes time to update after payment)
await expect
.poll(
async () => {
order = await wooCommerceApi.getOrder( orderId );
return order.status;
},
{
message: 'Assert order status is processing',
timeout: 30_000,
intervals: [ 1_000, 2_000, 3_000 ],
}
)
.toEqual( 'processing' );
} );

// Test
Expand Down
1 change: 0 additions & 1 deletion tests/qa/tests/06-refund/refund-usa.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ test.beforeAll( async ( { utils, pcpApi, wooCommerceApi } ) => {
[ payPal.id ]: { id: payPal.id, enabled: true },
[ acdc.id ]: { id: acdc.id, enabled: true },
} );
await wooCommerceApi.deleteAllOrders();
} );

for ( const testOrder of refundPayPalFromCheckout ) {
Expand Down
1 change: 0 additions & 1 deletion tests/qa/tests/07-vaulting/vaulting-checkout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ test.beforeAll( async ( { utils, pcpApi, wooCommerceApi } ) => {
savePaypalAndVenmo: true,
saveCardDetails: true,
} );
await wooCommerceApi.deleteAllOrders();
} );

for ( const testOrder of savePaymentMethodData ) {
Expand Down
1 change: 0 additions & 1 deletion tests/qa/tests/07-vaulting/vaulting-classic-cart.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ test.beforeAll( async ( { utils, pcpApi, wooCommerceApi } ) => {
savePaypalAndVenmo: true,
saveCardDetails: true,
} );
await wooCommerceApi.deleteAllOrders();
} );

for ( const testOrder of savePaymentMethodData ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ test.beforeAll( async ( { utils, pcpApi, wooCommerceApi } ) => {
savePaypalAndVenmo: true,
saveCardDetails: true,
} );
await wooCommerceApi.deleteAllOrders();
} );

for ( const testOrder of savePaymentMethodData ) {
Expand Down
1 change: 0 additions & 1 deletion tests/qa/tests/07-vaulting/vaulting-my-account.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ test.beforeAll( async ( { utils, pcpApi, wooCommerceApi } ) => {
savePaypalAndVenmo: true,
saveCardDetails: true,
} );
await wooCommerceApi.deleteAllOrders();
} );

const savePaymentMethodData = [
Expand Down
1 change: 0 additions & 1 deletion tests/qa/tests/07-vaulting/vaulting-pay-by-link.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ test.beforeAll( async ( { utils, pcpApi, wooCommerceApi } ) => {
savePaypalAndVenmo: true,
saveCardDetails: true,
} );
await wooCommerceApi.deleteAllOrders();
} );

for ( const testOrder of savePaymentMethodData ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ test.beforeAll( async ( { utils, pcpApi, wooCommerceApi } ) => {
products: [ 'physical', 'virtual', 'subscriptions' ],
}
);
await wooCommerceApi.deleteAllOrders();
} );

for ( const testOrder of vaultingGuest ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ test.beforeAll( async ( { utils, pcpApi, wooCommerceApi } ) => {
products: [ 'physical', 'virtual', 'subscriptions' ],
}
);
await wooCommerceApi.deleteAllOrders();
} );

for ( const testOrder of vaultingGuest ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ test.beforeAll( async ( { utils, pcpApi, wooCommerceApi } ) => {
products: [ 'physical', 'virtual', 'subscriptions' ],
}
);
await wooCommerceApi.deleteAllOrders();
} );

for ( const testOrder of vaultingRenewal ) {
Expand Down
6 changes: 6 additions & 0 deletions tests/qa/utils/admin/woocommerce-order-edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ export class WooCommerceOrderEdit extends WooCommerceOrderEditBase {
).toBeVisible();
}

// For example: Payment via PayPal
await expect(
this.paymentVia( orderData?.payment?.gateway?.titleInModal ),
`Assert payment via text is visible`
).toBeVisible();

// PayPal fees
if (
pcpData.payPalFee !== undefined &&
Expand Down
4 changes: 0 additions & 4 deletions tests/qa/utils/helpers/woocommerce.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,6 @@ export const setupWooCommerce = async () => {
await utils.restoreCustomer( customers[ country ] );
} );

setup( 'Setup Delete Previous Orders', async ( { wooCommerceApi } ) => {
await wooCommerceApi.deleteAllOrders();
} );

setup( 'Setup coupons', async ( { wooCommerceUtils } ) => {
// create test coupons
const couponItems = {};
Expand Down
Loading
Loading