Commit e3c7dd11462 for woocommerce
commit e3c7dd114627c1de3e7dda4b5d21c1523c066fe3
Author: Daniel Mallory <daniel.mallory@automattic.com>
Date: Mon Oct 12 13:21:54 2026 +0100
Remove the shipping-zone workaround from a checkout e2e spec (#69591)
* test(e2e): Remove shipping-zone workaround from custom place order button spec
The spec deleted every zone-0 shipping method so the cart did not need
shipping. That hid the collapsed shipping address block whose hidden
required fields caused the bug, so the spec no longer covered it. The
fix in #65933 already checks only visible invalid fields, so the
workaround is not needed.
Also match only visible invalid fields in the validation test.
Refs WOOPLUG-7696
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(checkout): Tighten the custom place order button e2e checks
The invalid-form test passed even when client-side validation let the
form through, because the server's error response also marks empty
fields invalid. It now checks that no checkout request was sent.
The valid-form test only covers hidden shipping fields while the cart
needs shipping, which depends on site setup. It now asserts those fields
are on the page and hidden, so losing that setup fails the test.
Also restore trunk's invalid-field locator; the :visible filter didn't
change which row was matched.
Refs WOOPLUG-7696
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
diff --git a/plugins/woocommerce/changelog/wooplug-7696-remove-shipping-zone-workaround b/plugins/woocommerce/changelog/wooplug-7696-remove-shipping-zone-workaround
new file mode 100644
index 00000000000..1e17f544dc5
--- /dev/null
+++ b/plugins/woocommerce/changelog/wooplug-7696-remove-shipping-zone-workaround
@@ -0,0 +1,3 @@
+Significance: patch
+Type: dev
+Comment: Remove a stale shipping workaround from the shortcode checkout custom button e2e spec; no production change.
diff --git a/plugins/woocommerce/tests/e2e/tests/checkout/checkout-shortcode-custom-place-order-button.spec.ts b/plugins/woocommerce/tests/e2e/tests/checkout/checkout-shortcode-custom-place-order-button.spec.ts
index 48f2a000358..e5bd04ae32e 100644
--- a/plugins/woocommerce/tests/e2e/tests/checkout/checkout-shortcode-custom-place-order-button.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/checkout/checkout-shortcode-custom-place-order-button.spec.ts
@@ -70,39 +70,17 @@ const test = baseTest.extend( {
} );
test.describe( 'Shortcode Checkout Custom Place Order Button', () => {
- // The shared site setup attaches a free shipping method to zone 0, so every
- // cart needs shipping. On the shortcode checkout that renders the collapsed
- // "Ship to a different address?" block with hidden, empty required shipping
- // fields. A custom place-order button's client-side validate() counts those
- // hidden invalid fields and silently skips submission, so the order is never
- // placed. Remove the baseline shipping for this spec so the cart does not
- // need shipping, then restore it afterwards.
- // TODO: Remove this workaround once the validation fix is merged.
- // Bug fixed in https://github.com/woocommerce/woocommerce/pull/65933.
- test.beforeAll( async ( { restApi } ) => {
- const { data: methods } = await restApi.get<
- { instance_id: number }[]
- >( `${ WC_API_PATH }/shipping/zones/0/methods` );
-
- for ( const method of methods ) {
- await restApi.delete(
- `${ WC_API_PATH }/shipping/zones/0/methods/${ method.instance_id }`,
- { force: true }
- );
- }
- } );
-
- test.afterAll( async ( { restApi } ) => {
- // Restore the baseline free shipping method on zone 0 (mirrors site setup).
- await restApi.post( `${ WC_API_PATH }/shipping/zones/0/methods`, {
- method_id: 'free_shipping',
- } );
- } );
-
test(
'clicking custom button triggers validation when form is invalid',
{ tag: [ tags.PAYMENTS ] },
async ( { page, product } ) => {
+ const checkoutRequests: string[] = [];
+ page.on( 'request', ( request ) => {
+ if ( request.url().includes( 'wc-ajax=checkout' ) ) {
+ checkoutRequests.push( request.url() );
+ }
+ } );
+
await addAProductToCart( page, product.id, 1 );
await page.goto( CLASSIC_CHECKOUT_PAGE.slug );
@@ -124,6 +102,10 @@ test.describe( 'Shortcode Checkout Custom Place Order Button', () => {
// Ensuring we're still on checkout (order not submitted).
await expect( page ).not.toHaveURL( /order-received/ );
+
+ // The server also marks empty fields invalid, so check that client-side
+ // validation stopped the checkout request from being sent.
+ expect( checkoutRequests ).toHaveLength( 0 );
}
);
@@ -209,6 +191,12 @@ test.describe( 'Shortcode Checkout Custom Place Order Button', () => {
await addAProductToCart( page, product.id, 1 );
await page.goto( CLASSIC_CHECKOUT_PAGE.slug );
+ // The cart needs shipping, so the collapsed shipping fields render hidden
+ // and empty. The custom button must still submit with them on the page.
+ const shippingFirstName = page.locator( '#shipping_first_name' );
+ await expect( shippingFirstName ).toBeAttached();
+ await expect( shippingFirstName ).toBeHidden();
+
const customer = getFakeCustomer();
await page
.getByRole( 'textbox', { name: 'First name' } )