Navigation Block: Add test coverage to check that post content is not removed #60189
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 towp_update_post
: If itspost_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'spost_content
is unset before runningblock_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.