[API Node] Set auth persistence in local stoarge (#3514)

This commit is contained in:
Christian Byrne
2025-04-19 11:15:07 +08:00
committed by GitHub
parent fbc6665ff4
commit 9cd11261f9
2 changed files with 15 additions and 1 deletions

View File

@@ -16,7 +16,9 @@ vi.mock('firebase/auth', () => ({
onAuthStateChanged: vi.fn(),
signInWithPopup: vi.fn(),
GoogleAuthProvider: vi.fn(),
GithubAuthProvider: vi.fn()
GithubAuthProvider: vi.fn(),
browserLocalPersistence: 'browserLocalPersistence',
setPersistence: vi.fn().mockResolvedValue(undefined)
}))
describe('useFirebaseAuthStore', () => {
@@ -64,6 +66,13 @@ describe('useFirebaseAuthStore', () => {
expect(store.error).toBe(null)
})
it('should set persistence to local storage on initialization', () => {
expect(firebaseAuth.setPersistence).toHaveBeenCalledWith(
mockAuth,
firebaseAuth.browserLocalPersistence
)
})
it('should properly clean up error state between operations', async () => {
// First, cause an error
const mockError = new Error('Invalid password')