diff --git a/packages/edit-site/src/components/editor/index.js b/packages/edit-site/src/components/editor/index.js index 9ff576e5842da..2c4693ba7ded6 100644 --- a/packages/edit-site/src/components/editor/index.js +++ b/packages/edit-site/src/components/editor/index.js @@ -70,6 +70,9 @@ const blockRemovalRules = { 'core/post-content': __( 'Post Content displays the content of a post or page.' ), + 'core/post-template': __( + 'Post Template displays each post or page in a Query Loop.' + ), }; export default function Editor( { isLoading } ) { diff --git a/test/e2e/specs/site-editor/block-removal.spec.js b/test/e2e/specs/site-editor/block-removal.spec.js index 66c75d722e425..c1d6cdfea0022 100644 --- a/test/e2e/specs/site-editor/block-removal.spec.js +++ b/test/e2e/specs/site-editor/block-removal.spec.js @@ -38,6 +38,30 @@ test.describe( 'Site editor block removal prompt', () => { ).toBeVisible(); } ); + test( 'should appear when attempting to remove Post Template 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 open child blocks of Query Loop block + const listView = page.getByRole( 'region', { name: 'List View' } ); + await listView.getByRole( 'link', { name: 'Query Loop' } ).click(); + await page.keyboard.press( 'ArrowRight' ); + + // Select and try to remove Post Template block + await listView.getByRole( 'link', { name: 'Post Template' } ).click(); + await page.keyboard.press( 'Backspace' ); + + // Expect the block removal prompt to have appeared + await expect( + page.getByText( + 'Post Template displays each post or page in a Query Loop.' + ) + ).toBeVisible(); + } ); + test( 'should not appear when attempting to remove something else', async ( { editor, page, @@ -53,14 +77,20 @@ test.describe( 'Site editor block removal prompt', () => { // Reveal its inner blocks in the list view await page.keyboard.press( 'ArrowRight' ); - // Select and remove its Post Template inner block + // Select its Post Template inner block await listView.getByRole( 'link', { name: 'Post Template' } ).click(); + + // Reveal its inner blocks in the list view + await page.keyboard.press( 'ArrowRight' ); + + // Select and remove its Title inner block + await listView.getByRole( 'link', { name: 'Title' } ).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', + name: 'Block: Title', } ) ).toBeHidden(); } );