Skip to content

feat: Featured Snippets, search and filtering for Community page#383

Open
code-snippets-bot wants to merge 29 commits into
core-betafrom
feat/community-page
Open

feat: Featured Snippets, search and filtering for Community page#383
code-snippets-bot wants to merge 29 commits into
core-betafrom
feat/community-page

Conversation

@code-snippets-bot
Copy link
Copy Markdown
Contributor

@code-snippets-bot code-snippets-bot commented May 5, 2026

Summary

Community Snippets page now shows featured snippets on initial load and supports server-side filtering with category, type, and status dropdowns. Filter options come from the full query result via independent facets.

Featured Snippets

  • Loads featured snippets when no search query active
  • Paginated via server-side page/per_page params
  • Featured heading visible above results

Server-Side Filters

  • category, type, status params sent to cloud API (ID-based)
  • Filter dropdowns built from available_filters response header (X-WP-Filters)
  • Independent facets: active filter dimension keeps all options, other dimensions narrow
  • Filters reset to page 1 on change

New Endpoints Proxied

  • GET /cloud/types (languages from cloud API, 1-day transient)
  • GET /cloud/categories (categories from cloud API, 1-day transient)

Cloud Snippet Model

  • Added language field to Cloud_Snippet (extracted from API response language.name)
  • Cloud_Snippets picks up available_filters from normalized API response

UI

  • Type dropdown added to search filters (alongside category and status)
  • Spinner replaces search button label during loading
  • Consistent heading and filters visible on empty results

Test plan

  • Featured snippets load on community page with no search
  • Type filter narrows results, categories/statuses adapt
  • Screen options per_page respected
  • Pagination works with filters active
  • Search clears featured and applies filters

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.
Copy link
Copy Markdown
Contributor

@louiswol94 louiswol94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@louiswol94 louiswol94 added the run-tests Trigger automated tests label May 5, 2026
@louiswol94
Copy link
Copy Markdown
Contributor

louiswol94 commented May 5, 2026

PlayWright tests are failing

@imantsk imantsk changed the title feat: Featured Snippets integration for Community page feat: Featured Snippets + server-side filters + type dropdown for Community page May 11, 2026
@imantsk imantsk changed the title feat: Featured Snippets + server-side filters + type dropdown for Community page feat: Featured Snippets, search and filtering for Community page May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-tests Trigger automated tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants