Repository navigation
Conversation
…palette items. Adds tests for `_wp_admin_bar_icon()`, `wp_admin_bar_sidebar_toggle()` and `wp_admin_bar_command_palette_menu()`, covering the icon markup, the admin only behavior of the sidebar toggle, and the conditions, keyboard shortcut label and script of the command palette button. See #66491.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the added Admin Bar test coverage.
No open issues 🎉
What changed in this PR
Adds Toolbar (Admin Bar) test coverage for Trac ticket #66491 without changing production behavior.
Changes:
- Tests registered and unknown icon markup, plus sidebar toggle visibility and attributes.
- Covers command palette visibility, button metadata, inline script presence, and Windows/Apple shortcut labels.
- Isolates script state and restores modified globals after command palette setup.
| File | Description |
|---|---|
tests/phpunit/tests/adminbar.php |
Adds eight tests covering icons, the sidebar toggle, and command palette items. |
Review effort: Balanced
huzaifaalmesbah
left a comment
There was a problem hiding this comment.
Thanks for working on this, @hmbashar! I really appreciate you taking the time to cover the Toolbar icon helper, sidebar toggle, and command palette button—these items add important admin functionality and had no direct tests before.
I reviewed the changes against Core standards, verified fixture hygiene (including clean restoration of scripts, user agent, and icon registry state), and checked all scenarios. Everything looks solid, cleanly isolated, and ready to go.
AI Review: Gemini 3.8 Flash
lancewillett
left a comment
There was a problem hiding this comment.
The Windows and Apple shortcut cases and the script-enqueue guard are worth keeping. Please simplify their setup. I ran the six sidebar and command-palette cases with a fresh WP_Admin_Bar and a direct call to the callback under test. Their node assertions passed in both single-site and multisite without logging in an editor or running every Toolbar callback. One integration case can still cover hook registration if that is part of the intended coverage.
Please also drop the exact sourceURL assertion. Renaming that debugger label would fail the test even if the command palette still opens and displays the correct shortcut. The node and shortcut assertions cover the behavior users see.
AI review · gpt-6
Adds unit tests for the Toolbar (Admin Bar) icon helper, sidebar toggle and command palette button in
tests/phpunit/tests/adminbar.php. This is the last group of the test coverage work proposed in the ticket, and is independent from the other groups. No behavior is changed.Functions covered:
_wp_admin_bar_icon()ab-icon svg-iconelement.wp_admin_bar_sidebar_toggle()wp_admin_bar_command_palette_menu()wp-core-commandsscript is enqueued: icon, URL,onclick, class, label and inline script.Ctrl+Klabel by default and the⌘Klabel for an Apple user agent.The tests that depend on the enqueued scripts use a fresh
WP_Scriptsinstance, which is restored afterwards, and the user agent is restored too.Testing:
vendor/bin/phpunit --filter Tests_AdminBarvendor/bin/phpunit -c tests/phpunit/multisite.xml --filter Tests_AdminBarvendor/bin/phpcs tests/phpunit/tests/adminbar.phpI also temporarily broke the related lines in
src/wp-includes/admin-bar.php(sidebar toggle admin guard, command palette script and admin guards, Apple user agent detection, icon empty check and wrapper class) and confirmed that a new test fails for each one.Trac ticket: https://core.trac.wordpress.org/ticket/66491
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.
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.