Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E: Add regression test for spacer block in themes without spacing units #68913

Merged
34 changes: 34 additions & 0 deletions test/e2e/specs/editor/blocks/spacer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,38 @@ test.describe( 'Spacer', () => {
)
).toBeFocused();
} );

test( 'should work in theme without spacing units support', async ( {
admin,
editor,
page,
} ) => {
// Mock the theme.json data to simulate a theme without spacing units
Mamaduka marked this conversation as resolved.
Show resolved Hide resolved
await page.evaluate( () => {
const settings = window.wp.data
.select( 'core/block-editor' )
.getSettings();
window.__originalSettings = settings;
window.wp.data.dispatch( 'core/block-editor' ).updateSettings( {
...settings,
spacing: { units: false },
} );
} );

await admin.createNewPost();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this. It's already handled in the test.beforeEach hook.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I might have missed the line in the beforeEach hook. Correcting this.

await editor.insertBlock( { name: 'core/spacer' } );

await expect(
editor.canvas.locator( '.block-editor-warning' )
).toBeHidden();

await page.evaluate( () => {
if ( window.__originalSettings ) {
window.wp.data
.dispatch( 'core/block-editor' )
.updateSettings( window.__originalSettings );
delete window.__originalSettings;
}
} );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's no need to restore old settings in this case. Reloading the subsequent tests will re-open the editor, and store data will be refetched..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this since in the future if we decide to add steps to this, I must clean up the changes in the configs I made. But I see how this is a far-fetched thought, so removing it.

} );
} );
Loading