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`, () => {
|
2023-02-21 13:04:35 +00:00
|
|
|
it( 'can not be inserted in a post', async () => {
|
2023-01-17 15:19:42 +00:00
|
|
|
await switchUserToAdmin();
|
|
|
|
await createNewPost( {
|
|
|
|
postType: 'post',
|
|
|
|
title: block.name,
|
|
|
|
} );
|
|
|
|
await searchForBlock( block.name );
|
|
|
|
expect( page ).toMatch( 'No results found.' );
|
|
|
|
} );
|
|
|
|
|
2023-11-20 12:06:12 +00:00
|
|
|
describe.skip( 'in FSE editor', () => {
|
2023-01-17 15:19:42 +00:00
|
|
|
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 );
|
2023-02-21 13:04:35 +00:00
|
|
|
const filteredBlocks = await filterCurrentBlocks(
|
2023-01-17 15:19:42 +00:00
|
|
|
( b ) => b.name === block.slug
|
|
|
|
);
|
2023-02-21 13:04:35 +00:00
|
|
|
expect( filteredBlocks ).toHaveLength( 2 );
|
2023-01-17 15:19:42 +00:00
|
|
|
} );
|
|
|
|
} );
|
|
|
|
} );
|