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
|
// Mock auth store
|
||||||
vi.mock('@/lib/auth-store', () => {
|
vi.mock('@/lib/auth-store', () => {
|
||||||
const store = {
|
const store = {
|
||||||
login: vi.fn(),
|
user: null,
|
||||||
|
isAuthenticated: false,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
error: null,
|
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(),
|
clearError: vi.fn(),
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
@@ -40,18 +48,34 @@ const mockedUseAuthStore = vi.mocked(useAuthStore);
|
|||||||
|
|
||||||
describe('LoginPage', () => {
|
describe('LoginPage', () => {
|
||||||
let mockStore: {
|
let mockStore: {
|
||||||
login: ReturnType<typeof vi.fn>;
|
user: null;
|
||||||
|
isAuthenticated: boolean;
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
error: string | null;
|
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>;
|
clearError: ReturnType<typeof vi.fn>;
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
mockStore = {
|
mockStore = {
|
||||||
login: vi.fn(),
|
user: null,
|
||||||
|
isAuthenticated: false,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
error: null,
|
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(),
|
clearError: vi.fn(),
|
||||||
};
|
};
|
||||||
mockedUseAuthStore.mockImplementation((selector) => {
|
mockedUseAuthStore.mockImplementation((selector) => {
|
||||||
|
|||||||
@@ -16,9 +16,17 @@ vi.mock('next/link', () => ({
|
|||||||
|
|
||||||
vi.mock('@/lib/auth-store', () => {
|
vi.mock('@/lib/auth-store', () => {
|
||||||
const store = {
|
const store = {
|
||||||
register: vi.fn(),
|
user: null,
|
||||||
|
isAuthenticated: false,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
error: null,
|
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(),
|
clearError: vi.fn(),
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
@@ -35,18 +43,34 @@ const mockedUseAuthStore = vi.mocked(useAuthStore);
|
|||||||
|
|
||||||
describe('RegisterPage', () => {
|
describe('RegisterPage', () => {
|
||||||
let mockStore: {
|
let mockStore: {
|
||||||
register: ReturnType<typeof vi.fn>;
|
user: null;
|
||||||
|
isAuthenticated: boolean;
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
error: string | null;
|
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>;
|
clearError: ReturnType<typeof vi.fn>;
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
mockStore = {
|
mockStore = {
|
||||||
register: vi.fn(),
|
user: null,
|
||||||
|
isAuthenticated: false,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
error: null,
|
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(),
|
clearError: vi.fn(),
|
||||||
};
|
};
|
||||||
mockedUseAuthStore.mockImplementation((selector) => {
|
mockedUseAuthStore.mockImplementation((selector) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user