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

View File

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