From ef36763844e2d721b0b16e567a1e1d345859eb9c Mon Sep 17 00:00:00 2001 From: himanshupathak95 Date: Wed, 5 Feb 2025 12:15:07 +0530 Subject: [PATCH] E2E: Improve spacer block test by mocking theme settings --- test/e2e/specs/editor/blocks/spacer.spec.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/test/e2e/specs/editor/blocks/spacer.spec.js b/test/e2e/specs/editor/blocks/spacer.spec.js index 9d65cc8ec683c..d969bda272d8f 100644 --- a/test/e2e/specs/editor/blocks/spacer.spec.js +++ b/test/e2e/specs/editor/blocks/spacer.spec.js @@ -52,9 +52,16 @@ test.describe( 'Spacer', () => { test( 'should work in theme without spacing units support', async ( { admin, editor, - requestUtils, + page, } ) => { - await requestUtils.activateTheme( 'twentytwenty' ); + // Mock the theme.json data to simulate a theme without spacing units + await page.evaluate( () => { + window.__originalSettings = window.__experimentalGetSettings(); + window.__experimentalGetSettings = () => ( { + ...window.__originalSettings, + spacing: { units: false }, + } ); + } ); await admin.createNewPost(); await editor.insertBlock( { name: 'core/spacer' } ); @@ -63,6 +70,12 @@ test.describe( 'Spacer', () => { editor.canvas.locator( '.block-editor-warning' ) ).not.toBeVisible(); - await requestUtils.activateTheme( 'twentytwentyone' ); + await page.evaluate( () => { + if ( window.__originalSettings ) { + window.__experimentalGetSettings = () => + window.__originalSettings; + delete window.__originalSettings; + } + } ); } ); } );