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:
Ho Ngoc Hai
2026-04-08 23:06:41 +07:00
parent 6552e6a661
commit ec4a960aed
2 changed files with 54 additions and 6 deletions

View File

@@ -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) => {

View File

@@ -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) => {