Skip to content

Add reranker result-mapping edge-case tests (#224) - #226

Merged
wpak-ai merged 1 commit into
cppalliance:mainfrom
timon0305:feat/reranker-edge-case-tests-224
Jul 16, 2026
Merged

Add reranker result-mapping edge-case tests (#224)#226
wpak-ai merged 1 commit into
cppalliance:mainfrom
timon0305:feat/reranker-edge-case-tests-224

Conversation

@timon0305

@timon0305 timon0305 commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Adds the missing edge-case tests for rerankResults result mapping (src/core/pinecone/rerank.ts). The suite previously covered only the happy path, empty input, and the rerank-throws fallback.

New tests:

  • Empty data array with a non-empty input returns empty reranked results with degraded: false and no degradation_reason.
  • Absent data (response is {}) returns empty reranked results with degraded: false.
  • A rerank item with no document maps to a result with empty id/content/metadata and reranked: true instead of throwing.
  • Duplicate documents in the output map to one SearchResult per data item, with the fields preserved on each.

Each test asserts the mapped SearchResult fields (id, content, score, metadata, reranked). Also extracted a small makePc helper so the repeated pc cast lives in one place.

This covers the live document-mapping path (returnDocuments: true). The index-based remap cases (out-of-range index) are tracked in #227, gated on rerank moving to returnDocuments: false, since there is no index-remap code to exercise today.

Test-only change. rerank tests 7/7 pass, format:check and typecheck clean.

Closes #224.

Summary by CodeRabbit

  • Tests
    • Expanded coverage for reranking when responses are empty or missing expected data.
    • Added validation for items without documents, including safe default values.
    • Added coverage for duplicate documents and consistent result mapping.
    • Simplified test setup for improved maintainability.

Add tests for empty and absent rerank data (non-empty input still returns
empty results, degraded=false), a data item with no document (maps to empty
id/content instead of throwing), and duplicate documents (one result per
data item). Each asserts the mapped SearchResult fields. Also extract a
makePc helper to drop the repeated pc cast across the file.

Closes cppalliance#224.
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The rerank test suite adds a shared mock-construction helper and cases for empty or absent data, missing documents, and duplicate documents while preserving existing assertions.

Changes

Rerank mapping test coverage

Layer / File(s) Summary
Rerank response mapping coverage
src/core/pinecone/rerank.test.ts
Adds shared Pinecone mock setup and tests empty responses, missing documents, and duplicate documents with explicit result-field assertions.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: wpak-ai, jonathanmldev

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The new tests cover empty or absent data, missing documents, duplicate documents, and mapped SearchResult fields as requested.
Out of Scope Changes check ✅ Passed The diff stays within the test file and a small helper extraction, with no unrelated code changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the new reranker result-mapping edge-case tests.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@bd94c14). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #226   +/-   ##
=======================================
  Coverage        ?   85.61%           
=======================================
  Files           ?       47           
  Lines           ?     2488           
  Branches        ?      857           
=======================================
  Hits            ?     2130           
  Misses          ?      357           
  Partials        ?        1           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wpak-ai
wpak-ai merged commit 98d0164 into cppalliance:main Jul 16, 2026
12 checks 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.

Add reranker result-mapping edge-case tests

3 participants