woocommerce/plugins/woocommerce-blocks/tests/e2e/specs/backend/mini-cart.test.js

38 lines
968 B
JavaScript

/**
* External dependencies
*/
import { switchUserToAdmin, getAllBlocks } from '@wordpress/e2e-test-utils';
import { visitBlockPage } from '@woocommerce/blocks-test-utils';
/**
* Internal dependencies
*/
import { insertBlockDontWaitForInsertClose } from '../../utils.js';
const block = {
name: 'Mini Cart',
slug: 'woocommerce/mini-cart',
class: '.wc-block-mini-cart',
};
if ( process.env.WOOCOMMERCE_BLOCKS_PHASE < 3 ) {
// eslint-disable-next-line jest/no-focused-tests
test.only( `skipping ${ block.name } tests`, () => {} );
}
describe( `${ block.name } Block`, () => {
beforeAll( async () => {
await switchUserToAdmin();
await visitBlockPage( `${ block.name } Block` );
} );
it( 'can only be inserted once', async () => {
await insertBlockDontWaitForInsertClose( block.name );
expect( await getAllBlocks() ).toHaveLength( 1 );
} );
it( 'renders without crashing', async () => {
await expect( page ).toRenderBlock( block );
} );
} );