-
Notifications
You must be signed in to change notification settings - Fork 4k
/
child-blocks.test.js
66 lines (60 loc) · 1.91 KB
/
child-blocks.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* WordPress dependencies
*/
import {
activatePlugin,
closeGlobalBlockInserter,
createNewPost,
deactivatePlugin,
getAllBlockInserterItemTitles,
insertBlock,
openGlobalBlockInserter,
} from '@wordpress/e2e-test-utils';
describe( 'Child Blocks', () => {
beforeAll( async () => {
await activatePlugin( 'gutenberg-test-child-blocks' );
} );
beforeEach( async () => {
await createNewPost();
} );
afterAll( async () => {
await deactivatePlugin( 'gutenberg-test-child-blocks' );
} );
it( 'are hidden from the global block inserter', async () => {
await openGlobalBlockInserter();
await expect( await getAllBlockInserterItemTitles() ).not.toContain(
'Child Blocks Child'
);
} );
it( 'shows up in a parent block', async () => {
await insertBlock( 'Child Blocks Unrestricted Parent' );
await closeGlobalBlockInserter();
await page.waitForSelector(
'[data-type="test/child-blocks-unrestricted-parent"] .block-editor-default-block-appender'
);
await page.click(
'[data-type="test/child-blocks-unrestricted-parent"] .block-editor-default-block-appender'
);
await openGlobalBlockInserter();
const inserterItemTitles = await getAllBlockInserterItemTitles();
expect( inserterItemTitles ).toContain( 'Child Blocks Child' );
expect( inserterItemTitles.length ).toBeGreaterThan( 20 );
} );
it( 'display in a parent block with allowedItems', async () => {
await insertBlock( 'Child Blocks Restricted Parent' );
await closeGlobalBlockInserter();
await page.waitForSelector(
'[data-type="test/child-blocks-restricted-parent"] .block-editor-default-block-appender'
);
await page.click(
'[data-type="test/child-blocks-restricted-parent"] .block-editor-default-block-appender'
);
await openGlobalBlockInserter();
const allowedBlocks = await getAllBlockInserterItemTitles();
expect( allowedBlocks.sort() ).toEqual( [
'Child Blocks Child',
'Image',
'Paragraph',
] );
} );
} );