Commit 19ad3fb0241 for woocommerce
commit 19ad3fb024157ba4e5b108db9bab38988dae9695
Author: Tung Du <dinhtungdu@gmail.com>
Date: Fri Sep 25 14:02:34 2026 +0700
Revert "[tests] Add Jest coverage for Catalog Sorting block registration" (#68661) (#69092)
Revert "[tests] Add Jest coverage for Catalog Sorting block registration (#68…"
This reverts commit 17a68fded493923eee2ad6c05cfb79af0234866d.
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/catalog-sorting/test/index.tsx b/plugins/woocommerce/client/blocks/assets/js/blocks/catalog-sorting/test/index.tsx
deleted file mode 100644
index 8a063b878b7..00000000000
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/catalog-sorting/test/index.tsx
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * External dependencies
- */
-import { render, screen } from '@testing-library/react';
-import { registerBlockType } from '@wordpress/blocks';
-import type { ReactNode } from 'react';
-
-/**
- * Internal dependencies
- */
-import metadata from '../block.json';
-import Edit from '../edit';
-
-jest.mock( '@wordpress/blocks', () => ( {
- registerBlockType: jest.fn(),
-} ) );
-
-jest.mock( '@wordpress/block-editor', () => ( {
- InspectorControls: ( { children }: { children: ReactNode } ) => (
- <div>{ children }</div>
- ),
- useBlockProps: ( props: Record< string, unknown > ) => props,
-} ) );
-
-jest.mock( '@wordpress/components', () => ( {
- Disabled: ( { children }: { children: ReactNode } ) => <>{ children }</>,
- ToggleControl: () => null,
- __experimentalToolsPanel: ( { children }: { children: ReactNode } ) => (
- <div>{ children }</div>
- ),
- __experimentalToolsPanelItem: ( { children }: { children: ReactNode } ) => (
- <div>{ children }</div>
- ),
-} ) );
-
-type RegisteredBlock = {
- attributes: typeof metadata.attributes;
- edit: unknown;
- save: () => null;
-};
-
-const loadRegisteredBlock = () => {
- let isolatedEdit: unknown;
-
- jest.isolateModules( () => {
- isolatedEdit = (
- jest.requireActual( '../edit' ) as {
- default: unknown;
- }
- ).default;
- jest.requireActual( '../index' );
- } );
-
- expect( registerBlockType ).toHaveBeenCalledTimes( 1 );
- const [ registeredMetadata, settings ] = ( registerBlockType as jest.Mock )
- .mock.calls[ 0 ];
-
- expect( registeredMetadata ).toEqual( metadata );
- expect( registeredMetadata.name ).toBe( 'woocommerce/catalog-sorting' );
- expect( settings.attributes ).toEqual( metadata.attributes );
-
- return {
- registeredMetadata,
- settings: settings as RegisteredBlock,
- isolatedEdit,
- };
-};
-
-describe( 'Catalog Sorting block registration', () => {
- beforeEach( () => {
- jest.clearAllMocks();
- } );
-
- it( 'registers the real editor component', () => {
- const { registeredMetadata, settings, isolatedEdit } =
- loadRegisteredBlock();
-
- expect( registeredMetadata ).toEqual( metadata );
- expect( registeredMetadata.name ).toBe( 'woocommerce/catalog-sorting' );
- expect( settings.attributes ).toEqual( metadata.attributes );
- expect( settings.edit ).toBe( isolatedEdit );
- } );
-
- it( 'registers a dynamic save callback that returns null', () => {
- const { settings } = loadRegisteredBlock();
-
- expect( settings.save() ).toBeNull();
- } );
-} );
-
-describe( 'Catalog Sorting editor placeholder', () => {
- it( 'renders the default sorting option without a visual label', () => {
- render(
- <Edit
- attributes={ { useLabel: false } }
- setAttributes={ jest.fn() }
- />
- );
-
- expect(
- screen.getByRole( 'option', { name: 'Default sorting' } )
- ).toBeInTheDocument();
- } );
-} );
diff --git a/plugins/woocommerce/client/blocks/changelog/testops-234-catalog-sorting b/plugins/woocommerce/client/blocks/changelog/testops-234-catalog-sorting
deleted file mode 100644
index 053d8e5a33c..00000000000
--- a/plugins/woocommerce/client/blocks/changelog/testops-234-catalog-sorting
+++ /dev/null
@@ -1,3 +0,0 @@
-Significance: patch
-Type: dev
-Comment: Add Jest coverage for the Catalog Sorting block's registration, dynamic save callback and editor placeholder. No E2E test is removed.