Opened 97 minutes ago
Last modified 83 minutes ago
#66588 new enhancement
Tests: Add unit tests for the server-side rendering of the Page List block
| Reported by: | hmbashar | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Editor | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
Description
The Page List block (core/page-list) is rendered on the server by the functions in src/wp-includes/blocks/page-list.php. They have no tests.
This ticket adds tests for the functions of the file, in several small pull requests:
- the helpers:
block_core_page_list_get_submenu_visibility(),block_core_page_list_build_css_colors()andblock_core_page_list_nest_pages(); - the markup of the list:
block_core_page_list_render_nested_page_list(); - the block:
render_block_core_page_list().
Change History (2)
This ticket was mentioned in PR #15777 on WordPress/wordpress-develop by @hmbashar.
91 minutes ago
#1
- Keywords has-patch has-unit-tests added
This ticket was mentioned in PR #15778 on WordPress/wordpress-develop by @hmbashar.
83 minutes ago
#2
Summary
Adds tests for block_core_page_list_render_nested_page_list(), the function that outputs the markup of the list of the Page List block, which had no tests. This is the second pull request for the ticket; the first one covers the helper functions, and the block itself follows.
- The markup of a page, the order of the pages, and an empty list.
- The active page, the ancestors of the active page, and the front page.
- The child pages in a submenu, and the options reaching the pages at every level.
- The classes of the items of the Navigation block for each submenu visibility, with and without submenu icons, and nothing of this outside of the Navigation block.
- The submenu button next to the link, and the button in place of the link when the submenu opens on click.
- The title: the fallback for a page without a title, the filtering of the title and the label, and the escaping of the link.
- The overlay colors of the items in a submenu and of a list that is in a submenu, and their escaping.
Testing
vendor/bin/phpunit --filter 'Tests_Blocks_PageListNestedPageList::' vendor/bin/phpunit -c tests/phpunit/multisite.xml --filter 'Tests_Blocks_PageListNestedPageList::' vendor/bin/phpcs tests/phpunit/tests/blocks/pageListNestedPageList.php
Mutation check: 48 changes to the function (every condition, class, flag and attribute, the escaping and the arguments passed to the child lists) were each caught by a test. One change was left out as it does not change the output: passing false for $is_nested to the child lists, since the items of the child lists get the overlay colors by their depth anyway.
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5.5
Used for: Written with AI and manually reviewed by me.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Summary
Adds tests for the helper functions of the Page List block, which had no tests. This is the first pull request for the ticket. The markup of the list and the block follow in separate pull requests.
block_core_page_list_get_submenu_visibility(): the default, the visibility of the navigation, and the deprecatedopenSubmenusOnClickattribute that wins over it.block_core_page_list_build_css_colors(): the named, the picked and the style colors of the text and of the background, which one wins, and the colors of the overlay.block_core_page_list_nest_pages(): no pages, pages without children, and children of children.Testing
Mutation check: 36 changes to the three functions (every condition, the order in which the colors win, the kebab case of the color names and the recursion) were each caught by a test.
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5.5
Used for: Written with AI and manually reviewed by me.