Skip to content

Blocks: Add more unit test covering edge cases for Block Hooks#5279

Closed
gziolo wants to merge 2 commits into
WordPress:trunkfrom
gziolo:update/tests-edge-cases-block-hooks
Closed

Blocks: Add more unit test covering edge cases for Block Hooks#5279
gziolo wants to merge 2 commits into
WordPress:trunkfrom
gziolo:update/tests-edge-cases-block-hooks

Conversation

@gziolo

@gziolo gziolo commented Sep 22, 2023

Copy link
Copy Markdown
Member

Trac ticket: https://core.trac.wordpress.org/ticket/59313

Follow-up for: https://core.trac.wordpress.org/changeset/56649

These two new unit tests document how Block Hooks behave with firstChild and lastChild relative positions. The hooked blocks will only get inserted in the case where the parent block has at least one child block present. While it seems like a limitation, in practice, it's hard to think of a case where the template would use a parent block without its children. It's more likely to happen with patterns in general, but in the case of patterns wired with the block theme, it also seems unlikely. The reasoning here is that out of the box, the block theme should produce a fully functional and valid HTML.

Replaces unit tests that cover similar cases in the Gutenberg plugin that are going to be removed with WordPress/gutenberg#54651.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@gziolo

gziolo commented Sep 26, 2023

Copy link
Copy Markdown
Member Author

Committed with https://core.trac.wordpress.org/changeset/56701.

@gziolo gziolo closed this Sep 26, 2023
@gziolo gziolo deleted the update/tests-edge-cases-block-hooks branch September 26, 2023 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant