-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Tests: Add integration tests with core blocks schema validation #36351
Conversation
Size Change: -35 B (0%) Total Size: 1.08 MB
ℹ️ View Unchanged
|
931072b
to
609b1d7
Compare
/** | ||
* External dependencies | ||
*/ | ||
import Ajv from 'ajv-draft-04'; |
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 had to install ajv-draft-04
to make everything work with the defined schema:
http://json-schema.org/draft-04/schema#
Out of the box, Ajv supports JSON Schema (drafts 04, 06, 07, 2019-09 and 2020-12) and JSON Type Definition (RFC8927 (opens new window)).
However, in practice, only JSON Schema draft-06/07/2019-09/2020-12 standards work with the core ajv
package. Is there any reason we picked draft-04
?
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.
@gziolo This is all the context I have. We briefly talked about it in the initial review of the block.json
introduction PR.
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 guess it’s fine to leave it as is. Thank you for sharing the context 💯
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.
SchemaStore has some best practices listed in their contributing docs that I was also basing my decisions off of. https://github.com/SchemaStore/schemastore/blob/master/CONTRIBUTING.md#best-practices
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.
Outside of the outstanding comment regarding the Schema version I think this looks great and does what we need :)
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 great! 🌟
Thanks for catching the blocks I missed, were they new? Good idea adding a test to make sure blocks have the file also. 👍
Validation script works well, I tested by making an invalid block.json file both by having improper JSON, and incorrect values that don't match the schema. The script picked up on all issues.
Great addition! 🚀
I know that some of them were new. |
Description
Follow up for #35900.
Closes #36319.
Adds a missing
$schema
field to a few more blocks. I also wrote integration tests to enforce that every block hasblock.json
with the$schema
field and the metadata validates against the local schema.How has this been tested?
Types of changes
Automated tests added.
Checklist:
standards/wordpress-coding-standards/accessibility/ -->