-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Footnotes: Add some test coverage for footnotes logic in useEntityBlockEditor #53376
Footnotes: Add some test coverage for footnotes logic in useEntityBlockEditor #53376
Conversation
@@ -290,7 +290,7 @@ export function useEntityBlockEditor( kind, name, { id: _id } = {} ) { | |||
} ); | |||
} | |||
|
|||
// We need to go through all block attributs deeply and update the | |||
// We need to go through all block attributes deeply and update the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave my attributs out of it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, so rude! 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
|
Thanks for the quick review! 🙇 |
What?
Follow-up to #53257 — add tests for
useEntityBlockEditor
to 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?
createBlock
to simulate adding a block with footnotes, to trigger the footnotes logic.Testing Instructions
npm run test:unit packages/core-data/src/test/entity-provider.js
gutenberg/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 (
null
andstring
values within an array block attribute get coerced to object values):