docs: Update architecture for supabase

test: Add tests for auth workflow
This commit is contained in:
2026-04-12 10:14:44 -04:00
parent 355f3c5dfa
commit c789454810
13 changed files with 900 additions and 14 deletions

View File

@@ -0,0 +1,24 @@
// @vitest-environment node
import { describe, it, expect } from 'vitest'
import { checkAuthRedirect } from '~/utils/auth'
describe('checkAuthRedirect', () => {
it.each(['/', '/login', '/signup', '/auth/callback'])(
'returns null for unauthenticated user on public route: %s',
(path) => {
expect(checkAuthRedirect(null, path)).toBeNull()
}
)
it('returns "/" for unauthenticated user on protected route', () => {
expect(checkAuthRedirect(null, '/boats')).toBe('/')
})
it('returns null for authenticated user on protected route', () => {
expect(checkAuthRedirect({ id: 'user-123' }, '/boats')).toBeNull()
})
it('returns null for authenticated user on public route', () => {
expect(checkAuthRedirect({ id: 'user-123' }, '/')).toBeNull()
})
})