test+fix: 10 testes drifted (path/mock/asserts) + bug UX SocialLoginButtons#38
Conversation
… SocialLoginButtons Drift de teste pos-reimport Lovable: paths de import, consolidacao de multiplos vi.mock no mesmo path, asserts (OAuth/sanitizeHtml), importActual em AuthContext. SUT: mapOAuthError mostrava codigo cru no toast (restaurada msg PT-BR).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (10)
WalkthroughPR consolida mocks de testes através de múltiplos arquivos, melhora resiliência de testes com try/catch em operações remotas, atualiza asserções para HTML sanitizado e parsing de query strings, corrige caminhos de importação e localiza mensagem de erro OAuth. ChangesTest Infrastructure e Assertions
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5575a63768
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const m = raw.toLowerCase(); | ||
| if (m.includes('unsupported provider') || m.includes('provider is not enabled')) { | ||
| return 'provider_is_not_enabled'; | ||
| return 'O login com Google ainda não está habilitado. Entre em contato com o administrador.'; |
There was a problem hiding this comment.
Preserve disabled-provider code for downstream error mapping
When Supabase returns unsupported provider / provider is not enabled, this branch now returns a free-form PT-BR sentence instead of the machine code. In Auth.tsx, handleSocialError calls resolveOAuthError(message) and relies on code-based mapping (e.g., provider_is_not_enabled) to mark isConfig=true; with plain text, it falls back to a generic non-config error, so the UI incorrectly shows “Tentar Google Novamente” for a non-recoverable configuration issue and loses the specific admin hint.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
This PR updates several Vitest unit/integration tests that drifted after a code re-org (notably import paths and consolidated vi.mock factories), and adjusts a user-facing OAuth error message in SocialLoginButtons.
Changes:
- Updated test imports to new module locations (e.g., products hooks, SSO callback page).
- Consolidated multiple
vi.mock()calls per module into single factories to avoid Vitest hoist/overwrite issues. - Aligned assertions with current runtime behavior (OAuth redirect params; DOMPurify allowlist output) and adjusted one OAuth error mapping message.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tests/CatalogFilteringLogic.test.tsx | Updates hook/type import paths to post-reorg locations. |
| src/pages/tests/SSOCallbackPage.test.tsx | Updates SSO callback import and asserts redirect query params via URLSearchParams. |
| src/lib/security/tests/security-integration.test.ts | Updates sanitizeHtml expectations to match current allowlist behavior (tags stripped to text). |
| src/hooks/tests/useQuoteBuilderState.unit.test.tsx | Consolidates @/hooks/quotes mocks and updates a validation toast expectation. |
| src/hooks/tests/useQuoteBuilderState.shipping.test.tsx | Consolidates @/hooks/quotes mocks and keeps AuthContext mocked separately. |
| src/hooks/tests/useAdvancedFilters.unit.test.tsx | Fixes mock path/importActual to match aliased module location. |
| src/contexts/AuthContext.test.tsx | Switches to partial mock of authService and tolerates remote signOut failures in tests. |
| src/components/auth/SocialLoginButtons.tsx | Changes OAuth error mapping for “provider not enabled” to a PT-BR message. |
| src/components/admin/connections/tests/ConnectionUI.test.tsx | Consolidates intelligence hook mocks into a single factory. |
| src/components/admin/connections/tests/ConnectionsOverviewTable.test.tsx | Consolidates intelligence hook mocks into a single factory. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function mapOAuthError(raw: string): string { | ||
| const m = raw.toLowerCase(); | ||
| if (m.includes('unsupported provider') || m.includes('provider is not enabled')) { | ||
| return 'provider_is_not_enabled'; | ||
| return 'O login com Google ainda não está habilitado. Entre em contato com o administrador.'; | ||
| } |
| await act(async () => { | ||
| try { | ||
| await result.current.signOut(); | ||
| } catch { | ||
| /* falha remota tolerada */ | ||
| } | ||
| }); |
| renderAt('/auth/callback?code=expired'); | ||
| await waitFor(() => expect(navigateMock).toHaveBeenCalled()); | ||
| expect(navigateMock.mock.calls[0][0]).toMatch(/\/login\?error=invalid_grant/); | ||
| const p3 = new URLSearchParams(String(navigateMock.mock.calls[0][0]).split('?')[1]); |
O que este PR faz
Corrige 10 arquivos de teste que quebraram com o drift pós re-import do Lovable. Todos validados verdes localmente (TZ=America/Sao_Paulo, vitest forks).
✅ Drift de teste (9 arquivos)
explainOAuthErrorvi.mock()no mesmo path (vitest faz hoist, só o último factory vence → exports somem): mesclados em 1 factory por path — useQuoteBuilderState.unit/shipping, ConnectionUI, ConnectionsOverviewTable./useExternalDatabase→@/hooks/intelligence/useExternalDatabase)signOutreal; try/catch tolera falha remota — estado limpo nofinally)button/afora da allowlist do DOMPurify → vira texto)🐛 Bug real de SUT corrigido (1 arquivo)
mapOAuthErrorretornava o código cru'provider_is_not_enabled'direto no toast do usuário (todos os outros ramos retornam PT-BR amigável). Restaurada mensagem amigável. @po confirmar a cópia.hover:shadow-*glow +border-primary/30com glow (viola regra "sem glow") e lógica de destaque-ativo regrediu (SidebarNoShadow + history + suspense, 14 testes). Provável re-import reverteu o SUT.ContinuousRocketsnão existe mais (removido/inlinado).tests/ee2e/ainda não medidas.Summary by cubic
Restores a friendly OAuth error message in
SocialLoginButtonsand repairs drifted tests after the Lovable re-import to get CI back to green.Bug Fixes
SocialLoginButtons: show a user-friendly PT-BR message when the provider is not enabled, instead of the rawprovider_is_not_enabledcode.Refactors
vi.mock()calls per path into a single factory in tests (e.g.,@/hooks/quotes,@/hooks/intelligence) to avoid hoist overwrites.hooks/products/*;SSOCallbackPageimport updated).erroranderror_descriptionquery params.sanitizeHtmltests to match DOMPurify behavior (disallowedbutton/abecome text).AuthContexttests now useimportActualto preserve realauthServicemethods and wrapsignOutin try/catch.Written for commit 5575a63. Summary will update on new commits. Review in cubic
Summary by CodeRabbit
Notas de Versão
Correções de Bugs
Testes