-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Block Bindings: Add unit test coverage for sources #72799
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
Conversation
92a9bbb to
ccca546
Compare
|
Size Change: 0 B Total Size: 2.38 MB ℹ️ View Unchanged
|
|
Flaky tests detected in 1a0cca9. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/18945720443
|
9a73c72 to
202f424
Compare
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
gziolo
left a comment
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.
This is a very nice additiona that vastly improves testing code coverage for post meta source using unit tests.
Aside, I know these tests cover existing functionality so it's outside of scope in this PR. However, I must admit it's uncovers the underlaying problem of mixing the actual value with labels and keys inside content property. It's a bit confusing, but it might be too late to change how getValues work.
Yeah, I agree that that's not ideal. It might just make more sense to return |
…72799) Test coverage for the `core/post-meta` source is currently provided through e2e tests. This commit adds unit tests, providing more granular coverage, which in turn allows pinpointing issues more easily. Co-authored-by: ockham <[email protected]> Co-authored-by: gziolo <[email protected]>
|
I just cherry-picked this PR to the wp/6.9 branch to get it included in the next release: 64c6b86 |
What?
Add unit test coverage for block bindings sources.
Why?
See #72739 (comment):
How?
Note that there are some "natural" mappings, e.g.:
postIdin context (and editing a Movie CPT post maps to providing apostId).getValues.getFieldsList.or editthe value of a protected fieldshow_in_restset to falseshow oredit the value of a protected fieldTesting Instructions
To run the new unit tests locally:
To run the corresponding e2e tests locally:
Note that the e2e tests will most likely fail when run locally (even though the file is unchanged on this branch)! This is a known issue, although the reason is still unclear. It seems like the Post Meta source isn't always available during e2e tests. They do however pass in CI.
Follow-up
I think we should consider removing some of the e2e tests, specifically the ones that are basically just a thin wrapper around a check for the return value of a function such as
getValuesandgetFieldsList. When working on #72739, I found that they were obfuscating the underlying issue, rather than helping to pinpoint it.