-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Block removal prompt: let consumers pass their own rules (#51841)
* Block removal prompt: let consumers pass their own rules Following up on #51145, this untangles `edit-site` from `block-editor` by removing the hard-coded set of rules `blockTypePromptMessages` from the generic `BlockRemovalWarningModal` component. Rules are now to be passed to that component by whichever block editor is using it. Names and comments have been updated accordingly and improved. * Site editor: Add e2e test for block removal prompt
- Loading branch information
Showing
7 changed files
with
146 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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(); | ||
} ); | ||
} ); |
862d719
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flaky tests detected in 862d719.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5423636698
📝 Reported issues:
specs/editor/various/autosave.test.js