Skip to content

test(search): cover short-query early return and result path - #79

Open
waterlemonnn wants to merge 1 commit into
AgentPostmortem:mainfrom
waterlemonnn:test/search-route-coverage
Open

test(search): cover short-query early return and result path#79
waterlemonnn wants to merge 1 commit into
AgentPostmortem:mainfrom
waterlemonnn:test/search-route-coverage

Conversation

@waterlemonnn

Copy link
Copy Markdown
Contributor

Closes #63.

Newsletter already has `route.test.ts` covering the new/existing/reactivated-subscriber branching (landed in #68), so the remaining gap from this issue was the search route. Added `app/api/search/route.test.ts`:

  • queries under 2 chars return { posts: [] } without calling fetchSearchPosts (also checked the no-query case)
  • a normal query calls fetchSearchPosts with the trimmed query and returns its result
  • agent/severity params are passed through as the filter object the route builds

Test plan

  • npx vitest run — 112/112 pass
  • npx eslint app/api/search/route.test.ts — clean
  • npx tsc --noEmit — clean

Newsletter route already has coverage from AgentPostmortem#68 (new/existing/
reactivated subscriber cases). This adds the missing search half:
queries under 2 chars short-circuit without hitting the DB, and a
normal query passes agent/severity filters through to fetchSearchPosts.
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.

Neither the newsletter nor the search route has a test

1 participant