Skip to content

Commit

Permalink
E2E: Improve spacer block test by mocking theme settings
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshupathak95 committed Feb 5, 2025
1 parent 285ce69 commit ef36763
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions test/e2e/specs/editor/blocks/spacer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' } );
Expand All @@ -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;
}
} );
} );
} );

0 comments on commit ef36763

Please sign in to comment.