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

37 lines
875 B
JavaScript
Raw Normal View History

/**
* External dependencies
*/
import {
insertBlock,
getAllBlocks,
switchUserToAdmin,
} from '@wordpress/e2e-test-utils';
import { visitBlockPage } from '@woocommerce/blocks-test-utils';
const block = {
name: 'Cart',
slug: 'woocommerce/cart',
class: '.wc-block-cart',
};
if ( process.env.WP_VERSION < 5.3 || process.env.WOOCOMMERCE_BLOCKS_PHASE < 2 )
// 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 insertBlock( block.name );
expect( await getAllBlocks() ).toHaveLength( 1 );
} );
it( 'renders without crashing', async () => {
await expect( page ).toRenderBlock( block );
} );
} );