From 47631d0052d8d5ee1ea5a14c57cd2d1475b7ec0e Mon Sep 17 00:00:00 2001 From: ella Date: Fri, 22 May 2026 08:24:24 +0200 Subject: [PATCH] Performance Tests: Wait for editor canvas before media-upload inserts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each media-upload test currently does `admin.createNewPost()` directly followed by `editor.insertBlock(...)`. The post-editor preload kickoff (#78508) defers `setupEditor`'s `SET_EDITED_POST` dispatch past page load, so the block insertion can land on a block-editor store that hasn't bound to the post entity yet — the canvas ends up empty and the subsequent `toBeVisible` assertion times out. Wait for the editor canvas iframe body to render before the iteration loop. That signal only fires once `` has mounted, which guarantees the block-editor store is bound. Co-Authored-By: Claude Opus 4.7 (1M context) --- test/performance/specs/media-upload.spec.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/performance/specs/media-upload.spec.js b/test/performance/specs/media-upload.spec.js index c6f0eb1ca70ffb..6d32b4c2dad421 100644 --- a/test/performance/specs/media-upload.spec.js +++ b/test/performance/specs/media-upload.spec.js @@ -69,6 +69,8 @@ async function runUploadIterations( { } ) { const iterations = samples + throwaway; + await editor.canvas.locator( 'body' ).waitFor(); + for ( let i = 1; i <= iterations; i++ ) { const { tmpFileName, tmpDirectory } = await createTempImage( sourceFile, @@ -201,6 +203,7 @@ test.describe( 'Media Upload Performance', () => { requestUtils, } ) => { await admin.createNewPost(); + await editor.canvas.locator( 'body' ).waitFor(); for ( let i = 1; i <= iterations; i++ ) { await editor.insertBlock( { name: 'core/gallery' } );