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

Navigation Block: Add test coverage to check that post content is not removed #60189

Merged
merged 1 commit into from
Mar 26, 2024

Conversation

ockham
Copy link
Contributor

@ockham ockham commented Mar 26, 2024

What?

Add a unit test to cover #59991 (fixed in #60071). The issue was that if a navigation menu was renamed (but not changed otherwise), its content was accidentally deleted.

The reason for this was related to the stdClass object that's used to communicate required changes to wp_update_post: If its post_content field was not set (indicating no changes were to be made), block_core_navigation_update_ignore_hooked_blocks_meta would accidentally set that field to an empty string (meaning it would be replaced by that) -- thus causing loss of data.

Why?

To prevent against regressions.

How?

Verify that if the stdClass object's post_content is unset before running block_core_navigation_update_ignore_hooked_blocks_meta, it also is afterwards.

Testing Instructions

Verify that tests pass.

To verify that the test covers the issue, revert 7b6ac8d (i.e. #60071), rebuild Gutenberg, and re-run the tests. They should now fail.

@ockham ockham added the [Type] Code Quality Issues or PRs that relate to code quality label Mar 26, 2024
@ockham ockham self-assigned this Mar 26, 2024
Copy link

github-actions bot commented Mar 26, 2024

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: ockham <bernhard-reiter@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

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

@ockham ockham added the [Block] Navigation Affects the Navigation Block label Mar 26, 2024
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.

Thank you, @ockham!

@ockham ockham merged commit e7889a4 into trunk Mar 26, 2024
65 checks passed
@ockham ockham deleted the add/test-update_ignore_hooked_blocks_meta branch March 26, 2024 10:20
@github-actions github-actions bot added this to the Gutenberg 18.1 milestone Mar 26, 2024
carstingaxion pushed a commit to carstingaxion/gutenberg that referenced this pull request Mar 27, 2024
…e nav menu (WordPress#60189)

Co-authored-by: ockham <bernhard-reiter@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
cbravobernal pushed a commit to garridinsi/gutenberg that referenced this pull request Apr 9, 2024
…e nav menu (WordPress#60189)

Co-authored-by: ockham <bernhard-reiter@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
@ellatrix
Copy link
Member

ellatrix commented May 1, 2024

Can/should this test be backported to core?

@getdave
Copy link
Contributor

getdave commented May 1, 2024

My understanding is that this test provides coverage for the Navigation block. The block is maintained in the Gutenberg repo and therefore tests reside in the Gutenberg repo. At least that's what I picked up from Riad as the state of things during the Editor Tech lead role for WP 6.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Affects the Navigation 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.

4 participants