feat: Featured Snippets integration for Community page#383
feat: Featured Snippets integration for Community page#383code-snippets-bot wants to merge 7 commits intocore-betafrom
Conversation
Add get_featured_snippets() to Cloud_API that fetches from the cloud /api/v1/featured endpoint with transient caching derived from the cached_until response field. Add /cloud/featured REST route to expose featured snippets to the frontend.
Load featured snippets on the Community Cloud page when no search query is active. The frontend context fetches from the /cloud/featured REST endpoint on mount and displays results under a "Featured Snippets" heading. When the user performs a search, normal search behaviour takes over. Add PHPUnit tests covering transient caching, cache-hit bypass, and graceful fallback on HTTP errors.
Add 3 additional PHPUnit tests: TTL respects cached_until, missing data key returns empty result, and transient stores Cloud_Snippets instance. Add Playwright E2E spec for community cloud page covering page load, featured heading display, and search override behavior.
There was a problem hiding this comment.
This PR is clean!
The only suggestion I can make is to mock the responses via Playwright page.route() + route.fulfill() with fixed JSON and X-WP-Total / X-WP-TotalPages headers. That avoids depending on a live cloud/API, removes flakiness from timeouts and env differences, and lets us assert the featured heading, row content, and “search hides featured” etc deterministically. Happy for this to land as a follow-up.
|
PlayWright tests are failing |
Playwright Test FailureOne or more Playwright targets failed in this workflow run. See all Playwright errors (click to expand)Affected Playwright test: Affected Playwright test: Affected Playwright test: Affected Playwright test: Affected Playwright test: Affected Playwright test: Affected Playwright test: Affected Playwright test: Affected Playwright test: Affected Playwright test: Affected Playwright test: Affected Playwright test: Affected Playwright test: Affected Playwright test: Affected Playwright test: Affected Playwright test: Affected Playwright test: Affected Playwright test: Affected Playwright test: Affected Playwright test: Affected Playwright test: Affected Playwright test: Please review the failing jobs and fix the issues before merging. |
Re-opening PR #341 after branch rename. Plugin-side integration for the new Featured Snippets cloud endpoint. Community Snippets page shows featured snippets on initial load.
Original PR: #341
Summary
Plugin-side integration for the new Featured Snippets cloud endpoint. Community Snippets page now shows featured snippets on initial load (no search active).
New/modified files
get_featured_snippets(): callsGET /api/v1/public/featured, transient cache with TTL fromcached_until, graceful fallback on errorcloud/featuredKey decisions
cached_until(min 1 hour floor)Tests