Skip to content

test(search): make /api/search e2e tests self-contained (fix red develop after #52)#53

Merged
line-o merged 1 commit into
eXist-db:developfrom
joewiz:fix/search-cypress-self-contained-fixture
Jun 8, 2026
Merged

test(search): make /api/search e2e tests self-contained (fix red develop after #52)#53
line-o merged 1 commit into
eXist-db:developfrom
joewiz:fix/search-cypress-self-contained-fixture

Conversation

@joewiz

@joewiz joewiz commented Jun 8, 2026

Copy link
Copy Markdown
Member

[This PR was co-authored with Claude Code. -Joe]

Summary

Fix the failing search.cy.js e2e tests that turned develop red after #52, by making them self-contained instead of dependent on the built-in doc app.

Why develop went red

#52 moved /api/search to query the shared site-content Lucene field. But search.cy.js assumed the built-in doc app would be findable (?q=xquery, &app=doc), and the doc app does not populate site-content — so on a bare existdb-openapi install (the CI image) the search returns nothing. Three assertions failed:

1) returns the documented shape …    AssertionError: expected 0 to be above 0
2) wraps matched terms in <mark> …   expected undefined to exist
3) exposes a canonical identifier …  Target cannot be null or undefined

(1) is the root cause — total was 0; (2) and (3) cascade off the empty result set.

Fix

Seed a self-contained fixture rather than relying on the image's content:

  • A before() hook stores a small collection at /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 searches its own corpus, exercising the real shared-field contract: relevance ordering, <mark> highlighting, per-document dedup, offset/limit paging, and the app facet.

This also removes an accidental coupling: the tests had been passing only because the image happened to ship the doc app; 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=xquery returns the 6 fixture docs with <mark> snippets and highlights[], and ?app=cypress-search-test restricts 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.

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 line-o merged commit c194c8d into eXist-db:develop Jun 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants