forked from cardosofelipe/fast-next-template
Refactor to enforce AuthContext usage over useAuthStore and improve test stability
- Replaced `useAuthStore` with `useAuth` from `AuthContext` across frontend components and tests to ensure dependency injection compliance. - Enhanced E2E test stability by delaying navigation until the auth context is fully initialized. - Updated Playwright configuration to use a single worker to prevent mock conflicts. - Refactored test setup to consistently inject `AuthProvider` for improved isolation and mocking. - Adjusted comments and documentation to clarify dependency injection and testability patterns.
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { updateCurrentUser } from '../client';
|
||||
import { useAuthStore } from '@/lib/stores/authStore';
|
||||
import { useAuth } from '@/lib/auth/AuthContext';
|
||||
import type { User } from '@/lib/stores/authStore';
|
||||
import { parseAPIError, getGeneralError } from '../errors';
|
||||
import { authKeys } from './useAuth';
|
||||
@@ -31,7 +31,7 @@ import { authKeys } from './useAuth';
|
||||
*/
|
||||
export function useUpdateProfile(onSuccess?: (message: string) => void) {
|
||||
const queryClient = useQueryClient();
|
||||
const setUser = useAuthStore((state) => state.setUser);
|
||||
const setUser = useAuth((state) => state.setUser);
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (data: {
|
||||
|
||||
Reference in New Issue
Block a user