Repository navigation
Tests: Add unit test coverage for Logging\AI_Request_Log_Page - #1038
Conversation
Developer - Added unit test coverage for Logging\AI_Request_Log_Page. Co-authored-by: noruzzamans <noruzzaman@git.wordpress.org>
954a4f4 to
04723ee
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1038 +/- ##
=============================================
+ Coverage 80.23% 80.72% +0.48%
Complexity 2998 2998
=============================================
Files 124 124
Lines 11978 11978
=============================================
+ Hits 9611 9669 +58
+ Misses 2367 2309 -58
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. |
What?
Adds unit and integration test coverage for
WordPress\AI\Logging\AI_Request_Log_Pageintests/Integration/Includes/Logging/AI_Request_Log_PageTest.php.Why?
The logging component provides comprehensive tests for
AI_Request_Log_Manager,AI_Request_Log_Repository,AI_Request_Log_Controller,Log_Data_Extractor, andLogging_Http_Transporter, but lacked dedicated test coverage forAI_Request_Log_Page.Adding this test suite verifies that:
ai-request-logsis properly registered with capabilitymanage_optionsand hooks intoload-{$page_hook}for authorized users.load-{$page_hook}action.on_load()method correctly attachesenqueue_assetstoadmin_enqueue_scripts.enqueue_assets()enqueues the required scripts (ai_ai_request_logs), styles, handles the bundled DataViews fallback stylesheet conditionally, sets script translations, and localizes essential settings (RequestLogsSettings, REST endpoints, initial summary/filter state, connectors URL, and provider metadata).render_page()correctly checksmanage_optionscapability, rendering the root container<div id="ai-request-logs-root"></div>for administrators and outputting nothing for unauthorized users.get_provider_metadata()correctly filters registered connectors forai_providerentries, identifies client vs. cloud provider types, and extracts logo and credentials URLs.How?
tests/Integration/Includes/Logging/AI_Request_Log_PageTest.phpcovering:test_constructor_initializes_instance: Verifies constructor instantiatesAI_Request_Log_Page.test_register_menu_adds_submenu_page_for_authorized_user: Verifies submenu page registration undertools.phpwithmanage_optionscapability andload-{$page_hook}action hook for administrators.test_register_menu_does_not_hook_on_load_when_user_lacks_capability: Verifiesload-{$page_hook}is not registered when user lacks permissions.test_on_load_hooks_enqueue_assets_action: Verifiesadmin_enqueue_scriptshook registration.test_enqueue_assets_enqueues_scripts_and_styles: Verifies script and style enqueuing including the bundled DataViews fallback style.test_enqueue_assets_does_not_enqueue_dataviews_fallback_if_wp_dataviews_registered: Verifies DataViews fallback style is skipped whenwp-dataviewsis registered in core.test_enqueue_assets_localizes_settings_data: Verifies localized JavaScript configuration object and REST route definitions.test_render_page_renders_container_for_authorized_user: Verifies admin UI container output for authorized administrators.test_render_page_outputs_nothing_for_unauthorized_user: Verifies empty output for unauthorized roles (subscribers).test_render_page_outputs_nothing_when_logged_out: Verifies empty output for guests/logged-out visitors.test_get_provider_metadata_filters_and_formats_connectors: Verifies provider metadata formatting, filtering out non-AI connectors, and distinguishing client vs cloud auth methods.test_get_provider_metadata_falls_back_to_slug_when_name_missing: Verifies fallback to connector slug when display name is missing.test_get_provider_metadata_ignores_invalid_connector_data: Verifies graceful omission of malformed connector registry entries.Use of AI Tools
AI assistance: Yes
Model(s): Gemini 3.8 Flash High
Used for: Analyzing test gaps in the Logging component, scaffolding test structure, and ensuring strict adherence to VIP Go and WordPress coding standards. Final test implementation and assertions were reviewed, refined, and validated by me.
Testing Instructions
npm run typecheck && npm run lint:jstests/Integration/Includes/Logging/AI_Request_Log_PageTest.phppasses cleanly.Changelog Entry