-
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
Categories block: move attributes to PHP #10635
Categories block: move attributes to PHP #10635
Conversation
I have a PR to allow the Categories block to use the |
Just a thought: e2e tests here would really help us validate that there are no regressions from master. Would you have the chance to add tests for it? 😄 |
@tofumatt I have no idea how to create tests. How do you do it, and what exactly should the e2e tests be testing? |
That probably means we won't have time for tests as I don't think we have time to onboard tonight 🙂 No worries! (For what it's worth: I would want to test common category behaviour and make sure that the tests run in |
@tofumatt Are you aware of any similar tests for other server-rendered blocks in the plugin? I might be able to squeeze in time to take a swing at it (and/or help @ZebulanStanphill) but it'd be nice to borrow from an existing example, if there is one. (I'm also going to poke around in the test folder — not totally helpless! — but if you have an idea off the top of your head that'd be cool!) EDIT: I'm having trouble digging up tests for any server rendered blocks. The block tests we have check against the raw block markup, not the rendered markup. We would need a way to compare with the published HTML of a post… still digging but not sure there's an example available. |
@chrisvanpatten we don't have such tests yet. I tend to prefer e2e tests have a better regression catch rate, so I'd argue we can start testing blocks using e2e tests:
|
@youknowriad I think if I can figure out how to snapshot the rendered markup, it should be pretty doable. Presumably we would need a |
Notably, I was planning on some more PRs after to this to standardize the alignments for all the widget blocks (e.g. right now the Categories block supports the |
@ZebulanStanphill There's always phase 2 :) |
True, but I was hoping I could help polish the initial release just a bit more. For reference, here is the current state of alignment options on widget blocks:
|
@ZebulanStanphill could you do a version of this that keeps everything identical in terms of where attributes are defined and all, but switches to use the See here: https://github.com/WordPress/gutenberg/pull/10562/files#diff-b7509123419c1a7302e1331c08294262R61 You should also be able to remove the |
@chrisvanpatten I thought you couldn't use |
@ZebulanStanphill you should be able to. It only provides the UI; the server callback still needs to apply the class. |
And obviously if the server callback is doing any validation of the align attribute that might need to be updated to account for the available alignments. |
@chrisvanpatten Okay, I'm testing out a new PR now. The block now lets you set any value for |
Just to clarify, I put the |
Closing this PR in favor of its replacement: #10635. |
Description
This PR changes the code for the Categories block, per feedback and discussion on #9829. There should be no behavioral changes from
master
. This is essentially just a code cleanup PR.How has this been tested?
I opened a post with an existing Categories block and checked to make sure setting alignments worked and applied the right classes in the editor and front-end.
Types of changes
index.js
toindex.php
to increase consistency with other blocks using server-side rendering.align
attribute now usesenum
to define the valid values.getEditWrapperProps
inindex.js
no longer checks the exact alignment value, as this is now covered by the attribute definition in PHP. It only checks to make sure the value is notundefined
, so that an erroneousalignundefined
class is never applied.test/integration/full-content/server-registered.json
. I also took the opportunity to rearrange the order of the blocks listed so they are in alphabetical order.