-
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
Testing: Add integration tests for blocks with deprecations #15268
Conversation
I don't see any code that adds it to the generation of the fixtures. How does it work? |
@@ -0,0 +1,10 @@ | |||
<!-- wp:core/gallery {"ids":[null,null],"columns":2} --> |
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.
There's multiple deprecations, but I only see one being added here?
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.
Yes, it's time-consuming to backport all those missing fixtures.
It's handled out of the box based on the patterns in the fixtures folder: |
I tried the following code for Quote but it doesn't work as the currently active <!-- wp:core/quote {"align":"left","style":2} -->
<blockquote class="wp-block-quote is-large" style="text-align:left">
<p>Testing deprecated quote block...</p>
<cite>...with a caption</cite>
</blockquote>
<!-- /wp:core/quote --> |
eb25221
to
4658ef3
Compare
I was able to cover all Pullquote deprecations with tests in 4658ef3. I will look into Image and Gallery blocks tomorrow. |
4658ef3
to
bf87e3a
Compare
It's now covered with 9e84880 and 4658ef3. I removed one of the deprecations from Gallery block as it will never catch block definition because of how the newer one builds on top of it. The related change was introduced in: #11540. |
{"core\/archives":{"attributes":{"align":{"type":"string","enum":["left","center","right","wide","full"]},"className":{"type":"string"},"displayAsDropdown":{"type":"boolean","default":false},"showPostCounts":{"type":"boolean","default":false}}},"core\/block":{"attributes":{"ref":{"type":"number"}}},"core\/calendar":{"attributes":{"align":{"type":"string","enum":["left","center","right","wide","full"]},"className":{"type":"string"},"month":{"type":"integer"},"year":{"type":"integer"}}},"core\/categories":{"attributes":{"align":{"type":"string","enum":["left","center","right","wide","full"]},"className":{"type":"string"},"displayAsDropdown":{"type":"boolean","default":false},"showHierarchy":{"type":"boolean","default":false},"showPostCounts":{"type":"boolean","default":false}}},"core\/latest-comments":{"attributes":{"align":{"type":"string","enum":["left","center","right","wide","full"]},"className":{"type":"string"},"commentsToShow":{"type":"number","default":5,"minimum":1,"maximum":100},"displayAvatar":{"type":"boolean","default":true},"displayDate":{"type":"boolean","default":true},"displayExcerpt":{"type":"boolean","default":true}}},"core\/latest-posts":{"attributes":{"align":{"type":"string","enum":["left","center","right","wide","full"]},"className":{"type":"string"},"categories":{"type":"string"},"postsToShow":{"type":"number","default":5},"displayPostContent":{"type":"boolean","default":false},"displayPostContentRadio":{"type":"string","default":"excerpt"},"excerptLength":{"type":"number","default":55},"displayPostDate":{"type":"boolean","default":false},"postLayout":{"type":"string","default":"list"},"columns":{"type":"number","default":3},"order":{"type":"string","default":"desc"},"orderBy":{"type":"string","default":"date"}}},"core\/legacy-widget":{"attributes":{"className":{"type":"string"},"identifier":{"type":"string"},"instance":{"type":"object"},"isCallbackWidget":{"type":"boolean"}}},"core\/rss":{"attributes":{"align":{"type":"string","enum":["left","center","right","wide","full"]},"className":{"type":"string"},"columns":{"type":"number","default":2},"blockLayout":{"type":"string","default":"list"},"feedURL":{"type":"string","default":""},"itemsToShow":{"type":"number","default":5},"displayExcerpt":{"type":"boolean","default":false},"displayAuthor":{"type":"boolean","default":false},"displayDate":{"type":"boolean","default":false},"excerptLength":{"type":"number","default":55}}},"core\/search":{"attributes":{"align":{"type":"string","enum":["left","center","right","wide","full"]},"className":{"type":"string"},"label":{"type":"string","default":"Search"},"placeholder":{"type":"string","default":""},"buttonText":{"type":"string","default":"Search"}}},"core\/shortcode":{"attributes":{"text":{"type":"string","source":"html"}}},"core\/tag-cloud":{"attributes":{"align":{"type":"string","enum":["left","center","right","wide","full"]},"className":{"type":"string"},"taxonomy":{"type":"string","default":"post_tag"},"showTagCounts":{"type":"boolean","default":false}}}} |
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.
It looks like npm run fixtures:regenerate
wasn't executed after Latest Posts block was updated.
@@ -95,47 +142,39 @@ export const settings = { | |||
); | |||
}, | |||
}, | |||
{ |
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.
The previous definition is nearly the same (it only adds one optional attribute in HTML output) making this entry redundant. It can be safely removed.
Then why weren't they generated before? I also see changes to fixtures. What makes it so that they are now generated in this PR? |
You need to manual craft HTML input files yourself. See all details explained in this file: https://github.com/WordPress/gutenberg/blob/master/packages/e2e-tests/fixtures/blocks/README.md |
@gziolo Ah, I see. Is there any way we can error if someone adds a deprecation, but doesn't add a HTML input file to test the deprecated code? |
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.
Love that deprecations are now tested!
Yes, that would be nice to have. It's now automatically enforced to include one HTML file per block's folder. We probably can expand on that once we have standardized |
Description
Inspired by the comment from @ellatrix in #15057 (comment):
This PR adds integration tests for blocks with deprecations:
Paragraph block was covered previously.
Implementation details
I used #3996 to replicate the example for deprecated Gallery block. I figured out there are two issues:
none
value but injects other values otherwiseimages
attribute uses a newer definition which makes it uselessI fixed both issues in this PR. You can test it manually by opening Gutenberg's Code Editor and pasting the following snippet used in the test:
How has this been tested?
npm run test-unit