Skip to content

Commit

Permalink
Merge branch 'trunk' into add/plugin-check
Browse files Browse the repository at this point in the history
  • Loading branch information
faisal-alvi authored Jan 17, 2025
2 parents 5d12297 + d29932b commit b4a681b
Show file tree
Hide file tree
Showing 24 changed files with 74 additions and 62 deletions.
5 changes: 5 additions & 0 deletions includes/Handlers/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,11 @@ public function set_synced_with_square( $product ) {
if ( is_string( $square_synced ) ) {
$errors = $this->check_product_sync_errors( $product );
if ( 'no' === $square_synced || empty( $errors ) ) {
if ( 'yes' === $square_synced && $product->is_type( 'variable' ) && wc_square()->get_settings_handler()->is_inventory_sync_enabled() ) {
// if syncing inventory with Square, parent variable products don't manage stock
$product->set_manage_stock( false );
}

Product::set_synced_with_square( $product, $square_synced );
} elseif ( ! empty( $errors ) ) {
foreach ( $errors as $error ) {
Expand Down
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"devDependencies": {
"@playwright/test": "^1.44.1",
"@woocommerce/dependency-extraction-webpack-plugin": "^3.0.1",
"@woocommerce/e2e-utils-playwright": "^0.2.1",
"@woocommerce/eslint-plugin": "^2.3.0",
"@wordpress/env": "^10.0.0",
"@wordpress/scripts": "^24.6.0",
Expand Down
8 changes: 7 additions & 1 deletion src/js/frontend/wc-square.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ jQuery( document ).ready( ( $ ) => {
false,
verificationResult
);
})
.catch(error => {
this.handle_errors([ error ]);
});
});
} else {
Expand Down Expand Up @@ -421,7 +424,10 @@ jQuery( document ).ready( ( $ ) => {
false,
verificationResult
);
});
})
.catch(error => {
this.handle_errors([ error ]);
});;
});
}

Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/specs/a6.transaction-authorize.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { chromium } from 'playwright';
import { test, expect } from '@playwright/test';
import { addOneOrMoreProductToCart } from '@woocommerce/e2e-utils-playwright';
import {
createProduct,
doesProductExist,
Expand Down Expand Up @@ -60,8 +61,7 @@ for ( const isBlock of isBlockCheckout ) {
test( title + 'Payment Gateway > Transaction Type > Authorization @general', async ( {
page,
} ) => {
await page.goto( '/product/simple-product' );
await page.locator( '.single_add_to_cart_button' ).click();
await addOneOrMoreProductToCart( page, 'simple-product' );

await visitCheckout( page, isBlock );
await fillAddressFields( page, isBlock );
Expand Down
7 changes: 3 additions & 4 deletions tests/e2e/specs/a7.transaction-authorize-virtual-only.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { chromium } from 'playwright';
import { test, expect } from '@playwright/test';
import { addOneOrMoreProductToCart } from '@woocommerce/e2e-utils-playwright';
import {
createProduct,
doesProductExist,
Expand Down Expand Up @@ -53,8 +54,7 @@ test.beforeAll( 'Setup', async ( { baseURL } ) => {
test( 'Payment Gateway > Transaction Type > Authorization + Virtual Only @general', async ( {
page,
} ) => {
await page.goto( '/product/virtual-product' );
await page.locator( '.single_add_to_cart_button' ).click();
await addOneOrMoreProductToCart( page, 'virtual-product' );

await visitCheckout( page, false );
await fillAddressFields( page, false );
Expand Down Expand Up @@ -93,8 +93,7 @@ test( 'Payment Gateway > Transaction Type > Authorization + Virtual Only but cha

await savePaymentGatewaySettings( page );

await page.goto( '/product/virtual-product' );
await page.locator( '.single_add_to_cart_button' ).click();
await addOneOrMoreProductToCart( page, 'virtual-product' );

await visitCheckout( page, false );
await fillAddressFields( page, false );
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/specs/a8.transaction-authorize-paid-order.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { chromium } from 'playwright';
import { test, expect } from '@playwright/test';
import { addOneOrMoreProductToCart } from '@woocommerce/e2e-utils-playwright';
import {
createProduct,
doesProductExist,
Expand Down Expand Up @@ -47,8 +48,7 @@ test.beforeAll( 'Setup', async ( { baseURL } ) => {
test( 'Payment Gateway > Transaction Type > Authorization + Capture Paid Orders @general', async ( {
page,
} ) => {
await page.goto( '/product/simple-product' );
await page.locator( '.single_add_to_cart_button' ).click();
await addOneOrMoreProductToCart( page, 'simple-product' );

await visitCheckout( page, false );
await fillAddressFields( page, false );
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/specs/a9.transaction-capture.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { chromium } from 'playwright';
import { test, expect } from '@playwright/test';
import { addOneOrMoreProductToCart } from '@woocommerce/e2e-utils-playwright';
import {
fillAddressFields,
fillCreditCardFields,
Expand Down Expand Up @@ -31,8 +32,7 @@ test.beforeAll( 'Setup', async ( { baseURL } ) => {
test( 'Payment Gateway > Transaction Type > Authorization @general', async ( {
page,
} ) => {
await page.goto( '/product/simple-product' );
await page.locator( '.single_add_to_cart_button' ).click();
await addOneOrMoreProductToCart( page, 'simple-product' );

await visitCheckout( page, false );
await fillAddressFields( page, false );
Expand Down
5 changes: 2 additions & 3 deletions tests/e2e/specs/a91.card-logos.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { test, expect } from '@playwright/test';
import { chromium } from 'playwright';
import { addOneOrMoreProductToCart } from '@woocommerce/e2e-utils-playwright';
import { savePaymentGatewaySettings } from '../utils/helper';


test( 'Payment Gateway - Accepted Card Logos @general', async ( { page } ) => {
await page.goto( '/product/simple-product' );
await page.locator( '.single_add_to_cart_button' ).click();
await addOneOrMoreProductToCart( page, 'simple-product' );
await page.goto( '/checkout-old' );

await expect(
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/specs/a92.currency-support.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { test, expect } from '@playwright/test';
import { chromium } from 'playwright';
import { addOneOrMoreProductToCart } from '@woocommerce/e2e-utils-playwright';

import {
visitCheckout,
Expand All @@ -26,8 +27,7 @@ test.beforeAll( 'Setup', async ( { baseURL } ) => {
test( 'Square credit card should available only for the supported currencies @general', async ( { page } ) => {
// Update currency to INR
await runWpCliCommand('wp option update woocommerce_currency "INR"');
await page.goto( '/product/simple-product' );
await page.locator( '.single_add_to_cart_button' ).click();
await addOneOrMoreProductToCart( page, 'simple-product' );
// Confirm that the Credit card is not visible on checkout page.
await visitCheckout(page, false);
await expect(
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/specs/a93.credit-card-form-fields.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { test, expect } from '@playwright/test';
import { chromium } from 'playwright';
import { addOneOrMoreProductToCart } from '@woocommerce/e2e-utils-playwright';

import {
visitCheckout,
Expand All @@ -23,8 +24,7 @@ test.beforeAll( 'Setup', async ( { baseURL } ) => {
} );

test( 'Verify square credit card form fields @general', async ( { page } ) => {
await page.goto( '/product/simple-product' );
await page.locator( '.single_add_to_cart_button' ).click();
await addOneOrMoreProductToCart( page, 'simple-product' );
// Confirm that the Credit card is not visible on checkout page.
await visitCheckout(page, true);

Expand Down
7 changes: 3 additions & 4 deletions tests/e2e/specs/b1.tokenization.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { test, expect } from '@playwright/test';
import { chromium } from 'playwright';
import { addOneOrMoreProductToCart } from '@woocommerce/e2e-utils-playwright';

import {
fillAddressFields,
Expand Down Expand Up @@ -45,8 +46,7 @@ for ( const isBlock of isBlockCheckout ) {

test( title + 'Payment Gateway - Customer Profiles @general', async ( { page } ) => {
await deleteAllPaymentMethods( page );
await page.goto( '/product/simple-product' );
await page.locator( '.single_add_to_cart_button' ).click();
await addOneOrMoreProductToCart( page, 'simple-product' );
await visitCheckout( page, isBlock );

await fillAddressFields( page, isBlock );
Expand Down Expand Up @@ -79,8 +79,7 @@ for ( const isBlock of isBlockCheckout ) {
} );

test( title + 'Checkout using saved card @general', async ( { page } ) => {
await page.goto( '/product/simple-product' );
await page.locator( '.single_add_to_cart_button' ).click();
await addOneOrMoreProductToCart( page, 'simple-product' );
await visitCheckout( page, isBlock );

if ( isBlock ) {
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/specs/b3.gift-card-full-payment.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { test, expect } from '@playwright/test';
import { chromium } from 'playwright';
import { addOneOrMoreProductToCart } from '@woocommerce/e2e-utils-playwright';

import {
createProduct,
Expand Down Expand Up @@ -40,8 +41,7 @@ test.beforeAll( 'Setup', async ( { baseURL } ) => {
let orderId;

test( 'Gift card - Full payment @giftcard', async ( { page } ) => {
await page.goto( '/product/dollar-product' );
await page.locator( '.single_add_to_cart_button' ).click();
await addOneOrMoreProductToCart( page, 'dollar-product' );

await page.goto( '/checkout-old' );
await fillAddressFields( page, false );
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/specs/b4.gift-card-partial-payment.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { test, expect } from '@playwright/test';
import { chromium } from 'playwright';
import { addOneOrMoreProductToCart } from '@woocommerce/e2e-utils-playwright';

import {
createProduct,
Expand Down Expand Up @@ -43,8 +44,7 @@ test.beforeAll( 'Setup', async ( { baseURL } ) => {
let orderId = 0;

test( 'Gift card - Partial payment @giftcard', async ( { page } ) => {
await page.goto( '/product/simple-product' );
await page.locator( '.single_add_to_cart_button' ).click();
await addOneOrMoreProductToCart( page, 'simple-product' );

await page.goto( '/checkout-old' );
await fillAddressFields( page, false );
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/specs/b5.gift-card-full-refund.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { test, expect } from '@playwright/test';
import { chromium } from 'playwright';
import { addOneOrMoreProductToCart } from '@woocommerce/e2e-utils-playwright';

import {
createProduct,
Expand Down Expand Up @@ -41,8 +42,7 @@ test.beforeAll( 'Setup', async ( { baseURL } ) => {

test( 'Full Refund Gift card order @giftcard', async ( { page } ) => {
page.on('dialog', dialog => dialog.accept());
await page.goto( '/product/dollar-product' );
await page.locator( '.single_add_to_cart_button' ).click();
await addOneOrMoreProductToCart( page, 'dollar-product' );

await page.goto( '/checkout-old' );
await fillAddressFields( page, false );
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/specs/b6.gift-card-partial-refund.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { test, expect } from '@playwright/test';
import { chromium } from 'playwright';
import { addOneOrMoreProductToCart } from '@woocommerce/e2e-utils-playwright';

import {
createProduct,
Expand Down Expand Up @@ -41,8 +42,7 @@ test.beforeAll( 'Setup', async ( { baseURL } ) => {

test( 'Partial Refund – Gift card order @giftcard', async ( { page } ) => {
page.on('dialog', dialog => dialog.accept());
await page.goto( '/product/dollar-product' );
await page.locator( '.single_add_to_cart_button' ).click();
await addOneOrMoreProductToCart( page, 'dollar-product' );

await page.goto( '/checkout-old' );
await fillAddressFields( page, false );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { test, expect } from '@playwright/test';
import { chromium } from 'playwright';
import { addOneOrMoreProductToCart } from '@woocommerce/e2e-utils-playwright';

import {
createProduct,
Expand Down Expand Up @@ -42,8 +43,7 @@ test.beforeAll( 'Setup', async ( { baseURL } ) => {

test( 'Gift card - Partial payment @giftcard', async ( { page } ) => {
page.on('dialog', dialog => dialog.accept());
await page.goto( '/product/simple-product' );
await page.locator( '.single_add_to_cart_button' ).click();
await addOneOrMoreProductToCart( page, 'simple-product' );

await page.goto( '/checkout-old' );
await fillAddressFields( page, false );
Expand Down
16 changes: 6 additions & 10 deletions tests/e2e/specs/d1.cash-app-pay.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect, devices, chromium } from '@playwright/test';
import { addOneOrMoreProductToCart } from '@woocommerce/e2e-utils-playwright';
import {
clearCart,
createProduct,
Expand Down Expand Up @@ -54,8 +55,7 @@ test.describe('Cash App Pay Tests @cashapp', () => {
enabled: false,
});

await page.goto('/product/simple-product');
await page.locator('.single_add_to_cart_button').click();
await addOneOrMoreProductToCart( page, 'simple-product' );

// Confirm that the Cash App Pay is not visible on checkout page.
await visitCheckout(page, false);
Expand Down Expand Up @@ -305,8 +305,7 @@ test.describe('Cash App Pay Tests @cashapp', () => {
...iPhone,
});
const page = await context.newPage();
await page.goto('/product/simple-product');
await page.locator('.single_add_to_cart_button').click();
await addOneOrMoreProductToCart( page, 'simple-product' );
await visitCheckout(page, isBlock);
await fillAddressFields(page, isBlock);
await selectPaymentMethod(page, 'square_cash_app_pay', isBlock);
Expand All @@ -332,8 +331,7 @@ test.describe('Cash App Pay Tests @cashapp', () => {
...iPhone,
});
const page = await context.newPage();
await page.goto('/product/simple-product');
await page.locator('.single_add_to_cart_button').click();
await addOneOrMoreProductToCart( page, 'simple-product' );
await expect(
page.getByRole('link', { name: 'View cart' }).first()
).toBeVisible();
Expand Down Expand Up @@ -366,9 +364,8 @@ test.describe('Cash App Pay Tests @cashapp', () => {
});
const page = await context.newPage();
await clearCart( page );
await page.goto('/product/simple-product');
page.on('dialog', dialog => dialog.accept());
await page.locator('.single_add_to_cart_button').click();
await addOneOrMoreProductToCart( page, 'simple-product' );
await visitCheckout(page, isBlock);
await fillAddressFields(page, isBlock);
await selectPaymentMethod(page, 'square_cash_app_pay', isBlock);
Expand All @@ -388,9 +385,8 @@ test.describe('Cash App Pay Tests @cashapp', () => {
...iPhone,
});
const page = await context.newPage();
await page.goto('/product/simple-product');
page.on('dialog', dialog => dialog.accept());
await page.locator('.single_add_to_cart_button').click();
await addOneOrMoreProductToCart( page, 'simple-product' );
await visitCheckout(page, isBlock);
await fillAddressFields(page, isBlock);
await selectPaymentMethod(page, 'square_cash_app_pay', isBlock);
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/specs/d2.cash-app-pay-inventory-sync.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,8 @@ test.describe('Cash App Pay Inventory Sync Tests', () => {
...iPhone,
});
const mobilePage = await context.newPage();
await mobilePage.goto('/product/sample-product-with-inventory/');
mobilePage.on('dialog', (dialog) => dialog.accept());
await mobilePage.locator('.single_add_to_cart_button').click();
await addOneOrMoreProductToCart( mobilePage, 'sample-product-with-inventory' );
await visitCheckout(mobilePage, isBlock);
await fillAddressFields(mobilePage, isBlock);
await selectPaymentMethod(mobilePage, 'square_cash_app_pay', isBlock);
Expand Down
Loading

0 comments on commit b4a681b

Please sign in to comment.