test: coverage for partyDisplayName and analytics path helpers#70
Open
doolin wants to merge 1 commit into
Open
test: coverage for partyDisplayName and analytics path helpers#70doolin wants to merge 1 commit into
doolin wants to merge 1 commit into
Conversation
Contributor
Author
|
I will continue with low-churn coverage for now, then having a good base, gradually start adding coverage to files with more historical churn. |
18 unit tests against three pure helpers — no React rendering, no fetch mocking, no provider wrappers: - src/utils/partyDisplay.ts — partyDisplayName() (7 cases). Tests the undefined-input fallback, string-uuid passthrough, and the name → short-name → uuid resolution order. - src/hooks/useCookieConsent.ts — sanitizedAnalyticsPath() (6 cases) and viewerAnalyticsPath() (5 cases). Tests the 'url' parameter masking, search-param preservation, hash handling, and viewId injection. Both target files have low historical churn (1 and 2 commits each), so the tests should remain stable across ongoing refactors. 23 tests passing on a clean checkout of main after npm ci. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2b0e123 to
e9c5721
Compare
Contributor
Author
|
Rebased onto current |
pkothare
approved these changes
Jun 5, 2026
pkothare
approved these changes
Jun 5, 2026
Contributor
Author
|
ty |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds 18 unit tests against three pure helpers. No React rendering,
no fetch mocking, no provider wrappers — just pure functions in,
expected values out.
Helpers exercised:
undefined-input fallback, string-uuid passthrough, the
`name → short-name → uuid` resolution order, and the empty-string
name edge case.
(6 cases) — the `url` parameter masking, other-param preservation,
hash handling, and the no-search-no-hash passthrough.
(5 cases) — `view` parameter injection, `url` masking, overwrite
of any existing `view` value.
Why these helpers
Both source files have low historical churn (1 and 2 commits each)
so the tests should stay valid across ongoing refactors. The two
analytics-path functions also encode a privacy-relevant invariant —
that loaded document URLs never leave the browser as analytics
data — which is worth locking in with assertions.
Independence
No dependency on the coverage-tooling PR (#68). These tests run
under the existing `npm test` (vitest run from #65) without any
config changes.
Test plan