fix(web): add missing AuthState properties to auth test mocks
Login and register test files had incomplete mock stores missing user, isAuthenticated, handleOAuthCallback, and other AuthState properties, causing TypeScript errors. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -21,9 +21,17 @@ vi.mock('next/link', () => ({
|
||||
// Mock auth store
|
||||
vi.mock('@/lib/auth-store', () => {
|
||||
const store = {
|
||||
login: vi.fn(),
|
||||
user: null,
|
||||
isAuthenticated: false,
|
||||
isLoading: false,
|
||||
error: null,
|
||||
login: vi.fn(),
|
||||
register: vi.fn(),
|
||||
handleOAuthCallback: vi.fn(),
|
||||
logout: vi.fn(),
|
||||
refreshToken: vi.fn(),
|
||||
fetchProfile: vi.fn(),
|
||||
initialize: vi.fn(),
|
||||
clearError: vi.fn(),
|
||||
};
|
||||
return {
|
||||
@@ -40,18 +48,34 @@ const mockedUseAuthStore = vi.mocked(useAuthStore);
|
||||
|
||||
describe('LoginPage', () => {
|
||||
let mockStore: {
|
||||
login: ReturnType<typeof vi.fn>;
|
||||
user: null;
|
||||
isAuthenticated: boolean;
|
||||
isLoading: boolean;
|
||||
error: string | null;
|
||||
login: ReturnType<typeof vi.fn>;
|
||||
register: ReturnType<typeof vi.fn>;
|
||||
handleOAuthCallback: ReturnType<typeof vi.fn>;
|
||||
logout: ReturnType<typeof vi.fn>;
|
||||
refreshToken: ReturnType<typeof vi.fn>;
|
||||
fetchProfile: ReturnType<typeof vi.fn>;
|
||||
initialize: ReturnType<typeof vi.fn>;
|
||||
clearError: ReturnType<typeof vi.fn>;
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
mockStore = {
|
||||
login: vi.fn(),
|
||||
user: null,
|
||||
isAuthenticated: false,
|
||||
isLoading: false,
|
||||
error: null,
|
||||
login: vi.fn(),
|
||||
register: vi.fn(),
|
||||
handleOAuthCallback: vi.fn(),
|
||||
logout: vi.fn(),
|
||||
refreshToken: vi.fn(),
|
||||
fetchProfile: vi.fn(),
|
||||
initialize: vi.fn(),
|
||||
clearError: vi.fn(),
|
||||
};
|
||||
mockedUseAuthStore.mockImplementation((selector) => {
|
||||
|
||||
@@ -16,9 +16,17 @@ vi.mock('next/link', () => ({
|
||||
|
||||
vi.mock('@/lib/auth-store', () => {
|
||||
const store = {
|
||||
register: vi.fn(),
|
||||
user: null,
|
||||
isAuthenticated: false,
|
||||
isLoading: false,
|
||||
error: null,
|
||||
login: vi.fn(),
|
||||
register: vi.fn(),
|
||||
handleOAuthCallback: vi.fn(),
|
||||
logout: vi.fn(),
|
||||
refreshToken: vi.fn(),
|
||||
fetchProfile: vi.fn(),
|
||||
initialize: vi.fn(),
|
||||
clearError: vi.fn(),
|
||||
};
|
||||
return {
|
||||
@@ -35,18 +43,34 @@ const mockedUseAuthStore = vi.mocked(useAuthStore);
|
||||
|
||||
describe('RegisterPage', () => {
|
||||
let mockStore: {
|
||||
register: ReturnType<typeof vi.fn>;
|
||||
user: null;
|
||||
isAuthenticated: boolean;
|
||||
isLoading: boolean;
|
||||
error: string | null;
|
||||
login: ReturnType<typeof vi.fn>;
|
||||
register: ReturnType<typeof vi.fn>;
|
||||
handleOAuthCallback: ReturnType<typeof vi.fn>;
|
||||
logout: ReturnType<typeof vi.fn>;
|
||||
refreshToken: ReturnType<typeof vi.fn>;
|
||||
fetchProfile: ReturnType<typeof vi.fn>;
|
||||
initialize: ReturnType<typeof vi.fn>;
|
||||
clearError: ReturnType<typeof vi.fn>;
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
mockStore = {
|
||||
register: vi.fn(),
|
||||
user: null,
|
||||
isAuthenticated: false,
|
||||
isLoading: false,
|
||||
error: null,
|
||||
login: vi.fn(),
|
||||
register: vi.fn(),
|
||||
handleOAuthCallback: vi.fn(),
|
||||
logout: vi.fn(),
|
||||
refreshToken: vi.fn(),
|
||||
fetchProfile: vi.fn(),
|
||||
initialize: vi.fn(),
|
||||
clearError: vi.fn(),
|
||||
};
|
||||
mockedUseAuthStore.mockImplementation((selector) => {
|
||||
|
||||
Reference in New Issue
Block a user