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

56 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* External dependencies
*/
import {
insertBlock,
getAllBlocks,
switchUserToAdmin,
} from '@wordpress/e2e-test-utils';
import { visitBlockPage } from '@woocommerce/blocks-test-utils';
const block = {
name: 'Checkout',
slug: 'woocommerce/checkout',
class: '.wc-block-checkout',
};
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 () => {
// Gutenberg error
expect(
( await page.content() ).match(
/Your site doesnt include support for/gi
)
).toBeNull();
// Our ErrorBoundary
expect(
( await page.content() ).match(
/There was an error whilst rendering/gi
)
).toBeNull();
// Validation Error
expect(
( await page.content() ).match(
/This block contains unexpected or invalid content/gi
)
).toBeNull();
await expect( page ).toMatchElement( block.class );
} );
} );