Skip to content

test: rank deprecated search results below current ones - #2907

Open
Trenyx wants to merge 1 commit into
Redocly:mainfrom
Trenyx:test/search-deprecated-ranking
Open

Trenyx wants to merge 1 commit into
Redocly:mainfrom
Trenyx:test/search-deprecated-ranking

Conversation

@Trenyx

@Trenyx Trenyx commented Nov 25, 2026

Copy link
Copy Markdown

What/Why/How?

If the deprecated weight in SEARCH_SCORE ever flipped sign (or was dropped), search would list a deprecated operation above the current one that replaces it, and readers would land on the old endpoint first. No test would notice: no test compares a deprecated and a current document that match a query equally.

Tests only: one test (+19 lines) in src/services/search/__tests__/engine.test.ts. No change to library code.

The test adds two documents with the same title and text, the first marked deprecated: true (the flag the indexer copies from item meta), searches for their title, and expects the current one first.

Reference

No linked issue: this PR only adds a test.

Tests

On main 6cd4168, Node 22.23.4:

  • CI=true npx vitest run src/services/search/__tests__/engine.test.ts: 44 passed.
  • vitest run (whole unit suite): 3905 passed, 5 skipped, 0 failed.
  • oxlint --max-warnings=0 on the file and tsgo --noEmit --skipLibCheck pass.
  • With deprecated: -40 changed to deprecated: 40 in src/services/search/engine/constants.ts, the whole suite shows exactly one failure, this new test (['list-pets-v1', 'list-pets-v2'] instead of ['list-pets-v2', 'list-pets-v1']).
  • Not run: npm run e2e.
  • No changeset: tests only.

Screenshots (optional)

Check yourself

  • Code is linted
  • Tested
  • All new/updated code is covered with tests

This test was written with Claude Code during a planted-bug run by SK @ Trenyx.

SEARCH_SCORE.deprecated is meant to push deprecated operations down, but
no test compares a deprecated and a current document that match a query
equally, so a flipped or dropped penalty would go unnoticed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Trenyx
Trenyx requested a review from a team as a code owner November 25, 2026 01:53
@ivankropyvnytskyi

Copy link
Copy Markdown
Contributor

Thanks @Trenyx, looks good! I've approved the CI run and will merge once it's green 🙌

This branch has not been deployed

No deployments
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