-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathblock-removal.spec.js
67 lines (56 loc) · 2.1 KB
/
block-removal.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
61
62
63
64
65
66
67
/**
* WordPress dependencies
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );
test.describe( 'Site editor block removal prompt', () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.activateTheme( 'emptytheme' );
} );
test.afterAll( async ( { requestUtils } ) => {
await requestUtils.activateTheme( 'twentytwentyone' );
} );
test.beforeEach( async ( { admin, editor } ) => {
await admin.visitSiteEditor( {
postId: 'emptytheme//index',
postType: 'wp_template',
} );
await editor.canvas.click( 'body' );
} );
test( 'should appear when attempting to remove Query Block', async ( {
page,
} ) => {
// Open and focus List View
const topBar = page.getByRole( 'region', { name: 'Editor top bar' } );
await topBar.getByRole( 'button', { name: 'List View' } ).click();
// Select and try to remove Query Loop block
const listView = page.getByRole( 'region', { name: 'List View' } );
await listView.getByRole( 'link', { name: 'Query Loop' } ).click();
await page.keyboard.press( 'Backspace' );
// Expect the block removal prompt to have appeared
await expect(
page.getByText( 'Query Loop displays a list of posts or pages.' )
).toBeVisible();
} );
test( 'should not appear when attempting to remove something else', async ( {
editor,
page,
} ) => {
// Open and focus List View
const topBar = page.getByRole( 'region', { name: 'Editor top bar' } );
await topBar.getByRole( 'button', { name: 'List View' } ).click();
// Select Query Loop list item
const listView = page.getByRole( 'region', { name: 'List View' } );
await listView.getByRole( 'link', { name: 'Query Loop' } ).click();
// Reveal its inner blocks in the list view
await page.keyboard.press( 'ArrowRight' );
// Select and remove its Post Template inner block
await listView.getByRole( 'link', { name: 'Post Template' } ).click();
await page.keyboard.press( 'Backspace' );
// Expect the block to have been removed with no prompt
await expect(
editor.canvas.getByRole( 'document', {
name: 'Block: Post Template',
} )
).toBeHidden();
} );
} );