Commit da42f10cce8 for woocommerce
commit da42f10cce866e90856e514c1e0a64dad5faa9d4
Author: Ajitem Sahasrabuddhe <ajitem.s@outlook.com>
Date: Thu Sep 10 18:27:05 2026 +0530
Remove 16 duplicated Product Collection registration E2E tests (#68138)
* Remove duplicated preview-label tests from register-product-collection
* Add changelog entry for duplicated Product Collection test removal
* Fold the usesReference product-picker check into the top-level post test
The usesReference describe ran the same five collections through a second copy of the post test. Its product-picker assertions now live in the top-level test, driven by a shouldShowProductPicker flag on the collection array, and the describe is gone. The file lists 30 tests, down from 35.
* Update changelog entry for the folded usesReference test
diff --git a/plugins/woocommerce/changelog/testops-234-remove-duplicate-register-product-collection-tests b/plugins/woocommerce/changelog/testops-234-remove-duplicate-register-product-collection-tests
new file mode 100644
index 00000000000..7fb5d26b4dc
--- /dev/null
+++ b/plugins/woocommerce/changelog/testops-234-remove-duplicate-register-product-collection-tests
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+Comment: Remove 16 duplicated Product Collection registration E2E tests.
+
diff --git a/plugins/woocommerce/tests/e2e/tests/blocks/product-collection/register-product-collection.block_theme.spec.ts b/plugins/woocommerce/tests/e2e/tests/blocks/product-collection/register-product-collection.block_theme.spec.ts
index a24f6ee27fc..6b66e883608 100644
--- a/plugins/woocommerce/tests/e2e/tests/blocks/product-collection/register-product-collection.block_theme.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/blocks/product-collection/register-product-collection.block_theme.spec.ts
@@ -320,12 +320,14 @@ test.describe( 'Product Collection: Register Product Collection', () => {
name: 'My Custom Collection - Product Context',
label: 'Block: My Custom Collection - Product Context',
previewLabelTemplate: [ `${ BLOCK_THEME_SLUG }//single-product` ],
+ shouldShowProductPicker: true,
},
{
id: 'myCustomCollectionWithCartContext',
name: 'My Custom Collection - Cart Context',
label: 'Block: My Custom Collection - Cart Context',
previewLabelTemplate: [ `${ BLOCK_THEME_SLUG }//page-cart` ],
+ shouldShowProductPicker: false,
},
{
id: 'myCustomCollectionWithOrderContext',
@@ -334,6 +336,7 @@ test.describe( 'Product Collection: Register Product Collection', () => {
previewLabelTemplate: [
`${ BLOCK_THEME_SLUG }//order-confirmation`,
],
+ shouldShowProductPicker: false,
},
{
id: 'myCustomCollectionWithArchiveContext',
@@ -342,6 +345,7 @@ test.describe( 'Product Collection: Register Product Collection', () => {
previewLabelTemplate: [
`${ BLOCK_THEME_SLUG }//taxonomy-product_cat`,
],
+ shouldShowProductPicker: false,
},
{
id: 'myCustomCollectionMultipleContexts',
@@ -351,6 +355,7 @@ test.describe( 'Product Collection: Register Product Collection', () => {
`${ BLOCK_THEME_SLUG }//single-product`,
`${ BLOCK_THEME_SLUG }//order-confirmation`,
],
+ shouldShowProductPicker: true,
},
].forEach( ( collection ) => {
collection.previewLabelTemplate.forEach( ( template ) => {
@@ -388,11 +393,33 @@ test.describe( 'Product Collection: Register Product Collection', () => {
test( `Collection "${ collection.name }" should not show preview label in a post`, async ( {
pageObject,
editor,
+ admin,
} ) => {
- await pageObject.createNewPostAndInsertBlock(
+ await admin.createNewPost();
+ await pageObject.insertProductCollection();
+ await pageObject.chooseCollectionInPost(
collection.id as Collections
);
+ // Check visibility of product picker
+ const editorProductPicker = editor.canvas.locator(
+ SELECTORS.productPicker
+ );
+ const expectedVisibility = collection.shouldShowProductPicker
+ ? 'toBeVisible'
+ : 'toBeHidden';
+ await expect( editorProductPicker )[ expectedVisibility ]();
+
+ if ( collection.shouldShowProductPicker ) {
+ await pageObject.chooseProductInEditorProductPickerIfAvailable(
+ editor.canvas
+ );
+ }
+
+ // At this point, the product picker should be hidden
+ await expect( editorProductPicker ).toBeHidden();
+
+ // Check visibility of preview label
const previewButtonLocator = editor.canvas.getByTestId(
SELECTORS.previewButtonTestID
);
@@ -506,139 +533,6 @@ test.describe( 'Product Collection: Register Product Collection', () => {
await expect( deletedProductPicker ).toBeVisible();
} );
- test.describe( 'with "usesReference" argument', () => {
- [
- {
- id: 'myCustomCollectionWithProductContext',
- name: 'My Custom Collection - Product Context',
- label: 'Block: My Custom Collection - Product Context',
- previewLabelTemplate: [
- `${ BLOCK_THEME_SLUG }//single-product`,
- ],
- shouldShowProductPicker: true,
- },
- {
- id: 'myCustomCollectionWithCartContext',
- name: 'My Custom Collection - Cart Context',
- label: 'Block: My Custom Collection - Cart Context',
- previewLabelTemplate: [ `${ BLOCK_THEME_SLUG }//page-cart` ],
- shouldShowProductPicker: false,
- },
- {
- id: 'myCustomCollectionWithOrderContext',
- name: 'My Custom Collection - Order Context',
- label: 'Block: My Custom Collection - Order Context',
- previewLabelTemplate: [
- `${ BLOCK_THEME_SLUG }//order-confirmation`,
- ],
- shouldShowProductPicker: false,
- },
- {
- id: 'myCustomCollectionWithArchiveContext',
- name: 'My Custom Collection - Archive Context',
- label: 'Block: My Custom Collection - Archive Context',
- previewLabelTemplate: [
- `${ BLOCK_THEME_SLUG }//taxonomy-product_cat`,
- ],
- shouldShowProductPicker: false,
- },
- {
- id: 'myCustomCollectionMultipleContexts',
- name: 'My Custom Collection - Multiple Contexts',
- label: 'Block: My Custom Collection - Multiple Contexts',
- previewLabelTemplate: [
- `${ BLOCK_THEME_SLUG }//single-product`,
- `${ BLOCK_THEME_SLUG }//order-confirmation`,
- ],
- shouldShowProductPicker: true,
- },
- ].forEach( ( collection ) => {
- collection.previewLabelTemplate.forEach( ( template ) => {
- test( `Collection "${ collection.name }" should show preview label in "${ template }"`, async ( {
- admin,
- pageObject,
- editor,
- } ) => {
- if (
- template ===
- `${ BLOCK_THEME_SLUG }//taxonomy-product_cat`
- ) {
- await admin.visitSiteEditor( {
- postType: 'wp_template',
- } );
- await editor.createTemplate( {
- templateName: 'Products by Category',
- } );
- } else {
- await pageObject.goToEditorTemplate( template );
- }
- await pageObject.insertProductCollection();
- await pageObject.chooseCollectionInTemplate(
- collection.id as Collections
- );
-
- const previewButtonLocator = editor.canvas.getByTestId(
- SELECTORS.previewButtonTestID
- );
-
- await expect( previewButtonLocator ).toBeVisible();
- } );
- } );
-
- test( `Collection "${ collection.name }" should not show preview label in a post`, async ( {
- pageObject,
- editor,
- admin,
- } ) => {
- await admin.createNewPost();
- await pageObject.insertProductCollection();
- await pageObject.chooseCollectionInPost(
- collection.id as Collections
- );
-
- // Check visibility of product picker
- const editorProductPicker = editor.canvas.locator(
- SELECTORS.productPicker
- );
- const expectedVisibility = collection.shouldShowProductPicker
- ? 'toBeVisible'
- : 'toBeHidden';
- await expect( editorProductPicker )[ expectedVisibility ]();
-
- if ( collection.shouldShowProductPicker ) {
- await pageObject.chooseProductInEditorProductPickerIfAvailable(
- editor.canvas
- );
- }
-
- // At this point, the product picker should be hidden
- await expect( editorProductPicker ).toBeHidden();
-
- // Check visibility of preview label
- const previewButtonLocator = editor.canvas.getByTestId(
- SELECTORS.previewButtonTestID
- );
-
- await expect( previewButtonLocator ).toBeHidden();
- } );
-
- test( `Collection "${ collection.name }" should not show preview label in Product Catalog template`, async ( {
- pageObject,
- editor,
- } ) => {
- await pageObject.goToProductCatalogAndInsertCollection(
- collection.id as Collections
- );
-
- const previewButtonLocator = editor.canvas.getByTestId(
- SELECTORS.previewButtonTestID
- );
-
- await expect( previewButtonLocator ).toBeHidden();
- } );
- } );
- } );
-
test.describe( 'with "scope" argument', () => {
test( 'Collection with only `inserter` scope should not be displayed in Collection Chooser', async ( {
pageObject,