You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(server): unit tests for parseResponse (mention/citation/visibility scoring) #243
parseResponse (and its helper countBrandMentions) in server/src/lib/response-parser.js is a pure function — it takes a model response plus brand/competitor metadata and computes mention count, citation count, sentiment passthrough, a 0–100 visibility score, and per-competitor mentions. No network, no Redis, no Supabase.
This is exactly the half of the manual test-tracking.js smoke script (see #240) that can be tested for free: mock/skip the paid OpenAI call and feed the parser fixtures instead. It makes a good first concrete server test — the same spirit as the web-side toCsv/classifyDomain tests (#196, #198).
Colocate server/src/lib/response-parser.test.js and cover the pure behavior with fixtures:
Brand mention count — counts brand.brandName and each brand.domains entry; verify URL stripping prevents double-counting a domain that also appears inside a citation URL.
Citation count — case-insensitive domain match against citations[].url; counts a citation once even if multiple domains match.
Visibility score — a few representative { mentionCount, citationCount, totalCitations, sentiment } inputs map to expected 0–100 outputs; sentiment affects the result.
Competitor mentions — each competitor gets its own mention/citation/score; missing comp.domain is handled.
Edge cases — empty text, empty citations, zero mentions.
Activity