-
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
Fixture Tests: Correctly generate fixture files for form-related blocks #56719
Conversation
Size Change: -16 B (0%) Total Size: 1.72 MB
ℹ️ View Unchanged
|
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress. If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged. If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack. Thank you! ❤️ View changed files❔ phpunit/class-block-fixture-test.php |
public function filter_allowed_html( $tags ) { | ||
$tags['form']['class'] = true; | ||
$tags['form']['enctype'] = true; | ||
return $tags; | ||
} |
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 wp_kses_post()
function does not allow form
tag by default. So we need to allow attributes to be included in the serialized form block.
/* eslint-disable no-restricted-syntax */ | ||
import * as form from '@wordpress/block-library/build-module/form'; | ||
import * as formInput from '@wordpress/block-library/build-module/form-input'; | ||
import * as formSubmitButton from '@wordpress/block-library/build-module/form-submit-button'; | ||
import * as formSubmissionNotification from '@wordpress/block-library/build-module/form-submission-notification'; | ||
/* eslint-enable no-restricted-syntax */ |
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.
If you have a better approach than this, please let me know.
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.
Thank you @t-hamano!
LGTM 👍
Fixes #56590
This issue was discovered in this comment: #56507 (comment)
What?
This PR will ensure that the fixture files for the following two blocks are generated correctly.
test/integration/fixtures/blocks/core__form-input.html
test/integration/fixtures/blocks/core__form.html
Additionally, this PR creates fixture files for form-related blocks that do not yet exist.
test/integration/fixtures/blocks/core__form-submission-notification.html
test/integration/fixtures/blocks/core__form-submit-button.html
Why?
These blocks are not available unless you explicitly opt-in on the Experimental Settings page. In other words, in fixture tests, it is excluded from the blocks registered with the
registerBlocks()
function.As a result, even if you create a fixture file, that block will be considered a
core/missing
block and will not generate a correct serialized file that has passed deprecation.How?
getNameFromLabel()
function no longer depends on thedocument
object to avoid fixture test failures. (See the "The behavior of the save function of the Input Field block is different in the fixture test" section in #56590 for details.)Testing Instructions
Confirm that the form-input block's save function outputs exactly the same markup as before.