Commit 355952a951a for woocommerce
commit 355952a951a684406e20427f7bcdca8b5806bfcb
Author: Ján Mikláš <neosinner@gmail.com>
Date: Wed Nov 18 23:37:09 2026 +0100
Share provisioning for extension test stores (#71115)
* build: share extension test-store provisioner
* docs: log shared test-store provisioner
* test: clarify the test-store seed contract
diff --git a/packages/js/extension-tooling/README.md b/packages/js/extension-tooling/README.md
index 65f57bdb295..e59aaf5c5dd 100644
--- a/packages/js/extension-tooling/README.md
+++ b/packages/js/extension-tooling/README.md
@@ -124,6 +124,16 @@ Add this mapping alongside the extension's existing `wp-content/bin` mapping in
Use `wp-env run cli bash wp-content/woo-extension-tooling/seed-dev.sh wp-content/bin/seed_dev_plugin.sh` for `env:dev:seed`. Pass the fixture hook's path inside the container. Include WooCommerce Gateway Dummy in the development site's plugin list to use the seeded dummy payment method.
+### Provision a browser test store
+
+For suites that switch between shortcode and block checkout, add the same `./wp-content/woo-extension-tooling` mapping to the browser test site. After resetting the site, call the provisioner in place of `wp_env_config.sh`. Keep the extension-specific `wp_env_config_plugin.sh` as the next step.
+
+```sh
+pnpm run wp-env:e2e run cli bash wp-content/woo-extension-tooling/provision-e2e-store.sh
+```
+
+The site needs Storefront, WooCommerce, and the extension's `WC_Docker_Provision_Manager` test mu-plugin. The script configures the block pages, creates the shortcode pages, and calls the mu-plugin's `wp wc docker-e2e provision` importer once. A failed WP-CLI step stops provisioning. Pass `--metric-units` if the suite expects kilograms and centimeters, as Product Bundles does.
+
## Lint and analysis presets
If your Stylelint config already disables `selector-class-pattern` for legacy SCSS, extend the shared overlay after the WordPress preset. Keep any file-specific rules in your own config.
diff --git a/packages/js/extension-tooling/bin/provision-e2e-store.sh b/packages/js/extension-tooling/bin/provision-e2e-store.sh
new file mode 100644
index 00000000000..0532f601b92
--- /dev/null
+++ b/packages/js/extension-tooling/bin/provision-e2e-store.sh
@@ -0,0 +1,51 @@
+#!/usr/bin/env bash
+set -e
+
+if [[ $# -gt 1 || ( $# -eq 1 && "$1" != "--metric-units" ) ]]; then
+ echo 'Usage: bash provision-e2e-store.sh [--metric-units]' >&2
+ exit 1
+fi
+
+# The extension's test-only mu-plugin registers the product importer and checkout filters.
+wp eval 'if ( ! class_exists( "WC_Docker_Provision_Manager" ) ) { WP_CLI::error( "Load the extension’s E2E provisioning mu-plugin first." ); }'
+
+echo 'Setting up the WooCommerce test store…'
+
+wp rewrite structure '/%postname%/'
+wp rewrite flush
+wp core version --extra
+wp plugin list
+wp theme activate storefront
+wp theme list
+
+address='{"first_name":"John","last_name":"Doe","company":"Automattic","country":"US","address_1":"addr 1","address_2":"addr 2","city":"San Francisco","state":"CA","postcode":"94107","phone":"123456789"}'
+wp wc customer update 1 --user=1 --billing="$address" --shipping="$address"
+
+wp option update woocommerce_store_address '60 29th Street #343'
+wp option update woocommerce_store_city 'San Francisco'
+wp option update woocommerce_store_postcode 94110
+wp option update woocommerce_default_country 'US:CA'
+wp option update woocommerce_default_customer_address 'geolocation'
+wp option update woocommerce_currency 'USD'
+wp option update woocommerce_currency_pos 'left'
+wp option update woocommerce_onboarding_profile --format=json '{"skipped":true}'
+if [[ ${1:-} == --metric-units ]]; then
+ wp option update woocommerce_weight_unit 'kg'
+ wp option update woocommerce_dimension_unit 'cm'
+fi
+wp option update woocommerce_coming_soon 'no'
+
+block_cart_id=$(wp option get woocommerce_cart_page_id)
+block_checkout_id=$(wp option get woocommerce_checkout_page_id)
+wp post update "$block_cart_id" --post_title='Blocks cart' --post_name='blocks-cart'
+wp post update "$block_checkout_id" --post_title='Blocks checkout' --post_name='blocks-checkout'
+
+cart_id=$(wp post create --post_type=page --porcelain --post_status=publish --post_title='Cart' --post_name='cart' --post_content='[woocommerce_cart]')
+checkout_id=$(wp post create --post_type=page --porcelain --post_status=publish --post_title='Checkout' --post_name='checkout' --post_content='[woocommerce_checkout]')
+wp option set tests_legacy_woocommerce_cart_page_id "$cart_id"
+wp option set tests_legacy_woocommerce_checkout_page_id "$checkout_id"
+wp option set e2e_tests_mode 'legacy'
+
+wp wc docker-e2e provision
+wp action-scheduler run
+wp config set WP_DEBUG true --raw
diff --git a/packages/js/extension-tooling/changelog/shared-extension-test-store-provisioning b/packages/js/extension-tooling/changelog/shared-extension-test-store-provisioning
new file mode 100644
index 00000000000..dad5f5b6d44
--- /dev/null
+++ b/packages/js/extension-tooling/changelog/shared-extension-test-store-provisioning
@@ -0,0 +1,4 @@
+Significance: minor
+Type: add
+
+Share provisioning for extension test stores with classic and block checkout.
diff --git a/packages/js/extension-tooling/test/provision-e2e-store.test.js b/packages/js/extension-tooling/test/provision-e2e-store.test.js
new file mode 100644
index 00000000000..08905e83935
--- /dev/null
+++ b/packages/js/extension-tooling/test/provision-e2e-store.test.js
@@ -0,0 +1,127 @@
+const assert = require( 'node:assert/strict' );
+const { spawnSync } = require( 'node:child_process' );
+const fs = require( 'node:fs' );
+const os = require( 'node:os' );
+const path = require( 'node:path' );
+const { test } = require( 'node:test' );
+
+const script = path.join( __dirname, '../bin/provision-e2e-store.sh' );
+
+function run( context, args = [], fail = '' ) {
+ const directory = fs.mkdtempSync( path.join( os.tmpdir(), 'woo-store-' ) );
+ context.after( () =>
+ fs.rmSync( directory, { recursive: true, force: true } )
+ );
+ const log = path.join( directory, 'commands.log' );
+ fs.writeFileSync( log, '' );
+ fs.writeFileSync(
+ path.join( directory, 'wp' ),
+ `#!/usr/bin/env bash
+printf '%s\\n' "$*" >> "$WP_LOG"
+case "$*" in
+ "$WP_FAIL"*) [[ -z "$WP_FAIL" ]] || exit 4 ;;
+esac
+case "$*" in
+ 'option get woocommerce_cart_page_id') echo 20 ;;
+ 'option get woocommerce_checkout_page_id') echo 21 ;;
+ 'post create'*'--post_name=cart '*) echo 30 ;;
+ 'post create'*'--post_name=checkout '*) echo 31 ;;
+esac
+`,
+ { mode: 0o755 }
+ );
+ const result = spawnSync( 'bash', [ script, ...args ], {
+ cwd: directory,
+ env: {
+ ...process.env,
+ PATH: `${ directory }${ path.delimiter }${ process.env.PATH }`,
+ WP_LOG: log,
+ WP_FAIL: fail,
+ },
+ encoding: 'utf8',
+ } );
+ assert.ifError( result.error );
+ const commands = fs.readFileSync( log, 'utf8' ).trim().split( '\n' );
+ return { ...result, commands };
+}
+
+test( 'provisions the classic and block checkout pages before importing extension data', ( context ) => {
+ const result = run( context );
+ assert.equal( result.status, 0, result.stderr );
+ assert.ok(
+ result.commands.includes(
+ 'post update 20 --post_title=Blocks cart --post_name=blocks-cart'
+ )
+ );
+ assert.ok(
+ result.commands.includes(
+ 'post update 21 --post_title=Blocks checkout --post_name=blocks-checkout'
+ )
+ );
+ const shortcodePages = result.commands.filter( ( command ) =>
+ command.startsWith( 'post create ' )
+ );
+ assert.equal( shortcodePages.length, 2 );
+ assert.ok( shortcodePages[ 0 ].endsWith( '[woocommerce_cart]' ) );
+ assert.ok( shortcodePages[ 1 ].endsWith( '[woocommerce_checkout]' ) );
+ assert.deepEqual( result.commands.slice( -6 ), [
+ 'option set tests_legacy_woocommerce_cart_page_id 30',
+ 'option set tests_legacy_woocommerce_checkout_page_id 31',
+ 'option set e2e_tests_mode legacy',
+ 'wc docker-e2e provision',
+ 'action-scheduler run',
+ 'config set WP_DEBUG true --raw',
+ ] );
+ assert.ok(
+ ! result.commands.some( ( command ) =>
+ command.startsWith( 'option update woocommerce_weight_unit ' )
+ )
+ );
+ assert.ok(
+ ! result.commands.some( ( command ) =>
+ command.startsWith( 'option update woocommerce_dimension_unit ' )
+ )
+ );
+} );
+
+test( 'applies Product Bundles metric units when requested', ( context ) => {
+ const result = run( context, [ '--metric-units' ] );
+ assert.equal( result.status, 0, result.stderr );
+ const weight = 'option update woocommerce_weight_unit kg';
+ const index = result.commands.indexOf( weight );
+ assert.notEqual( index, -1 );
+ assert.equal(
+ result.commands[ index + 1 ],
+ 'option update woocommerce_dimension_unit cm'
+ );
+} );
+
+test( 'rejects invalid arguments before running WP-CLI', ( context ) => {
+ for ( const args of [
+ [ '--metric-unit' ],
+ [ '--metric-units', 'unexpected' ],
+ ] ) {
+ const result = run( context, args );
+ assert.equal( result.status, 1 );
+ assert.ok( result.stderr.startsWith( 'Usage:' ) );
+ assert.equal( result.commands.join( '' ), '' );
+ }
+} );
+
+test( 'stops before changing the site if the test provisioning plugin is absent', ( context ) => {
+ const result = run( context, [], 'eval' );
+ assert.equal( result.status, 4 );
+ assert.equal( result.commands.length, 1 );
+ assert.ok( result.commands[ 0 ].startsWith( 'eval ' ) );
+} );
+
+test( 'stops when WP-CLI fails to create the classic cart page', ( context ) => {
+ const result = run( context, [], 'post create' );
+ assert.equal( result.status, 4 );
+ assert.ok(
+ ! result.commands.some( ( command ) =>
+ command.startsWith( 'option set ' )
+ )
+ );
+ assert.ok( ! result.commands.includes( 'wc docker-e2e provision' ) );
+} );