Commit 59d74b61c82 for woocommerce
commit 59d74b61c823d1e2830e2ee54f99b75deca70342
Author: Adrian Moldovan <3854374+adimoldovan@users.noreply.github.com>
Date: Tue Oct 20 15:16:42 2026 +0200
Add test locks to 3 Blocks e2e specs and move them to parallel (#69435)
* Split Blocks e2e tests into blocks-parallel and blocks-serial projects
* Add changelog entry for Blocks e2e project split
* Reduce Blocks e2e serial shards from 10 to 7
* Use 8 shards for Blocks e2e serial jobs
* Document the parallel and serial e2e projects for core and Blocks
* Move 9 Blocks e2e specs to the parallel project
* Add changelog entry for moving Blocks e2e specs to parallel
* Wait for the add-to-cart response in Blocks e2e addToCart
* Gate Blocks e2e test plugins by cookie and move specs to parallel
* Add changelog entry for gating Blocks e2e test plugins
* Add test locks to 3 Blocks e2e specs and move them to parallel
Local pickup takes a lock and deletes its options after each test.
Product rating uses the e2e-filters cookie instead of global settings.
Inspector controls locks the taxonomy template tests, deletes the
templates in a fixture, and drops the unused experimental-blocks flag.
* Split Blocks e2e tests into blocks-parallel and blocks-serial projects
* Add changelog entry for Blocks e2e project split
* Reduce Blocks e2e serial shards from 10 to 7
* Use 8 shards for Blocks e2e serial jobs
* Document the parallel and serial e2e projects for core and Blocks
* Move 9 Blocks e2e specs to the parallel project
* Add changelog entry for moving Blocks e2e specs to parallel
* Wait for the add-to-cart response in Blocks e2e addToCart
* Gate Blocks e2e test plugins by cookie and move specs to parallel
* Add changelog entry for gating Blocks e2e test plugins
* Load workspace packages from source in Blocks e2e scripts
Blocks specs now import locks from the core e2e fixtures, which import
@woocommerce/e2e-utils-playwright. CI does not build that package, so
use the wc-source export condition, as the core e2e scripts do.
diff --git a/plugins/woocommerce/changelog/dev-testops-231-blocks-e2e-m2c-test-locks b/plugins/woocommerce/changelog/dev-testops-231-blocks-e2e-m2c-test-locks
new file mode 100644
index 00000000000..08f7fc8f78c
--- /dev/null
+++ b/plugins/woocommerce/changelog/dev-testops-231-blocks-e2e-m2c-test-locks
@@ -0,0 +1,3 @@
+Significance: patch
+Type: dev
+Comment: Add test locks and cleanup to 3 Blocks e2e specs and move them to the parallel project; no production change.
diff --git a/plugins/woocommerce/package.json b/plugins/woocommerce/package.json
index cef89fff8bf..1616e512aa4 100644
--- a/plugins/woocommerce/package.json
+++ b/plugins/woocommerce/package.json
@@ -78,8 +78,8 @@
"test:e2e:default": "pnpm test:e2e:install && pnpm test:e2e:with-env default",
"test:e2e:install": "pnpm playwright install chromium",
"test:e2e:blocks": "pnpm test:e2e:blocks:parallel && pnpm test:e2e:blocks:serial",
- "test:e2e:blocks:parallel": "node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON --test tests/e2e/utils/blocks/*.test.mjs && pnpm playwright test --config=tests/e2e/playwright.config.ts --project=blocks-parallel",
- "test:e2e:blocks:serial": "pnpm playwright test --config=tests/e2e/playwright.config.ts --project=blocks-serial",
+ "test:e2e:blocks:parallel": "node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON --test tests/e2e/utils/blocks/*.test.mjs && NODE_OPTIONS=\"$NODE_OPTIONS --conditions=wc-source\" pnpm playwright test --config=tests/e2e/playwright.config.ts --project=blocks-parallel",
+ "test:e2e:blocks:serial": "NODE_OPTIONS=\"$NODE_OPTIONS --conditions=wc-source\" pnpm playwright test --config=tests/e2e/playwright.config.ts --project=blocks-serial",
"test:e2e:blocks:unified-editor-assets:parallel": "pnpm wp-env:e2e run cli wp option update woocommerce_feature_block_editor_unified_assets_enabled yes && pnpm test:e2e:blocks:parallel",
"test:e2e:blocks:unified-editor-assets:serial": "pnpm wp-env:e2e run cli wp option update woocommerce_feature_block_editor_unified_assets_enabled yes && pnpm test:e2e:blocks:serial",
"test:e2e:blocks:performance": "pnpm playwright test --config=tests/e2e/playwright.performance.config.ts --project=blocks-performance",
diff --git a/plugins/woocommerce/tests/e2e/fixtures/fixtures.ts b/plugins/woocommerce/tests/e2e/fixtures/fixtures.ts
index c7860f1f736..2e943836bc6 100644
--- a/plugins/woocommerce/tests/e2e/fixtures/fixtures.ts
+++ b/plugins/woocommerce/tests/e2e/fixtures/fixtures.ts
@@ -119,7 +119,13 @@ export const locks = {
// sent emails or the Email settings page also take it, since the flags
// change both.
EMAIL_FEATURE_FLAGS: 'email-feature-flags',
+ // `woocommerce_pickup_location_settings` and `pickup_location_pickup_locations`.
+ LOCAL_PICKUP: 'local-pickup',
// The Back in Stock feature flag and `woocommerce_customer_stock_notifications_*`.
// Concurrent writes of the same value make `e2e-options/update` return 400.
STOCK_NOTIFICATIONS: 'stock-notifications',
+ // The `taxonomy-product_cat`, `taxonomy-product_tag` and
+ // `taxonomy-product_brand` templates. The Site Editor offers to add one only
+ // while it does not exist.
+ TAXONOMY_TEMPLATES: 'taxonomy-templates',
} as const;
diff --git a/plugins/woocommerce/tests/e2e/playwright.config.ts b/plugins/woocommerce/tests/e2e/playwright.config.ts
index c63707abccc..be4601da9c3 100644
--- a/plugins/woocommerce/tests/e2e/playwright.config.ts
+++ b/plugins/woocommerce/tests/e2e/playwright.config.ts
@@ -244,15 +244,12 @@ const blocksSerialSpecs = [
// Change global settings that cart, checkout and storefront specs read:
// shipping, taxes, local pickup, account creation, site language, the shop
- // page slug, product reviews and feature flags.
+ // page slug and feature flags.
'**/tests/blocks/cart/cart-checkout-block-shipping.block_theme.spec.ts',
'**/tests/blocks/cart/cart-checkout-block-taxes.shopper.block_theme.spec.ts',
'**/tests/blocks/cart/cart-checkout-block-translations.shopper.block_theme.spec.ts',
'**/tests/blocks/checkout/checkout-block.shopper.block_theme.spec.ts',
'**/tests/blocks/checkout/order-confirmation.block_theme.spec.ts',
- '**/tests/blocks/local-pickup/local-pickup.merchant.block_theme.spec.ts',
- '**/tests/blocks/product-collection/inspector-controls.block_theme.spec.ts',
- '**/tests/blocks/single-product-template/single-product-template.product-rating.spec.ts',
'**/tests/blocks/templates/shop-page.block_theme.spec.ts',
// Place orders, which change the Best Sellers ranking. Some also add to the
diff --git a/plugins/woocommerce/tests/e2e/tests/blocks/local-pickup/local-pickup.merchant.block_theme.spec.ts b/plugins/woocommerce/tests/e2e/tests/blocks/local-pickup/local-pickup.merchant.block_theme.spec.ts
index 2f1b1156879..df9b8cd0ab4 100644
--- a/plugins/woocommerce/tests/e2e/tests/blocks/local-pickup/local-pickup.merchant.block_theme.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/blocks/local-pickup/local-pickup.merchant.block_theme.spec.ts
@@ -1,181 +1,221 @@
/**
* External dependencies
*/
-import { test, expect } from '@woocommerce/e2e-utils';
-
-test.describe( 'Merchant → Local Pickup Settings', () => {
- test.beforeEach( async ( { localPickupUtils } ) => {
- await localPickupUtils.disableLocalPickupCosts();
- await localPickupUtils.enableLocalPickup();
- } );
-
- test( 'user can toggle the enabled state', async ( {
- page,
- localPickupUtils,
- } ) => {
- await expect( page.getByLabel( 'Enable local pickup' ) ).toBeChecked();
-
- await localPickupUtils.disableLocalPickup();
-
- await expect(
- page.getByLabel( 'Enable local pickup' )
- ).not.toBeChecked();
- } );
-
- test( 'user can change the title', async ( { page, localPickupUtils } ) => {
- await page.getByPlaceholder( 'Pickup' ).fill( 'Local Pickup Test #1' );
-
- await localPickupUtils.saveLocalPickupSettings();
-
- await expect( page.getByPlaceholder( 'Pickup' ) ).toHaveValue(
- 'Local Pickup Test #1'
- );
-
- await page.getByPlaceholder( 'Pickup' ).fill( 'Local Pickup Test #2' );
-
- await localPickupUtils.saveLocalPickupSettings();
-
- await expect( page.getByPlaceholder( 'Pickup' ) ).toHaveValue(
- 'Local Pickup Test #2'
- );
- } );
-
- test( 'user can toggle the price field state', async ( {
- page,
- localPickupUtils,
- } ) => {
- await localPickupUtils.enableLocalPickupCosts();
-
- await expect(
- page.getByLabel(
- 'Add a price for customers who choose local pickup'
- )
- ).toBeChecked();
-
- await localPickupUtils.disableLocalPickupCosts();
-
- await expect(
- page.getByLabel(
- 'Add a price for customers who choose local pickup'
- )
- ).not.toBeChecked();
- } );
-
- test( 'user can edit costs and tax status', async ( {
- page,
- localPickupUtils,
- } ) => {
- await localPickupUtils.enableLocalPickupCosts();
-
- await expect(
- page.getByLabel(
- 'Add a price for customers who choose local pickup'
- )
- ).toBeChecked();
-
- await page.getByPlaceholder( 'Free' ).fill( '20' );
- await page.getByLabel( 'Taxes' ).selectOption( 'none' );
-
- await localPickupUtils.saveLocalPickupSettings();
-
- await expect( page.getByPlaceholder( 'Free' ) ).toHaveValue( '20' );
- await expect( page.getByLabel( 'Taxes' ) ).toHaveValue( 'none' );
-
- await page.getByPlaceholder( 'Free' ).fill( '' );
- await page.getByLabel( 'Taxes' ).selectOption( 'taxable' );
-
- await localPickupUtils.saveLocalPickupSettings();
-
- await expect( page.getByPlaceholder( 'Free' ) ).toHaveValue( '' );
- await expect( page.getByLabel( 'Taxes' ) ).toHaveValue( 'taxable' );
- } );
-
- test( 'user can add a new location', async ( {
- page,
- localPickupUtils,
- } ) => {
- await localPickupUtils.addPickupLocation( {
- location: {
- name: 'Automattic, Inc.',
- address: '60 29th Street, Suite 343',
- city: 'San Francisco',
- postcode: '94110',
- state: 'US:CA',
- details: 'American entity',
- },
+import { test as base, expect } from '@woocommerce/e2e-utils';
+
+/**
+ * Internal dependencies
+ */
+import { locks } from '../../../fixtures/fixtures';
+
+const test = base.extend< { resetLocalPickup: void } >( {
+ resetLocalPickup: [
+ async ( { requestUtils }, use ) => {
+ await use();
+ for ( const optionName of [
+ 'woocommerce_pickup_location_settings',
+ 'pickup_location_pickup_locations',
+ ] ) {
+ await requestUtils.rest( {
+ method: 'POST',
+ path: 'e2e-options/delete',
+ data: { option_name: optionName },
+ } );
+ }
+ },
+ { auto: true },
+ ],
+} );
+
+test.describe(
+ 'Merchant → Local Pickup Settings',
+ { lock: locks.LOCAL_PICKUP },
+ () => {
+ test.beforeEach( async ( { localPickupUtils } ) => {
+ await localPickupUtils.disableLocalPickupCosts();
+ await localPickupUtils.enableLocalPickup();
} );
- await expect(
- page.getByRole( 'cell', {
- name: 'Automattic, Inc.60 29th Street, Suite 343, San Francisco, California, 94110, United States (US)',
- } )
- ).toBeVisible();
- } );
-
- test( 'user can edit a location', async ( { page, localPickupUtils } ) => {
- await localPickupUtils.addPickupLocation( {
- location: {
- name: 'Automattic, Inc.',
- address: '60 29th Street, Suite 343',
- city: 'San Francisco',
- postcode: '94110',
- state: 'US:CA',
- details: 'American entity',
- },
+ test( 'user can toggle the enabled state', async ( {
+ page,
+ localPickupUtils,
+ } ) => {
+ await expect(
+ page.getByLabel( 'Enable local pickup' )
+ ).toBeChecked();
+
+ await localPickupUtils.disableLocalPickup();
+
+ await expect(
+ page.getByLabel( 'Enable local pickup' )
+ ).not.toBeChecked();
} );
- await expect(
- page.getByRole( 'cell', {
- name: 'Automattic, Inc.60 29th Street, Suite 343, San Francisco, California, 94110, United States (US)',
- } )
- ).toBeVisible();
-
- await localPickupUtils.editPickupLocation( {
- location: {
- name: 'Ministry of Automattic Limited',
- address: '100 New Bridge Street',
- city: 'London',
- postcode: 'EC4V 6JA',
- state: 'GB',
- details: 'British entity',
- },
+ test( 'user can change the title', async ( {
+ page,
+ localPickupUtils,
+ } ) => {
+ await page
+ .getByPlaceholder( 'Pickup' )
+ .fill( 'Local Pickup Test #1' );
+
+ await localPickupUtils.saveLocalPickupSettings();
+
+ await expect( page.getByPlaceholder( 'Pickup' ) ).toHaveValue(
+ 'Local Pickup Test #1'
+ );
+
+ await page
+ .getByPlaceholder( 'Pickup' )
+ .fill( 'Local Pickup Test #2' );
+
+ await localPickupUtils.saveLocalPickupSettings();
+
+ await expect( page.getByPlaceholder( 'Pickup' ) ).toHaveValue(
+ 'Local Pickup Test #2'
+ );
} );
- await expect(
- page.getByRole( 'cell', {
- name: 'Ministry of Automattic Limited100 New Bridge Street, London, EC4V 6JA, United Kingdom (UK)',
- } )
- ).toBeVisible();
- } );
-
- test( 'user can delete a location', async ( {
- page,
- localPickupUtils,
- } ) => {
- await localPickupUtils.addPickupLocation( {
- location: {
- name: 'Ausomattic Pty Ltd',
- address:
- 'c/o Baker And Mckenzie Level 19 Cbw, 181 William Street',
- city: 'Melbourne',
- postcode: '300',
- state: 'AU:VIC',
- details: 'Australian entity',
- },
+ test( 'user can toggle the price field state', async ( {
+ page,
+ localPickupUtils,
+ } ) => {
+ await localPickupUtils.enableLocalPickupCosts();
+
+ await expect(
+ page.getByLabel(
+ 'Add a price for customers who choose local pickup'
+ )
+ ).toBeChecked();
+
+ await localPickupUtils.disableLocalPickupCosts();
+
+ await expect(
+ page.getByLabel(
+ 'Add a price for customers who choose local pickup'
+ )
+ ).not.toBeChecked();
} );
- await expect(
- page.getByRole( 'cell', {
- name: 'Ausomattic Pty Ltdc/o Baker And Mckenzie Level 19 Cbw, 181 William Street, Melbourne, Victoria, 300, Australia',
- } )
- ).toBeVisible();
+ test( 'user can edit costs and tax status', async ( {
+ page,
+ localPickupUtils,
+ } ) => {
+ await localPickupUtils.enableLocalPickupCosts();
- await localPickupUtils.deletePickupLocation();
+ await expect(
+ page.getByLabel(
+ 'Add a price for customers who choose local pickup'
+ )
+ ).toBeChecked();
- await expect(
- page.getByRole( 'cell', {
- name: 'When you add a pickup location, it will appear here.',
- } )
- ).toBeVisible();
- } );
-} );
+ await page.getByPlaceholder( 'Free' ).fill( '20' );
+ await page.getByLabel( 'Taxes' ).selectOption( 'none' );
+
+ await localPickupUtils.saveLocalPickupSettings();
+
+ await expect( page.getByPlaceholder( 'Free' ) ).toHaveValue( '20' );
+ await expect( page.getByLabel( 'Taxes' ) ).toHaveValue( 'none' );
+
+ await page.getByPlaceholder( 'Free' ).fill( '' );
+ await page.getByLabel( 'Taxes' ).selectOption( 'taxable' );
+
+ await localPickupUtils.saveLocalPickupSettings();
+
+ await expect( page.getByPlaceholder( 'Free' ) ).toHaveValue( '' );
+ await expect( page.getByLabel( 'Taxes' ) ).toHaveValue( 'taxable' );
+ } );
+
+ test( 'user can add a new location', async ( {
+ page,
+ localPickupUtils,
+ } ) => {
+ await localPickupUtils.addPickupLocation( {
+ location: {
+ name: 'Automattic, Inc.',
+ address: '60 29th Street, Suite 343',
+ city: 'San Francisco',
+ postcode: '94110',
+ state: 'US:CA',
+ details: 'American entity',
+ },
+ } );
+
+ await expect(
+ page.getByRole( 'cell', {
+ name: 'Automattic, Inc.60 29th Street, Suite 343, San Francisco, California, 94110, United States (US)',
+ } )
+ ).toBeVisible();
+ } );
+
+ test( 'user can edit a location', async ( {
+ page,
+ localPickupUtils,
+ } ) => {
+ await localPickupUtils.addPickupLocation( {
+ location: {
+ name: 'Automattic, Inc.',
+ address: '60 29th Street, Suite 343',
+ city: 'San Francisco',
+ postcode: '94110',
+ state: 'US:CA',
+ details: 'American entity',
+ },
+ } );
+
+ await expect(
+ page.getByRole( 'cell', {
+ name: 'Automattic, Inc.60 29th Street, Suite 343, San Francisco, California, 94110, United States (US)',
+ } )
+ ).toBeVisible();
+
+ await localPickupUtils.editPickupLocation( {
+ location: {
+ name: 'Ministry of Automattic Limited',
+ address: '100 New Bridge Street',
+ city: 'London',
+ postcode: 'EC4V 6JA',
+ state: 'GB',
+ details: 'British entity',
+ },
+ } );
+
+ await expect(
+ page.getByRole( 'cell', {
+ name: 'Ministry of Automattic Limited100 New Bridge Street, London, EC4V 6JA, United Kingdom (UK)',
+ } )
+ ).toBeVisible();
+ } );
+
+ test( 'user can delete a location', async ( {
+ page,
+ localPickupUtils,
+ } ) => {
+ await localPickupUtils.addPickupLocation( {
+ location: {
+ name: 'Ausomattic Pty Ltd',
+ address:
+ 'c/o Baker And Mckenzie Level 19 Cbw, 181 William Street',
+ city: 'Melbourne',
+ postcode: '300',
+ state: 'AU:VIC',
+ details: 'Australian entity',
+ },
+ } );
+
+ await expect(
+ page.getByRole( 'cell', {
+ name: 'Ausomattic Pty Ltdc/o Baker And Mckenzie Level 19 Cbw, 181 William Street, Melbourne, Victoria, 300, Australia',
+ } )
+ ).toBeVisible();
+
+ await localPickupUtils.deletePickupLocation();
+
+ await expect(
+ page.getByRole( 'cell', {
+ name: 'When you add a pickup location, it will appear here.',
+ } )
+ ).toBeVisible();
+ } );
+ }
+);
diff --git a/plugins/woocommerce/tests/e2e/tests/blocks/product-collection/inspector-controls.block_theme.spec.ts b/plugins/woocommerce/tests/e2e/tests/blocks/product-collection/inspector-controls.block_theme.spec.ts
index 824642a0666..78daa5efbf3 100644
--- a/plugins/woocommerce/tests/e2e/tests/blocks/product-collection/inspector-controls.block_theme.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/blocks/product-collection/inspector-controls.block_theme.spec.ts
@@ -8,8 +8,29 @@ import { test as base, expect, BLOCK_THEME_SLUG } from '@woocommerce/e2e-utils';
*/
import ProductCollectionPage, { SELECTORS } from './product-collection.page';
import { getProductCollectionQuery } from '../products/utils';
+import { locks } from '../../../fixtures/fixtures';
-const test = base.extend< { pageObject: ProductCollectionPage } >( {
+const TAXONOMY_TEMPLATES = [
+ {
+ slug: `${ BLOCK_THEME_SLUG }//taxonomy-product_cat`,
+ title: 'Products by Category',
+ },
+ {
+ slug: `${ BLOCK_THEME_SLUG }//taxonomy-product_tag`,
+ title: 'Products by Tag',
+ },
+ {
+ slug: `${ BLOCK_THEME_SLUG }//taxonomy-product_brand`,
+ title: 'Products by Brand',
+ },
+];
+
+const test = base.extend< {
+ pageObject: ProductCollectionPage;
+ createTaxonomyTemplate: (
+ template: ( typeof TAXONOMY_TEMPLATES )[ number ]
+ ) => Promise< void >;
+} >( {
pageObject: async ( { page, admin, editor }, use ) => {
const pageObject = new ProductCollectionPage( {
page,
@@ -18,6 +39,31 @@ const test = base.extend< { pageObject: ProductCollectionPage } >( {
} );
await use( pageObject );
},
+ createTaxonomyTemplate: async ( { admin, editor, requestUtils }, use ) => {
+ const deleteTemplate = ( slug: string ) =>
+ requestUtils
+ .rest( {
+ method: 'DELETE',
+ path: `/wp/v2/templates/${ slug }`,
+ params: { force: true },
+ } )
+ .catch( ( error ) => {
+ if ( error?.code !== 'rest_template_not_found' ) {
+ throw error;
+ }
+ } );
+ let createdSlug: string | undefined;
+ await use( async ( { slug, title } ) => {
+ // A stopped run can leave the template, and then the Site Editor does not offer it.
+ await deleteTemplate( slug );
+ createdSlug = slug;
+ await admin.visitSiteEditor( { postType: 'wp_template' } );
+ await editor.createTemplate( { templateName: title } );
+ } );
+ if ( createdSlug ) {
+ await deleteTemplate( createdSlug );
+ }
+ },
} );
test.describe( 'Product Collection: Inspector Controls', () => {
@@ -444,42 +490,26 @@ test.describe( 'Product Collection: Inspector Controls', () => {
} );
} );
- [
- {
- slug: `${ BLOCK_THEME_SLUG }//taxonomy-product_cat`,
- title: 'Products by Category',
- },
- {
- slug: `${ BLOCK_THEME_SLUG }//taxonomy-product_tag`,
- title: 'Products by Tag',
- },
- {
- slug: `${ BLOCK_THEME_SLUG }//taxonomy-product_brand`,
- title: 'Products by Brand',
- },
- ].forEach( ( template ) => {
- test( `should be visible in archive template: ${ template.slug }`, async ( {
- admin,
- pageObject,
- editor,
- } ) => {
- await admin.visitSiteEditor( {
- postType: 'wp_template',
- } );
- await editor.createTemplate( {
- templateName: template.title,
- } );
- await pageObject.insertProductCollection();
- await pageObject.chooseCollectionInTemplate();
- await pageObject.focusProductCollection();
- await editor.openDocumentSettingsSidebar();
-
- await expect(
- pageObject
- .locateSidebarSettings()
- .getByLabel( SELECTORS.usePageContextControl )
- ).toBeVisible();
- } );
+ TAXONOMY_TEMPLATES.forEach( ( template ) => {
+ test(
+ `should be visible in archive template: ${ template.slug }`,
+ {
+ lock: locks.TAXONOMY_TEMPLATES,
+ },
+ async ( { pageObject, editor, createTaxonomyTemplate } ) => {
+ await createTaxonomyTemplate( template );
+ await pageObject.insertProductCollection();
+ await pageObject.chooseCollectionInTemplate();
+ await pageObject.focusProductCollection();
+ await editor.openDocumentSettingsSidebar();
+
+ await expect(
+ pageObject
+ .locateSidebarSettings()
+ .getByLabel( SELECTORS.usePageContextControl )
+ ).toBeVisible();
+ }
+ );
} );
[
@@ -609,9 +639,7 @@ test.describe( 'Product Collection: Inspector Controls', () => {
pageObject,
editor,
page,
- requestUtils,
} ) => {
- await requestUtils.setFeatureFlag( 'experimental-blocks', true );
await pageObject.createNewPostAndInsertBlock();
await expect( pageObject.products ).toHaveCount( 9 );
@@ -667,10 +695,7 @@ test.describe( 'Product Collection: Inspector Controls', () => {
pageObject,
editor,
page,
- requestUtils,
} ) => {
- await requestUtils.setFeatureFlag( 'experimental-blocks', true );
-
await pageObject.createNewPostAndInsertBlock();
await expect( pageObject.products ).toHaveCount( 9 );
diff --git a/plugins/woocommerce/tests/e2e/tests/blocks/single-product-template/single-product-template.product-rating.spec.ts b/plugins/woocommerce/tests/e2e/tests/blocks/single-product-template/single-product-template.product-rating.spec.ts
index 80e7c90ed83..58d5f0d0af8 100644
--- a/plugins/woocommerce/tests/e2e/tests/blocks/single-product-template/single-product-template.product-rating.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/blocks/single-product-template/single-product-template.product-rating.spec.ts
@@ -1,7 +1,12 @@
/**
* External dependencies
*/
-import { test, expect, getPostIdBySlug, wpCLI } from '@woocommerce/e2e-utils';
+import { test, expect } from '@woocommerce/e2e-utils';
+
+/**
+ * Internal dependencies
+ */
+import { setFilterValue } from '../../../utils/filters';
const blockData = {
slug: 'woocommerce/single-product',
@@ -9,15 +14,23 @@ const blockData = {
};
test.describe( `${ blockData.slug } Block`, () => {
+ test.beforeEach( async ( { page } ) => {
+ await page.goto( `/product/${ blockData.productSlug }/` );
+
+ await expect(
+ page.locator( '.wc-block-components-product-rating' )
+ ).toBeVisible();
+ } );
+
test( 'Product Rating block is not visible if ratings are disabled for product', async ( {
page,
} ) => {
- await test.step( `Disable reviews for ${ blockData.productSlug }`, async () => {
- const productId = await getPostIdBySlug( blockData.productSlug );
- await wpCLI( `post update ${ productId } --comment_status=closed` );
- } );
-
- await page.goto( `/product/${ blockData.productSlug }/` );
+ await setFilterValue(
+ page,
+ 'woocommerce_product_get_reviews_allowed',
+ false
+ );
+ await page.reload();
await expect(
page.locator( '.wc-block-components-product-rating' )
@@ -25,22 +38,14 @@ test.describe( `${ blockData.slug } Block`, () => {
} );
test( 'Product Rating block is not visible if ratings are disabled globally in the store', async ( {
- admin,
page,
} ) => {
- await test.step( `Disable reviews in the store`, async () => {
- await page.goto(
- '/wp-admin/admin.php?page=wc-settings&tab=products'
- );
- await admin.page
- .getByRole( 'checkbox', {
- name: 'Enable product reviews',
- } )
- .uncheck();
- await page.getByRole( 'button', { name: 'Save changes' } ).click();
- } );
-
- await page.goto( `/product/${ blockData.productSlug }/` );
+ await setFilterValue(
+ page,
+ 'pre_option_woocommerce_enable_reviews',
+ 'no'
+ );
+ await page.reload();
await expect(
page.locator( '.wc-block-components-product-rating' )