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

Conversation

himanshupathak95
Copy link
Contributor

@himanshupathak95 himanshupathak95 commented Jan 28, 2025

Closes #37922

What?

Add an E2E test to ensure the Spacer block works correctly in themes without spacing unit support. This regression test switches to the Twenty Twenty theme (which doesn't support spacing units) and verifies the Spacer block can be inserted without errors.

Why?

Previously, the Spacer block would break in themes where useSetting( 'spacing.units' ) returned false. This regression test ensures this issue doesn't recur by testing the block's functionality in a theme without spacing unit support.

Reference: #37774 where the original issue was fixed. This PR adds test coverage to prevent future regressions.

Testing Instructions

Run the E2E test suite:

npm run test:e2e -- editor/blocks/spacer.spec.js

@t-hamano t-hamano added [Type] Code Quality Issues or PRs that relate to code quality [Block] Spacer Affects the Spacer Block labels Jan 31, 2025
@himanshupathak95 himanshupathak95 marked this pull request as ready for review February 4, 2025 06:00
Copy link

github-actions bot commented Feb 4, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: himanshupathak95 <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: fullofcaffeine <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@himanshupathak95
Copy link
Contributor Author

Hey @Mamaduka, Please let me know if this PR looks good to you whenever you have time 😃

editor,
requestUtils,
} ) => {
await requestUtils.activateTheme( 'twentytwenty' );
Copy link
Member

Choose a reason for hiding this comment

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

Switching themes can be expensive, usually done in test.beforeAll hooks. Can we find a different way to test this without switching themes?

} );
} );

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.

Comment on lines 76 to 83
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.

Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

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

Thanks, @himanshupathak95!

This looks good ✅

@Mamaduka Mamaduka merged commit fa5a02e into WordPress:trunk Feb 5, 2025
64 checks passed
@github-actions github-actions bot added this to the Gutenberg 20.3 milestone Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Spacer Affects the Spacer Block [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add regression test for spacer block breakage in themes without spacing.units support
3 participants