Tests: Add integration tests with core blocks schema validation#36351
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.
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.
@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.
I guess it’s fine to leave it as is. Thank you for sharing the context 💯
There was a problem hiding this comment.
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
fabiankaegy
left a comment
There was a problem hiding this comment.
Outside of the outstanding comment regarding the Schema version I think this looks great and does what we need :)
mkaz
left a comment
There was a problem hiding this comment.
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
$schemafield to a few more blocks. I also wrote integration tests to enforce that every block hasblock.jsonwith the$schemafield 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/ -->