woocommerce/plugins/woocommerce-blocks/tests/e2e/specs/backend/product-results-count.test.js

62 lines
1.3 KiB
JavaScript
Raw Normal View History

[Blockifying Product Archive Templates] Add Results Count block (https://github.com/woocommerce/woocommerce-blocks/pull/8078) * Init setup to add a new block Results Count * Render template part as a content of ResultsCount block * Switch to template part rendering * Rename the block to ProductResultsCount * Fix typo in BlockTypesController * Change the ProductResultsCount class name * Remove Product Results Count block from Product Query template * Improve the way Product Results Count is rendered in the editor * Add prefix to places that missed renaming from ResultsCount to ProductResultsCount * Remove unnecessary frontend.tsx file for ProductResultsCount * Make sure global styles are applied and respected by Product Results Count block * Make sure the Product Results Count is available inly in Product Catalog template * Add basic tests to Product Results Count * Remove empty line in style file * Fix TS issue in Product Results Count * Fix typo * Override the enqueue_assets method to prevent unnecessary enqueue and 404 error on the frontend * Add necessary property to block's metadata * Address code review feedback * Update description Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Remove disabled component * Improve test description * Merge edit and block files * Remove align support * Remove background support * Simplify edit component * Improve readability with sprintf and add custom class * Simplify test case * Add styles and order placeholders Co-authored-by: Tung Du <dinhtungdu@gmail.com> * Fix markup to match with the frontend Co-authored-by: Tung Du <dinhtungdu@gmail.com> Co-authored-by: Alba Rincón <albarin@users.noreply.github.com> Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> Co-authored-by: Alba Rincón <alba.rincon@automattic.com> Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2023-01-17 15:19:42 +00:00
/**
* External dependencies
*/
import {
canvas,
createNewPost,
insertBlock,
switchUserToAdmin,
} from '@wordpress/e2e-test-utils';
import { searchForBlock } from '@wordpress/e2e-test-utils/build/inserter';
/**
* Internal dependencies
*/
import {
filterCurrentBlocks,
goToSiteEditor,
useTheme,
waitForCanvas,
} from '../../utils.js';
const block = {
name: 'Product Results Count',
slug: 'woocommerce/product-results-count',
class: '.wc-block-product-results-count',
};
describe( `${ block.name } Block`, () => {
it( 'in can not be inserted in a post', async () => {
await switchUserToAdmin();
await createNewPost( {
postType: 'post',
title: block.name,
} );
await searchForBlock( block.name );
expect( page ).toMatch( 'No results found.' );
} );
describe( 'in FSE editor', () => {
useTheme( 'emptytheme' );
beforeEach( async () => {
await goToSiteEditor();
await waitForCanvas();
} );
it( 'can be inserted in FSE area', async () => {
await insertBlock( block.name );
await expect( canvas() ).toMatchElement( block.class );
} );
it( 'can be inserted more than once', async () => {
await insertBlock( block.name );
await insertBlock( block.name );
const foo = await filterCurrentBlocks(
( b ) => b.name === block.slug
);
expect( foo ).toHaveLength( 2 );
} );
} );
} );