test(app): identity step — auth store, locale sync, login/signup, guards, shell, dashboard, account
- tests/helpers/fakeSupabase: in-memory auth events + profiles/profile_roles builder - validation schemas and safeNextPath; classifyAuthError mapping (packages/supabase) - LoginRoute (unavailable, validation, next path, phrased failure, OAuth buttons, show password) - SignupRoute (policy, mismatch, metadata + redirect, user exists) - RequireAuth / RedirectIfSignedIn, AppLayout (nav, active, drawer, sign out), Dashboard, Account forms
This commit is contained in:
1 parent
c517ea267b
commit
aa1985eead
11 files changed
+993
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import type { AuthError } from '@supabase/supabase-js'
|
||||
import { classifyAuthError } from '../src/auth'
|
||||
|
||||
function err(patch: Partial<AuthError> & { code?: string }): AuthError {
|
||||
return { name: 'AuthApiError', message: 'm', ...patch } as AuthError
|
||||
}
|
||||
|
||||
describe('classifyAuthError', () => {
|
||||
it('maps GoTrue codes to the closed kinds the UI phrases', () => {
|
||||
expect(classifyAuthError(err({ code: 'invalid_credentials', status: 400 }))).toBe('invalid_credentials')
|
||||
expect(classifyAuthError(err({ code: 'email_not_confirmed', status: 400 }))).toBe('email_not_confirmed')
|
||||
expect(classifyAuthError(err({ code: 'user_already_exists', status: 422 }))).toBe('user_exists')
|
||||
expect(classifyAuthError(err({ code: 'weak_password', status: 422 }))).toBe('weak_password')
|
||||
expect(classifyAuthError(err({ code: 'otp_expired', status: 403 }))).toBe('link_expired')
|
||||
expect(classifyAuthError(err({ code: 'bad_code_verifier', status: 400 }))).toBe('link_expired')
|
||||
})
|
||||
|
||||
it('falls back on the HTTP status, then network, then unknown', () => {
|
||||
expect(classifyAuthError(err({ status: 429 }))).toBe('rate_limited')
|
||||
expect(classifyAuthError(err({ status: 400, message: 'Invalid login credentials' }))).toBe('invalid_credentials')
|
||||
expect(classifyAuthError(err({ status: 0 }))).toBe('network')
|
||||
expect(classifyAuthError(err({ status: 500, code: 'unexpected_failure' }))).toBe('unknown')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user