-
Notifications
You must be signed in to change notification settings - Fork 797
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
Add a block fixtures framework to allow automated checking of block validation #18643
Add a block fixtures framework to allow automated checking of block validation #18643
Conversation
This is an automated check which relies on |
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 tests well for me 👍
- All tests passed when run as per instructions
- Altering the fixture or the save function correctly caused test failures
- Altering the number of deprecations was also caught
- Deleting fixture files was handled
- Regeneration of fixtures worked and tests were passing again
- Took it for a test run on the
jetpack/rating-star
block and appeared fine - Only one minor issue in code, inline comment left.
It would be good to get a few extra sets of eyes on this though with regards to overall approach. In the meantime, I have a couple of questions or thoughts on it.
Naming convention for "settings"
In #18582 the block's controls get refactored out into a settings.js
file. Now within this PR we are importing block settings as settings
within validate.js
. It might be good to establish some clearer naming conventions around this now at the outset.
Automating script/fixture generation
Can we automate the creation of the initial fixture .html
file at all?
It seems like the simple steps of inserting a block with blank or default attributes and running it through the save function could be doable. Perhaps we could use the block settings' example.attributes
if available?
Similar question for the validate.js
can we script it's initial creation?
I'm thinking making it super simple to get the files in place might help encourage inclusion of these tests for more blocks.
projects/plugins/jetpack/extensions/shared/test/block-fixtures.js
Outdated
Show resolved
Hide resolved
Could be worth looking at. I will get some more feedback on the concept in general first and then take a look at that. |
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.
Have only skimmed through this, for now, but ❤️ adding this kind of test!
It'd be great to add a section to the block fixtures readme with a step by step process for updating when creating a deprecation... I imagine that's going to be "first contact" with this system for many folks working on existing blocks.
<3 it! I left few questions inline, but I also have a few more general questions.
|
Caution: This PR has changes that must be merged to WordPress.com |
Have added some details, let me know if it make sense or not. |
The validation tests all get run as part of
I am assuming that because they all run as part of |
Oh, I didn't know that. that should take care of CI run. Happy to approve it once you'll get a green light from one of your teammates |
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.
Great work on this! Works well for me, and happy to see this implemented in new and existing blocks going forward. 👍🏻
5cf8b8d
to
8e6cf18
Compare
8df20f6
to
1def8d3
Compare
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 you don't need approval from Crew to merge this branch into another (non-master) branch, but here it goes anyway :)
fab9c33
to
0090356
Compare
1def8d3
to
3bb5e46
Compare
…alidation (#18643) Co-authored-by: Glen Davies <glen.davies@a8c.com>
Note Needs to be merged into #18582 before it is merged.
Adds automated checking of block validation for Jetpack blocks. See p1HpG7-b6y-p2 for background.
Based on the Gutenberg core block fixtures, but restructured to put the fixtures next to the block in question.
Only runs for WhatsApp block currently.
To generate new fixtures:
yarn fixtures:generate extensions/blocks/send-a-message/whatsapp-button/test/validate.js
To run validation tests:
yarn test-extensions-single extensions/blocks/send-a-message/whatsapp-button/test/validate.js
See the readme file for more details.