-
Notifications
You must be signed in to change notification settings - Fork 4k
/
block-switcher.spec.js
60 lines (58 loc) · 1.41 KB
/
block-switcher.spec.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
/**
* WordPress dependencies
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );
test.describe( 'Block Switcher', () => {
test.beforeEach( async ( { admin } ) => {
await admin.createNewPost();
} );
test( 'Block variation transforms', async ( { editor, page } ) => {
// This is the `stack` Group variation.
await editor.insertBlock( {
name: 'core/group',
attributes: {
layout: {
type: 'flex',
orientation: 'vertical',
},
},
innerBlocks: [
{
name: 'core/paragraph',
attributes: { content: '1' },
},
],
} );
// Transform to `Stack` variation.
await editor.clickBlockToolbarButton( 'Stack' );
const variations = page
.getByRole( 'menu', { name: 'Stack' } )
.getByRole( 'group' );
await expect(
variations.getByRole( 'menuitem', { name: 'Stack' } )
).toBeHidden();
await variations.getByRole( 'menuitem', { name: 'Row' } ).click();
await expect.poll( editor.getBlocks ).toMatchObject( [
{
name: 'core/group',
attributes: expect.objectContaining( {
layout: {
type: 'flex',
flexWrap: 'nowrap',
orientation: undefined,
},
} ),
innerBlocks: [
{
name: 'core/paragraph',
attributes: { content: '1' },
},
],
},
] );
await editor.clickBlockToolbarButton( 'Row' );
await expect(
page.locator( 'role=menuitem[name="Stack"i]' )
).toBeVisible();
} );
} );