Skip to content

test : added unit tests for og-user-params helpers#2464

Open
tmdeveloper007 wants to merge 1 commit into
Umbrella-io:mainfrom
tmdeveloper007:#2459
Open

test : added unit tests for og-user-params helpers#2464
tmdeveloper007 wants to merge 1 commit into
Umbrella-io:mainfrom
tmdeveloper007:#2459

Conversation

@tmdeveloper007

Copy link
Copy Markdown
Contributor

Closes #2459.

Summary of What Has Been Done:
Added a dedicated vitest test file test/og-user-params.test.ts that pins the behaviour of every pure helper in src/lib/og-user-params.ts. The tests are deterministic (no network, no Date.now) and use the same describe/it/expect style as the rest of the suite.

Changes Made:

  • New file: test/og-user-params.test.ts (14 tests, all passing under npm test).
  • Coverage for the public normalizeOgUserParams(searchParams: URLSearchParams) export, including:
    • The happy path (all inputs supplied, expected avatar URL composition).
    • Missing or invalid username falling back to "developer".
    • name falling back to username when missing.
    • topLang falling back to "JavaScript" when missing.
    • name and topLang truncating at the MAX_NAME_LENGTH (48) and MAX_LANGUAGE_LENGTH (24) caps.
    • streak and commits returning 0 for empty / non-numeric / negative inputs.
    • streak and commits flooring decimal values.
    • streak and commits clamping at MAX_METRIC_VALUE (999999) and accepting the boundary value 999999.

Impact it Made:
Locks the contract for the public OG user-card query-param normaliser used by the /api/og/user route. Future refactors of the avatar URL composition, the fallback chain, or the metric clamping will surface a test failure rather than a silent UI regression. No production code was modified; the change is limited to one new test file.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:testing GSSoC type bonus: tests (+10 pts) labels Jun 15, 2026
@github-actions

Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Umbrella-io — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution type:testing GSSoC type bonus: tests (+10 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test : add unit tests for og-user-params helpers

1 participant