test(search): make /api/search e2e tests self-contained (fix red develop after #52)#53
Merged
line-o merged 1 commit intoJun 8, 2026
Conversation
The search.cy.js suite assumed the built-in `doc` app would be findable via /api/search (?q=xquery, &app=doc). Since /api/search now queries the shared `site-content` Lucene field — which the `doc` app does not populate — a bare existdb-openapi install (the CI image) returns no results, so three assertions failed (`expected 0 to be above 0`, then the <mark> and uri assertions cascaded off the empty result set). This is what turned develop red after eXist-db#52 merged. Seed a self-contained fixture instead: a `before()` hook stores a small collection under /db/apps/cypress-search-test with a `site-content` index (6 <page> docs containing "xquery" across two sections) and reindexes, via admin XQuery through /api/query; `after()` removes it. The suite now searches its own corpus rather than depending on the image's `doc` app, and exercises the real shared-field contract (relevance, <mark> highlighting, dedup, offset/limit paging, and the app facet). Verified end-to-end on a live existdb-openapi instance: the setup runs via /api/query, ?q=xquery returns the 6 fixture docs with <mark> snippets and highlights, and ?app=cypress-search-test restricts to the fixture. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
line-o
approved these changes
Jun 8, 2026
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.
[This PR was co-authored with Claude Code. -Joe]
Summary
Fix the failing
search.cy.jse2e tests that turneddevelopred after #52, by making them self-contained instead of dependent on the built-indocapp.Why develop went red
#52 moved
/api/searchto query the sharedsite-contentLucene field. Butsearch.cy.jsassumed the built-indocapp would be findable (?q=xquery,&app=doc), and thedocapp does not populatesite-content— so on a bare existdb-openapi install (the CI image) the search returns nothing. Three assertions failed:(1) is the root cause —
totalwas 0; (2) and (3) cascade off the empty result set.Fix
Seed a self-contained fixture rather than relying on the image's content:
before()hook stores a small collection at/db/apps/cypress-search-testwith asite-contentindex — 6<page>docs containing "xquery" across two sections — and reindexes, via admin XQuery through/api/query.after()removes it.<mark>highlighting, per-document dedup,offset/limitpaging, and theappfacet.This also removes an accidental coupling: the tests had been passing only because the image happened to ship the
docapp; several content assertions were in fact passing vacuously on an empty result set once the field changed.Verification
Run end-to-end on a live existdb-openapi instance: the setup runs via
/api/query,?q=xqueryreturns the 6 fixture docs with<mark>snippets andhighlights[], and?app=cypress-search-testrestricts to the fixture. The other 10 specs (db, query, packages, parity, site, system, users, langservice, query_scope, query_pool_reuse) are unaffected.Note
Surfaced because #52 was merged with this CI already red. This PR is the fix-forward; with it,
develop's Cypress run goes green again.