test(navbar): guard /auth/me display_name rendering - #24
Merged
Conversation
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.
✅ Deploy Preview for criticalbit-web ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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
src/components/navbar.test.tsxwith two MSW-driven regression tests that lock down the navbar'sauth.displayName ?? auth.emailrendering against the recurring "navbar shows steam id" symptom (steam profile name regression #23).serverfromsrc/test/setup.tsso any future test can override MSW handlers per-test.VITE_API_URLto an absolute URL invitest.config.ts— a latent test-infra bug that was causing every/auth/mecall in tests to fail silently (ky/undici rejects relative/api/...URLs; the AuthProvider'stry/catchswallowed it).The actual user-visible bug is server-side (
display_namepopulated 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)display_name→displayNameinauth.tsxmakes the test fail loudly, confirming the guard works