From 02a7c49707159f8b79b587fa84f1301c5751e278 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Thu, 18 May 2023 18:43:12 +0400 Subject: [PATCH] Fix flaky media inserter drag-and-dropping e2e test (#50740) --- test/e2e/specs/editor/blocks/image.spec.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/e2e/specs/editor/blocks/image.spec.js b/test/e2e/specs/editor/blocks/image.spec.js index eb5d9e2780b445..82a7e1ac71cce5 100644 --- a/test/e2e/specs/editor/blocks/image.spec.js +++ b/test/e2e/specs/editor/blocks/image.spec.js @@ -552,9 +552,16 @@ test.describe( 'Image', () => { } ); async function openMediaTab() { - await page - .getByRole( 'button', { name: 'Toggle block inserter' } ) - .click(); + const blockInserter = page.getByRole( 'button', { + name: 'Toggle block inserter', + } ); + const isClosed = + ( await blockInserter.getAttribute( 'aria-pressed' ) ) === + 'false'; + + if ( isClosed ) { + await blockInserter.click(); + } await blockLibrary.getByRole( 'tab', { name: 'Media' } ).click();