Skip to content

test(navbar): guard /auth/me display_name rendering - #24

Merged
amrtgaber merged 1 commit into
mainfrom
test/navbar-displayname-regression
May 23, 2026
Merged

test(navbar): guard /auth/me display_name rendering#24
amrtgaber merged 1 commit into
mainfrom
test/navbar-displayname-regression

Conversation

@amrtgaber

Copy link
Copy Markdown
Contributor

Summary

  • Adds src/components/navbar.test.tsx with two MSW-driven regression tests that lock down the navbar's auth.displayName ?? auth.email rendering against the recurring "navbar shows steam id" symptom (steam profile name regression #23).
  • Exports server from src/test/setup.ts so any future test can override MSW handlers per-test.
  • Pins VITE_API_URL to an absolute URL in vitest.config.ts — a latent test-infra bug that was causing every /auth/me call in tests to fail silently (ky/undici rejects relative /api/... URLs; the AuthProvider's try/catch swallowed it).

The actual user-visible bug is server-side (display_name populated with SteamID64); upstream issue filed at ag-tech-group/criticalbit-auth-api#26. This PR is the consumer-side guard — it does not close #23.

Test plan

  • pnpm test:run — all 3 tests pass (1 existing + 2 new)
  • pnpm lint — no new warnings (4 pre-existing in unrelated files)
  • pnpm build — passes (ran via husky pre-commit)
  • Mutation check: temporarily renaming display_namedisplayName in auth.tsx makes the test fail loudly, confirming the guard works
  • CI green

Locks down the JSON field name, the AuthProvider state-setter chain, and
the navbar fallback so the recurring "navbar shows steam id" symptom can't
silently come back through a frontend refactor. The actual cause of #23
lives in the auth API (see ag-tech-group/criticalbit-auth-api#26); this is
the consumer-side guard.

Two supporting changes the new test depends on:

- Export `server` from src/test/setup.ts so tests can override MSW handlers
  per-test via `server.use(...)`.
- Pin VITE_API_URL to an absolute URL in vitest.config.ts. Without it
  ky/undici reject the relative /api/... URL as unparseable, MSW never
  intercepts, and auth.tsx's try/catch swallows the error — every
  /auth/me call was silently failing in tests.

Verified the guard catches the regression via mutation: renaming
`display_name` to `displayName` in auth.tsx makes the test fail loudly.

Refs #23.
@netlify

netlify Bot commented May 23, 2026

Copy link
Copy Markdown

Deploy Preview for criticalbit-web ready!

Name Link
🔨 Latest commit 8e1a1b5
🔍 Latest deploy log https://app.netlify.com/projects/criticalbit-web/deploys/6a11cb95fd1b3a0009fb7185
😎 Deploy Preview https://deploy-preview-24--criticalbit-web.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@amrtgaber
amrtgaber merged commit 7f52ff2 into main May 23, 2026
6 checks passed
@amrtgaber
amrtgaber deleted the test/navbar-displayname-regression branch May 23, 2026 15:54
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.

steam profile name regression

1 participant