Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 77e7f32

Browse files
authored
Add initial e2e tests to Mini Cart block (#4677)
1 parent 7e5485d commit 77e7f32

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"title":"Mini Cart Block","pageContent":"<!-- wp:woocommerce/mini-cart /-->"}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* External dependencies
3+
*/
4+
import { switchUserToAdmin, getAllBlocks } from '@wordpress/e2e-test-utils';
5+
import { visitBlockPage } from '@woocommerce/blocks-test-utils';
6+
7+
/**
8+
* Internal dependencies
9+
*/
10+
import { insertBlockDontWaitForInsertClose } from '../../utils.js';
11+
12+
const block = {
13+
name: 'Mini Cart',
14+
slug: 'woocommerce/mini-cart',
15+
class: '.wc-block-mini-cart',
16+
};
17+
18+
if ( process.env.WOOCOMMERCE_BLOCKS_PHASE < 3 ) {
19+
// eslint-disable-next-line jest/no-focused-tests
20+
test.only( `skipping ${ block.name } tests`, () => {} );
21+
}
22+
23+
describe( `${ block.name } Block`, () => {
24+
beforeAll( async () => {
25+
await switchUserToAdmin();
26+
await visitBlockPage( `${ block.name } Block` );
27+
} );
28+
29+
it( 'can only be inserted once', async () => {
30+
await insertBlockDontWaitForInsertClose( block.name );
31+
expect( await getAllBlocks() ).toHaveLength( 1 );
32+
} );
33+
34+
it( 'renders without crashing', async () => {
35+
await expect( page ).toRenderBlock( block );
36+
} );
37+
} );

0 commit comments

Comments
 (0)