Skip to content

test: add unit tests for predictive-document-analysis content utilities#226

Open
fragres wants to merge 1 commit intoDeodat-Lawson:mainfrom
fragres:test/content-utils-coverage
Open

test: add unit tests for predictive-document-analysis content utilities#226
fragres wants to merge 1 commit intoDeodat-Lawson:mainfrom
fragres:test/content-utils-coverage

Conversation

@fragres
Copy link

@fragres fragres commented Mar 1, 2026

Summary

The helper functions in src/app/api/agents/predictive-document-analysis/utils/content.ts are used throughout the predictive analysis pipeline but had no dedicated unit tests, making it easy to introduce regressions silently.

This PR adds a new test file __tests__/api/predictiveDocumentAnalysis/content.test.ts with coverage for all seven exported functions:

Function Cases covered
groupContentFromChunks page headers, empty input, chunk separators
cleanText lowercasing, special-char removal, whitespace trimming
extractKeywords stop-word exclusion, minLength boundary, custom minLength
hasReferencePattern all built-in patterns, case-insensitivity, no-match case
calculateTextSimilarity identical, substring, partial-overlap, disjoint strings
truncateText within limit, over limit, exact limit, default maxLength
hasSpecificIdentifier exhibit/schedule/attachment patterns, generic names, empty string

Test plan

  • pnpm test passes with the new file included
  • No existing tests are broken

The helper functions in utils/content.ts (groupContentFromChunks,
cleanText, extractKeywords, hasReferencePattern, calculateTextSimilarity,
truncateText, hasSpecificIdentifier) had no dedicated unit tests.

Add a test file that covers the main behaviours and edge cases for each
function, making regressions easier to catch when the utilities change.
@vercel
Copy link

vercel bot commented Mar 1, 2026

@fragres is attempting to deploy a commit to the Timothy Lin's projects Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Mar 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pdr-ai-v2 Ready Ready Preview, Comment Mar 2, 2026 7:11am

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.

1 participant