From 63079c7edd8e823664d0fb5e28ed5a558a97fa51 Mon Sep 17 00:00:00 2001 From: Kai Hao Date: Wed, 15 Feb 2023 21:32:41 +0800 Subject: [PATCH] Fix `editor.getBlocks` for unmodified default block (#48093) --- .../src/editor/get-blocks.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/e2e-test-utils-playwright/src/editor/get-blocks.ts b/packages/e2e-test-utils-playwright/src/editor/get-blocks.ts index dba597a19c983..70a5a03628ee0 100644 --- a/packages/e2e-test-utils-playwright/src/editor/get-blocks.ts +++ b/packages/e2e-test-utils-playwright/src/editor/get-blocks.ts @@ -15,14 +15,11 @@ export async function getBlocks( this: Editor ) { const blocks = window.wp.data.select( 'core/block-editor' ).getBlocks(); // The editor might still contain an unmodified empty block even when it's technically "empty". - if ( blocks.length === 1 ) { - const blockName = blocks[ 0 ].name; - if ( - blockName === window.wp.blocks.getDefaultBlockName() || - blockName === window.wp.blocks.getFreeformContentHandlerName() - ) { - return []; - } + if ( + blocks.length === 1 && + window.wp.blocks.isUnmodifiedDefaultBlock( blocks[ 0 ] ) + ) { + return []; } return blocks;