Footnotes: Add some test coverage for footnotes logic in useEntityBlockEditor#53376
Merged
andrewserong merged 2 commits intotrunkfrom Aug 7, 2023
Merged
Conversation
ramonjd
reviewed
Aug 7, 2023
| } | ||
|
|
||
| // We need to go through all block attributs deeply and update the | ||
| // We need to go through all block attributes deeply and update the |
Contributor
Author
There was a problem hiding this comment.
I know, so rude! 😆
ramonjd
approved these changes
Aug 7, 2023
Member
ramonjd
left a comment
There was a problem hiding this comment.
Works as described and covers the test case from the bug fix.
Thank you!
|
Size Change: 0 B Total Size: 1.44 MB ℹ️ View Unchanged
|
Contributor
Author
|
Thanks for the quick review! 🙇 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?
Follow-up to #53257 — add tests for
useEntityBlockEditorto cover footnotes logic that updates the order of footnotes within blocks. These added tests primarily cover the fix in #53257, rather than aiming for full coverage. I figure that we can start with this PR and if the approach seems reasonable for now, we can add further tests for the logic in follow-ups.Why?
The fix in #53257 was fairly complex to test because the bug was only really noticeable for custom blocks that set attributes in a particular way. While we could write e2e tests, these unit/integration tests are faster (
< 20ms) and target the particular part of the footnotes logic that was mutating block attributes.How?
createBlockto simulate adding a block with footnotes, to trigger the footnotes logic.Testing Instructions
npm run test:unit packages/core-data/src/test/entity-provider.jsgutenberg/packages/core-data/src/entity-provider.js
Lines 225 to 231 in d8f5fbc
With those lines commented out, you should see a test failure that matches the behaviour before #53257 landed (
nullandstringvalues within an array block attribute get coerced to object values):