Repository navigation
Tests: Add unit test coverage for Connector Approval Admin_Page and Admin_Notice - #1134
noruzzamans wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1134 +/- ##
=============================================
+ Coverage 81.67% 82.00% +0.33%
Complexity 3103 3103
=============================================
Files 129 129
Lines 12334 12334
=============================================
+ Hits 10074 10115 +41
+ Misses 2260 2219 -41
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
dkotter
left a comment
There was a problem hiding this comment.
Thanks for the PR! While I appreciate increasing our test coverage, also want to ensure we're not just adding tests for the sake of adding tests and the tests we add are actually bringing value. I've flagged a few tests here that I think could likely be removed but let me know if you feel differently.
| * | ||
| * @since x.x.x | ||
| */ | ||
| public function test_register_adds_admin_hooks(): void { |
There was a problem hiding this comment.
So I'm not sure what value this test is adding? I know we have similar tests in our codebase though I'd like to clean all of those up. Ideally we're testing that actual functionality works as expected and not just that certain hooks fire
| * | ||
| * @since x.x.x | ||
| */ | ||
| public function test_register_adds_admin_hooks(): void { |
There was a problem hiding this comment.
Another one I'd question the value on having
| * | ||
| * @since x.x.x | ||
| */ | ||
| public function test_url_returns_expected_admin_url(): void { |
There was a problem hiding this comment.
Any need for both this test and test_add_submenu_registers_tools_submenu_for_administrator?
|
Thanks @dkotter! That makes total sense — I completely agree that focusing on real functionality, permissions, and runtime behavior rather than shallow hook-registration checks brings much greater value and keeps the test suite clean and purposeful. I've removed both hook-registration tests as well as the redundant URL test in commit 3b26985, keeping only the meaningful behavioral test coverage. |
What?
Adds dedicated unit and integration test coverage for
WordPress\AI\Experiments\Connector_Approval\Admin_Page(tests/Integration/Includes/Experiments/Connector_Approval/Admin_PageTest.php) and extends test coverage forWordPress\AI\Connector_Approval\Admin_Notice(tests/Integration/Includes/Connector_Approval/Admin_NoticeTest.php).Why?
While the Connector Approval subsystem includes unit tests for
Approvals_Store,Caller_Identifier,Connector_Key_Index,Http_Guard,REST_Controller, andConnector_Approval, the administrative page controllerWordPress\AI\Experiments\Connector_Approval\Admin_Page(includes/Experiments/Connector_Approval/Admin_Page.php) lacked a dedicated test suite (0%direct test coverage). Additionally,Admin_NoticeTestonly covered screen-level CSS class checks while leaving hook registration, capability guards, empty queue handling, singular/plural message formatting, and dismissal signature persistence/invalidation untested.How?
Added
tests/Integration/Includes/Experiments/Connector_Approval/Admin_PageTest.phpcoveringWordPress\AI\Experiments\Connector_Approval\Admin_Page:test_url_returns_expected_admin_url: VerifiesAdmin_Page::url()returns the expectedtools.php?page=ai-connector-approvaladmin URL.test_register_adds_admin_hooks: Verifiesregister()attachesadd_submenutoadmin_menuandenqueue_assetstoadmin_enqueue_scripts.test_add_submenu_registers_tools_submenu_for_administrator: Verifiesadd_submenu()registers theai-connector-approvalsubmenu undertools.phpwithmanage_optionscapability.test_enqueue_assets_bails_on_non_matching_hook_suffix: Verifiesenqueue_assets()returns early without enqueuing assets on unrelated admin screens.test_enqueue_assets_enqueues_script_style_and_localizes_data_on_matching_hook: Verifiesenqueue_assets()enqueues theai_connector_approvalscript and style and localizesaiConnectorApprovalwith the REST endpoint URL and nonce ontools_page_ai-connector-approval.test_render_requires_manage_options_capability: Verifiesrender()terminates viawp_die()when the current user lacksmanage_options.test_render_outputs_page_container_for_administrator: Verifiesrender()outputs the heading and#ai-connector-approval-rootmount container for administrators.Extended
tests/Integration/Includes/Connector_Approval/Admin_NoticeTest.phpcoveringWordPress\AI\Connector_Approval\Admin_Notice:test_register_adds_admin_hooks: Verifiesregister()hooksmaybe_handle_dismissonadmin_initandrenderonadmin_notices.test_render_skips_users_without_manage_options: Verifiesrender()outputs nothing for users withoutmanage_options.test_render_skips_when_pending_queue_is_empty: Verifiesrender()outputs nothing when there are no pending connector approval requests.test_render_outputs_singular_and_plural_messages_with_links: Verifies singular and plural notice copy along with the review and nonce-protected dismiss links.test_maybe_handle_dismiss_bails_without_query_arg: Verifiesmaybe_handle_dismiss()bails whenwpai_ca_notice_dismissis absent.test_maybe_handle_dismiss_bails_without_manage_options: Verifiesmaybe_handle_dismiss()bails when the user lacksmanage_options.test_maybe_handle_dismiss_bails_with_invalid_nonce: Verifiesmaybe_handle_dismiss()bails when the nonce is invalid.test_maybe_handle_dismiss_stores_signature_and_silences_notice_until_queue_changes: Verifies that dismissing the notice stores the MD5 pending-queue signature in user meta, silences subsequent renders for the same queue, and re-displays the notice once a new pending request changes the queue signature.Use of AI Tools
AI assistance: Yes
Model(s): Claude Opus 4.6
Used for: Auditing test coverage gaps in the Connector Approval subsystem and scaffolding test methods. All test cases, assertions, and coding standards compliance were reviewed and verified by me.
Testing Instructions
Changelog Entry