Closed ryanwelcher closed 2 years ago
Related to #174, the dashboard details view already supports these kind of "virtual" entities like archive pages - we only need to update the search endpoint to support it 👍
Thanks @ivankruchkoff ! The IB looks good, but we should add tests for the new endpoint via the controller class as we have for others (see REST_*_ControllerTest
s).
Thanks @ivankruchkoff – I think we should bump the estimate for the added tests but otherwise
IB ✅
Currently, any URIs that are entered to the input must resolve to a related piece of content, or "No results found" are displayed. In the case of directly entering valid URIs that don't resolve such as tag archive or the homepage when there is no Page assigned.
The was discovered while working on #1434 and will be more pronounced with the work done there, as now the View Data button is not enabled unless there is a matched piece of content.
We should be able to submit valid URIs directly as long as they match the site domain.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Google\Site_Kit\Core\Util\REST_Entity_Search_Controller
, which has aregister
method that adds an additional REST endpointcore/search/data/entity-search
.core/search/data/post-search
endpoint, with a few differences, as listed below.id
title
url
type
Entity_Factory::create_entity_for_post
).Plugin
main class.core/search/data/post-search
should be switched to the new endpoint instead, including the updated response format of course.core/search/data/post-search
endpoint should be removed.Implementation Brief
Create a new file
includes/Core/Util/includes/Core/Util/REST_Entity_Search_Controller.php
with a classGoogle\Site_Kit\Core\Util\REST_Entity_Search_Controller
.Add a
register()
function which adds anew REST_Route
core/search/data/entity-search
based oncore/search/data/post-search
from the following: https://github.com/google/site-kit-wp/blob/4713411/includes/Core/REST_API/REST_Routes.php#L171-L222The returned value will be an array of entities, see the AC for the format. The entities will be fetched either via
create_entity_for_post()
or from the call toget_reference_entity_from_url()
: https://github.com/google/site-kit-wp/blob/4713411/includes/Core/Util/Entity_Factory.php#L169-L186Call the
register()
function of the new class in theincludes/Plugin.php
file: https://github.com/google/site-kit-wp/blob/4713411/includes/Plugin.php#L176-L194Update
js/components/PostSearcherAutoSuggest.js
to use the new endpoint.Remove the no longer needed REST Route: https://github.com/google/site-kit-wp/blob/4713411/includes/Core/REST_API/REST_Routes.php#L171-L222
Test Coverage
phpunit/integration/Core/Util/includes/Core/Util/REST_Entity_Search_ControllerTest.php
, looking at any of theREST_*_ControllerTest
files for reference.Visual Regression Changes
QA Brief
http://sitekit.10uplabs.com/?cat=1
orhttp://sitekit.10uplabs.com/category/uncategorized/
core/search/data/entity-search
meets AC.Changelog entry