2020-03-04 14:32:31 +00:00
|
|
|
|
/**
|
|
|
|
|
* External dependencies
|
|
|
|
|
*/
|
|
|
|
|
import {
|
|
|
|
|
insertBlock,
|
|
|
|
|
getAllBlocks,
|
|
|
|
|
switchUserToAdmin,
|
|
|
|
|
} from '@wordpress/e2e-test-utils';
|
|
|
|
|
|
2020-06-15 14:59:18 +00:00
|
|
|
|
import { visitBlockPage } from '@woocommerce/blocks-test-utils';
|
2020-03-04 14:32:31 +00:00
|
|
|
|
|
2020-06-15 14:59:18 +00:00
|
|
|
|
const block = {
|
|
|
|
|
name: 'Checkout',
|
|
|
|
|
slug: 'woocommerce/checkout',
|
|
|
|
|
class: '.wc-block-checkout',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
describe( `${ block.name } Block`, () => {
|
|
|
|
|
beforeAll( async () => {
|
|
|
|
|
await switchUserToAdmin();
|
|
|
|
|
await visitBlockPage( `${ block.name } Block` );
|
2020-03-04 14:32:31 +00:00
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
it( 'can only be inserted once', async () => {
|
2020-06-15 14:59:18 +00:00
|
|
|
|
await insertBlock( block.name );
|
2020-03-04 14:32:31 +00:00
|
|
|
|
expect( await getAllBlocks() ).toHaveLength( 1 );
|
2020-06-15 14:59:18 +00:00
|
|
|
|
} );
|
2020-03-04 14:32:31 +00:00
|
|
|
|
|
2020-06-15 14:59:18 +00:00
|
|
|
|
it( 'renders without crashing', async () => {
|
|
|
|
|
// Gutenberg error
|
|
|
|
|
expect(
|
|
|
|
|
( await page.content() ).match(
|
|
|
|
|
/Your site doesn’t 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 );
|
2020-03-04 14:32:31 +00:00
|
|
|
|
} );
|
|
|
|
|
} );
|