Skip to content

test(server): unit tests for parseResponse (mention/citation/visibility scoring) - #251

Merged
gkhngyk merged 1 commit into
ansvisor:mainfrom
Pallavikumarimdb:test/unit-tests-for-parseResponse
Jun 13, 2026
Merged

gkhngyk merged 1 commit into
ansvisor:mainfrom
Pallavikumarimdb:test/unit-tests-for-parseResponse

Conversation

@Pallavikumarimdb

Copy link
Copy Markdown
Contributor

Summary

This PR implements unit tests for parseResponse and its helper countBrandMentions in server/src/lib/response-parser.js.

Changes Made

  • Added server/src/lib/response-parser.test.js covering:
    • Brand mention count: Case-insensitive domain and name matching, and verification of URL stripping to prevent double-counting.
    • Citation count: Case-insensitive matches against citation URLs and single count consolidation for multi-domain matching.
    • Visibility score: Scoring correctness (0-100) including sentiment bonuses and cap rules.
    • Competitor mentions: Verification of per-competitor metrics, handles empty competitor domains.
    • Edge cases: Zero mentions, empty texts, and empty citations.

Related issue

Closes #243

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

@Pallavikumarimdb
Pallavikumarimdb marked this pull request as ready for review June 13, 2026 11:56

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified locally: 13/13 tests pass, eslint + prettier clean. Checked every assertion against response-parser.js — mention word-boundary counting, citation break-once logic, visibility score components/caps, and competitor scoring all match the implementation exactly. Excellent, well-documented coverage. Thanks!

@gkhngyk
gkhngyk merged commit c111d45 into ansvisor:main Jun 13, 2026
3 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.

test(server): unit tests for parseResponse (mention/citation/visibility scoring)

2 participants