Skip to content

[EDU-18407] test(cypress): add search E2E test suite#469

Open
PedroAntunesCosta wants to merge 55 commits into
mainfrom
test/edu-18407-search-e2e
Open

[EDU-18407] test(cypress): add search E2E test suite#469
PedroAntunesCosta wants to merge 55 commits into
mainfrom
test/edu-18407-search-e2e

Conversation

@PedroAntunesCosta

@PedroAntunesCosta PedroAntunesCosta commented May 27, 2026

Copy link
Copy Markdown
Contributor

What is the purpose of this pull request?

Adds a full Cypress E2E test suite for Help Center search, covering the
current Algolia path and stubbing the upcoming hybrid search (doctype filter)
path.

What problem is this solving?

EDU-18407 — Add Cypress search tests

No automated E2E coverage existed for the search feature. This PR closes
that gap so that the hybrid search rollout (EDU-17906, vtexdocs/helpcenter
PR #456) can land on a branch that already has passing search tests.

Changes

Config / infrastructure

  • cypress.config.cjs — adds env block with HYBRID_SEARCH_ENABLED flag; raises pageLoadTimeout to 60 s (Netlify preview cold-start fix)
  • src/tests/cypress/support/commands.js — adds searchFor, submitSearch (Enter-only; no submit button in SearchInput), and getAutocompleteSuggestions custom commands
  • .github/workflows/e2e-tests.yml — step summary updated to list search suites; MAX_ATTEMPTS raised to 240 (40-min polling window for slow Netlify builds); workflow_dispatch trigger added with deploy_url input to bypass the wait steps when triggering manually against an already-live preview

New specs (all in src/tests/cypress/integration/)

File Tests Status
search-regression.cy.js 5 ✅ passing
search-results.cy.js 4 ✅ passing
search-autocomplete.cy.js 4 ✅ passing
search-locale.cy.js 3 (en, pt, es) ✅ passing
search-pagination.cy.js 3 ✅ passing
search-doctype-filter.cy.js 4 pending describe.skip — blocked on EDU-18406

Bug fix (EDU-18495)

  • src/tests/cypress/integration/sidebar-navigation.cy.js — adds { force: true } to the EN sidebar .click() call to resolve a pre-existing animation flake (was 11/12; now 12/12 ✅)

Selector decisions

  • Search input: [data-cy="search"].first() — Algolia's SearchInput
    has no data-testid; .first() disambiguates the header vs
    hamburger-menu instance
  • Result cards: .searchCardTitle — stable class on SearchCard title Text
  • Autocomplete suggestions: cy.getAutocompleteSuggestions() — centralizes
    the .first().parent().parent().find('a') traversal; no data-cy attribute
    on the dropdown container in @vtexdocs/components

Known pending item

search-doctype-filter.cy.js runs as describe.skip (4 pending, CI green).
The 4 it() calls have name-only stubs — no bodies, no selectors, no
assertions. Unblocked by EDU-18406 (portal-side doctype filter UI); the full
implementation will be introduced in PR #456 when that work lands.

How to manually test

  1. Open a PR on this repo to trigger the E2E Tests workflow automatically.
  2. Confirm CI shows: regression 5/5, results 4/4, autocomplete 4/4,
    locale 3/3, pagination 3/3, sidebar-navigation 12/12, doctype-filter 4 pending.
    Total: 40 passing, 4 pending, 0 failing.

If Netlify is slow and the automated run times out:

  1. Wait until the Netlify dashboard shows the deploy as "Published".
  2. Go to GitHub Actions → E2E Tests → Run workflow, paste the preview URL into deploy_url, and trigger.
  3. The two wait steps are skipped; Cypress runs immediately against the live URL.

Types of changes

  • Bug fix
  • New feature
  • Tests / CI
  • Breaking change

Adds HYBRID_SEARCH_ENABLED env var to cypress config and introduces
searchFor/submitSearch custom commands for the search test specs.
@netlify

netlify Bot commented May 27, 2026

Copy link
Copy Markdown

Deploy Preview for leafy-mooncake-7c2e5e ready!

Name Link
🔨 Latest commit f8de9c4
🔍 Latest deploy log https://app.netlify.com/projects/leafy-mooncake-7c2e5e/deploys/6a2a0aedbc661e0008782265
😎 Deploy Preview https://deploy-preview-469--leafy-mooncake-7c2e5e.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This pull request does not contain a valid label. Please add one of the following labels: ['release-no', 'release-auto', 'release-patch', 'release-minor', 'release-major']

Covers five cases for search with hybrid flag OFF: input presence,
autocomplete dropdown, results URL, result card visibility, and no
hybrid-endpoint console errors.
@PedroAntunesCosta PedroAntunesCosta self-assigned this May 27, 2026
The search components use data-cy="search" (not data-testid="search-input")
and have no data-testid on the autocomplete dropdown or result cards.
Use structural selector for autocomplete items and .searchCardTitle for
result cards (stable className on SearchCard component).

Resolves B-1.
The search input (flex:0) is collapsed until its container is clicked.
Click the parent Flex container first to expand/focus before clear+type.
Also check container visibility in test 1 instead of the collapsed input.
@PedroAntunesCosta PedroAntunesCosta added the release-auto Automatic version bump label May 27, 2026
github-actions[bot]
github-actions Bot previously approved these changes May 27, 2026
The hamburger-menu component also renders a SearchInput in the DOM,
giving 2 [data-cy="search"] elements. Use .first() to target only
the header search input throughout searchFor, submitSearch, and spec.
github-actions[bot]
github-actions Bot previously approved these changes May 27, 2026
The Netlify preview can be slow after several tests run consecutively.
10s pageLoadTimeout is too tight; override to 30s for this spec's visit.
github-actions[bot]
github-actions Bot previously approved these changes May 27, 2026
- search-results.cy.js: 4 tests covering Enter/button submit, card href
  validity, and empty-state via intercept gating
- search-autocomplete.cy.js: 4 tests covering dropdown appearance,
  suggestion click navigation, outside-click dismiss, and See all results
- search-locale.cy.js: 3 tests (en/pt/es) verifying locale reflected in
  URL and results present after locale switch
- search-pagination.cy.js: 3 tests covering infinite-scroll load,
  duplicate-href check, and scroll-accumulation
- search-doctype-filter.cy.js: describe.skip skeleton pending EDU-18406

Selectors use confirmed classes (.searchCardTitle, [data-cy="search"])
from component source — no data-testid attrs exist in Algolia components.
github-actions[bot]
github-actions Bot previously approved these changes May 27, 2026
search-results: drop closest('a') href check — SearchCard wraps Flex not
  <a> with legacyBehavior, so no <a> ancestor exists on result cards
search-autocomplete: replace 'See all results' link check (unreliable,
  depends on Algolia returning >7 hits) with href check on first suggestion
  link (autocomplete items ARE real <a> tags)
search-locale: replace verifyLocale (URL check) with locale button check —
  router.push({pathname:'/search'}) does not preserve locale in the URL
search-pagination: replace closest('a') href uniqueness check with
  new-title-appeared check after scrolling
github-actions[bot]
github-actions Bot previously approved these changes May 27, 2026
cy.switchLocale from '/' gives URL '/pt' (no trailing slash), failing the
command's own include('/pt/') assertion before search is even submitted.
Locale-switching.cy.js works because it starts from an inner doc page.

Replace switchLocale + verifyLocale with direct visit to locale doc page
(/pt/docs/tutorials, /es/docs/tutorials) then submitSearch — same pattern
the existing locale-switching spec uses.
github-actions[bot]
github-actions Bot previously approved these changes May 27, 2026
Replaces describe.skip skeleton with four working tests targeting
SearchFilterTabBar. Viewport set to 1023px (tab bar hidden at >=1024px
per brand-ui 64em breakpoint). Depends on data-testid attributes to be
added to vtexdocs/components feat/hybrid-search branch per
temp/edu-18407/agent-prompt-add-filter-testids.md.
github-actions[bot]
github-actions Bot previously approved these changes May 27, 2026
github-actions[bot]
github-actions Bot previously approved these changes May 28, 2026
github-actions[bot]
github-actions Bot previously approved these changes Jun 9, 2026
…ion-status

Cypress always appends a trailing slash to baseUrl, so
`${baseUrl}/path` produces `https://host//path`. This caused
extra HTTP redirects that slowed the spec down (~3.5 min vs ~30 s)
and intermittently prevented pages from rendering article content.

Remove the redundant leading slash from all three URL/log usages.
github-actions[bot]
github-actions Bot previously approved these changes Jun 9, 2026
…rl (EDU-18407)

- Remove cy.url() assertion from submitSearch — coupled command to navigation
  side-effect, failing specs that submit without a redirect (Rec 6)
- Strip trailing slash from baseUrl in helpcenter-navigation-status.cy.js to
  prevent double-slash URL construction (Rec 7)
github-actions[bot]
github-actions Bot previously approved these changes Jun 9, 2026
…us spec

After T-22 stripped the trailing slash from baseUrl, urlPrefix values like
'announcements/' (no leading slash) produced broken URLs such as
'...netlify.appannouncements/slug'. Ensure urlPrefix always starts with '/'
so page URLs are always correctly formed regardless of baseUrl trailing-slash
state.
github-actions[bot]
github-actions Bot previously approved these changes Jun 9, 2026
Adds Cypress.log() before return false in the global uncaught:exception
handler so Minified React error / invariant / hydration exceptions are
visible in the Cypress command log and CI screenshots instead of being
silently dropped. Suppression logic is unchanged; the log makes it
possible to distinguish a real search-UI crash from a benign hydration
warning without disabling the safety net.
github-actions[bot]
github-actions Bot previously approved these changes Jun 9, 2026
…TODO

Both call sites in sidebar-navigation.cy.js that use { force: true } now
have a comment explaining the animation workaround and referencing the
tracking ticket EDU-18495 for follow-up.
github-actions[bot]
github-actions Bot previously approved these changes Jun 9, 2026
Addresses T-25: two retries cover Netlify Function cold-start flakes
(60 s timeout on first attempt warms the Function; second attempt passes).
Three retries add ~3 min of CI overhead for no additional benefit.
github-actions[bot]
github-actions Bot previously approved these changes Jun 10, 2026
Add a "Pre-warm Netlify Functions and SSR routes" step between the URL
resolution step and the Cypress run. Hits /api/navigation (Netlify Function
cold-start source) and two SSR pages before tests start. Uses --max-time 90
with 3 retries; never exits 1 on failure so a slow warm does not abort CI.
/en/docs/tutorials → /docs/tutorials (aligns with what locale-switching
and search-locale specs actually visit). Add /pt/docs/tutorials and
/es/docs/tutorials — the ISR compute instances for these locales are
separate from the English pool and were the routes failing in CI.
github-actions[bot]
github-actions Bot previously approved these changes Jun 10, 2026
…27/T-28/T-29)

Root cause: Netlify ISR renders cold pages on first request (getStaticProps +
fallback:'blocking'), intermittently exceeding the 60s cy.visit timeout.

- helpcenter-navigation-status: second before() warms each randomly selected
  page via cy.request (90s timeout) before the asserting cy.visit loop
- copy-for-llm: warm EN/ES/PT tutorial URLs at end of before() after slugs resolved
- locale-switching: new before() warms all 7 statically known page URLs
- cypress.config.cjs: pageLoadTimeout 60000 → 120000 as a safety net for
  pages that are slow even after warming
github-actions[bot]
github-actions Bot previously approved these changes Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-auto Automatic version bump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant