[EDU-18407] test(cypress): add search E2E test suite#469
Open
PedroAntunesCosta wants to merge 30 commits into
Open
[EDU-18407] test(cypress): add search E2E test suite#469PedroAntunesCosta wants to merge 30 commits into
PedroAntunesCosta wants to merge 30 commits into
Conversation
Adds HYBRID_SEARCH_ENABLED env var to cypress config and introduces searchFor/submitSearch custom commands for the search test specs.
❌ Deploy Preview for leafy-mooncake-7c2e5e failed. Why did it fail? →
|
Covers five cases for search with hybrid flag OFF: input presence, autocomplete dropdown, results URL, result card visibility, and no hybrid-endpoint console errors.
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.
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.
The Netlify preview can be slow after several tests run consecutively. 10s pageLoadTimeout is too tight; override to 30s for this spec's visit.
- 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.
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
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.
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.
cy.on('window:console') is not a Cypress event — the handler never fired.
Replaced with cy.spy(win.console, 'error') via onBeforeLoad so the spy
is active before page JS executes. Test now manages its own cy.visit().
… in URL (EDU-18407) SearchInput has no submit button — Enter is the only submission mechanism (confirmed in @vtexdocs/components search-box.tsx). Remove the via param and its broken button branch. Replace the 'submits via search button' test with 'search URL includes the submitted keyword' (asserts keyword=orders in URL, verifying the router query param name not already covered by the Enter test).
…spec (EDU-18407)
All three scroll tests now gate on the Algolia network request via
cy.intercept/cy.wait('@algoliaNextPage') instead of fixed 1500ms delays.
Replace 5 inline .parent().parent().find('a') chains with a single
cy.getAutocompleteSuggestions() command. Fragility comment in
commands.js references pr-469-review.md Recommendation 5.
MAX_ATTEMPTS 150 → 240 (240 × 10 s = 40 min). Three consecutive V-16 CI runs failed at ~26 min with the deploy still building — P99 worst case exceeds the old 25-min hard limit.
…U-18407) Adds a manual trigger so Cypress can run against a known-live preview URL when Netlify builds are stuck or failing. Both wait steps are skipped on workflow_dispatch; a resolve-url step picks the URL from the input or from the normal wait-for-netlify-preview output depending on the trigger. Also improves the timeout error message to use ::error:: annotation and explain that it's an infrastructure issue with recovery options.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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— addsenvblock withHYBRID_SEARCH_ENABLEDflag; raisespageLoadTimeoutto 60 s (Netlify preview cold-start fix, EDU-18407)src/tests/cypress/support/commands.js— addssearchForandsubmitSearchcustom commands.github/workflows/e2e-tests.yml— step summary updated to list search suitesNew specs (all in
src/tests/cypress/integration/)search-regression.cy.jssearch-results.cy.jssearch-autocomplete.cy.jssearch-locale.cy.jssearch-pagination.cy.jssearch-doctype-filter.cy.jsdescribe.skip— unblocked by vtexdocs/components PR #82Bug 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
[data-cy="search"].first()— Algolia'sSearchInputhas no
data-testid;.first()disambiguates the header vshamburger-menu instance
.searchCardTitle— stable class onSearchCardtitleText[data-testid="doctype-filter-tab*"]attributes —to be added to
SearchFilterTabBarin vtexdocs/components PR Adjust pagination behavior #82Known pending item
search-doctype-filter.cy.jsruns asdescribe.skip(4 pending, CI green)until vtexdocs/components PR #82 adds
data-testidattributes toSearchFilterTabBar. The full implementation is preserved on this branchfor reuse once those attributes land.
How to manually test
E2E Testsworkflow.locale 3/3, pagination 3/3, sidebar-navigation 12/12, doctype-filter 4 pending.
Total: 40 passing, 4 pending, 0 failing.
Types of changes