Tests refactor

This commit is contained in:
Aerilyn Weber 2026-05-19 11:06:03 +09:00
parent 245520fb50
commit 99134d8556
165 changed files with 911 additions and 531 deletions

View file

@ -11,6 +11,7 @@
"lint-fix": "eslint src --fix",
"typecheck": "tsc --noEmit",
"test": "vitest run",
"test:watch": "vitest",
"test:cov": "vitest run --coverage"
},
"dependencies": {

View file

@ -32,7 +32,7 @@ vi.mock('next/link', () => ({
default: (props: any) => <a href={props.href}>{props.children}</a>,
}));
import DashboardPage from '../page';
import DashboardPage from '../../../../src/app/(dashboard)/dashboard/page';
beforeEach(() => {
vi.clearAllMocks();

View file

@ -9,7 +9,7 @@ vi.mock('@/components/layout/TopBar', () => ({
TopBar: () => <div data-testid="topbar" />,
}));
import DashboardLayout from '../layout';
import DashboardLayout from '../../../src/app/(dashboard)/layout';
describe('DashboardLayout', () => {
it('renders sidebar, topbar and children', () => {

View file

@ -1,7 +1,7 @@
import { describe, it, expect } from 'vitest';
import { render } from '@testing-library/react';
import DashboardLoading from '../loading';
import DashboardLoading from '../../../src/app/(dashboard)/loading';
describe('DashboardLoading', () => {
it('renders a loading spinner', () => {

View file

@ -33,7 +33,7 @@ vi.mock('next/link', () => ({
default: (props: { href?: string; children: React.ReactNode }) => props.children,
}));
import MedicinePricesPage from '../page';
import MedicinePricesPage from '../../../../src/app/(dashboard)/medicine-prices/page';
const emptyResponse = { data: [], pagination: { cursor: null, hasMore: false } };

View file

@ -16,7 +16,7 @@ vi.mock('@/services/cabinet-events', () => ({
vi.mock('@/services/medicines', () => ({ listMedicines: mockListMedicines }));
import { ActivityTab } from '../ActivityTab';
import { ActivityTab } from '../../../../src/app/(dashboard)/medicines/ActivityTab';
const emptyMeds = { data: [], pagination: { cursor: null, hasMore: false } };
const emptyEvents = { data: [], pagination: { cursor: null, hasMore: false } };

View file

@ -36,7 +36,7 @@ vi.mock('next/link', () => ({
),
}));
import { CabinetTab } from '../CabinetTab';
import { CabinetTab } from '../../../../src/app/(dashboard)/medicines/CabinetTab';
const emptySummary = { data: [] };
const emptyItems = { data: [], pagination: { cursor: null, hasMore: false } };

View file

@ -21,7 +21,7 @@ vi.mock('next/link', () => ({
),
}));
import { LibraryTab } from '../LibraryTab';
import { LibraryTab } from '../../../../src/app/(dashboard)/medicines/LibraryTab';
const emptyResponse = { data: [], pagination: { cursor: null, hasMore: false } };

View file

@ -20,7 +20,7 @@ vi.mock('@/services/organizer', () => ({
vi.mock('@/services/regimens', () => ({ listRegimens: mockListRegimens }));
import { OrganizerTab } from '../OrganizerTab';
import { OrganizerTab } from '../../../../src/app/(dashboard)/medicines/OrganizerTab';
const emptyRegimens = { data: [], pagination: { cursor: null, hasMore: false } };
const emptyFills = { data: [], pagination: { cursor: null, hasMore: false } };

View file

@ -29,7 +29,7 @@ vi.mock('@/services/regimens', () => ({
vi.mock('@/services/medicines', () => ({ listMedicines: mockListMedicines }));
import { RegimensTab } from '../RegimensTab';
import { RegimensTab } from '../../../../src/app/(dashboard)/medicines/RegimensTab';
const emptyMeds = { data: [], pagination: { cursor: null, hasMore: false } };
const emptyRegimens = { data: [], pagination: { cursor: null, hasMore: false } };

View file

@ -53,7 +53,7 @@ vi.mock('@/services/cabinet', () => ({
deleteCabinetItem: mockDeleteCabinetItem,
}));
import MedicineDetailPage from '../page';
import MedicineDetailPage from '../../../../../src/app/(dashboard)/medicines/[id]/page';
const medicine = {
_id: 'med-1',

View file

@ -14,7 +14,7 @@ vi.mock('@/app/(dashboard)/medicines/ActivityTab', () => ({
),
}));
import ActivityPage from '../page';
import ActivityPage from '../../../../../src/app/(dashboard)/medicines/activity/page';
describe('ActivityPage', () => {
it('shows skeleton when loading', () => {

View file

@ -14,7 +14,7 @@ vi.mock('@/app/(dashboard)/medicines/CabinetTab', () => ({
),
}));
import CabinetPage from '../page';
import CabinetPage from '../../../../../src/app/(dashboard)/medicines/cabinet/page';
describe('CabinetPage', () => {
it('shows skeleton when loading', () => {

View file

@ -14,7 +14,7 @@ vi.mock('@/app/(dashboard)/medicines/LibraryTab', () => ({
),
}));
import LibraryPage from '../page';
import LibraryPage from '../../../../../src/app/(dashboard)/medicines/library/page';
describe('LibraryPage', () => {
it('shows skeleton when loading', () => {

View file

@ -14,7 +14,7 @@ vi.mock('@/app/(dashboard)/medicines/OrganizerTab', () => ({
),
}));
import OrganizerPage from '../page';
import OrganizerPage from '../../../../../src/app/(dashboard)/medicines/organizer/page';
describe('OrganizerPage', () => {
it('shows skeleton when loading', () => {

View file

@ -12,7 +12,7 @@ vi.mock('next/link', () => {
return { default: (props: any) => props.children };
});
import MedicinesPage from '../page';
import MedicinesPage from '../../../../src/app/(dashboard)/medicines/page';
beforeEach(() => vi.clearAllMocks());

View file

@ -14,7 +14,7 @@ vi.mock('@/app/(dashboard)/medicines/RegimensTab', () => ({
),
}));
import RegimensPage from '../page';
import RegimensPage from '../../../../../src/app/(dashboard)/medicines/regimens/page';
describe('RegimensPage', () => {
it('shows skeleton when loading', () => {

View file

@ -20,7 +20,7 @@ vi.mock('next/link', () => ({
default: (props: any) => <a href={props.href}>{props.children}</a>,
}));
import SchedulePage from '../page';
import SchedulePage from '../../../../../src/app/(dashboard)/medicines/schedule/page';
beforeEach(() => vi.clearAllMocks());

View file

@ -25,7 +25,7 @@ vi.mock('next/link', () => {
return { default: (props: any) => props.children };
});
import PantryPage from '../page';
import PantryPage from '../../../../src/app/(dashboard)/pantry/page';
beforeEach(() => vi.clearAllMocks());

View file

@ -9,7 +9,7 @@ vi.mock('@/services/products', () => ({
importProducts: mockImportProducts,
}));
import { ImportDialog } from '../ImportDialog';
import { ImportDialog } from '../../../../src/app/(dashboard)/products/ImportDialog';
beforeEach(() => vi.clearAllMocks());

View file

@ -9,7 +9,7 @@ vi.mock('@/services/products', () => ({
lookupBarcode: mockLookupBarcode,
}));
import { ProductModal } from '../ProductModal';
import { ProductModal } from '../../../../src/app/(dashboard)/products/ProductModal';
import { ProductCategory, ServingUnit } from '@meshitrack/shared';
beforeEach(() => vi.clearAllMocks());

View file

@ -26,7 +26,7 @@ vi.mock('next/link', () => {
return { default: (props: any) => props.children };
});
import ProductsPage from '../page';
import ProductsPage from '../../../../src/app/(dashboard)/products/page';
beforeEach(() => vi.clearAllMocks());

View file

@ -35,7 +35,7 @@ vi.mock('next/link', () => ({
default: (props: { href?: string; children: React.ReactNode }) => props.children,
}));
import PurchasesPage from '../page';
import PurchasesPage from '../../../../src/app/(dashboard)/purchases/page';
const emptyResponse = { data: [], pagination: { cursor: null, hasMore: false } };

View file

@ -39,7 +39,7 @@ vi.mock('next/link', () => ({
default: (props: any) => <a href={props.href}>{props.children}</a>,
}));
import { RecipeEditor } from '../RecipeEditor';
import { RecipeEditor } from '../../../../src/app/(dashboard)/recipes/RecipeEditor';
beforeEach(() => vi.clearAllMocks());

View file

@ -33,7 +33,7 @@ vi.mock('next/link', () => ({
default: (props: any) => <a href={props.href}>{props.children}</a>,
}));
import EditRecipePage from '../page';
import EditRecipePage from '../../../../../../src/app/(dashboard)/recipes/[id]/edit/page';
beforeEach(() => vi.clearAllMocks());

View file

@ -34,7 +34,7 @@ vi.mock('next/link', () => ({
default: (props: any) => <a href={props.href}>{props.children}</a>,
}));
import RecipeDetailPage from '../page';
import RecipeDetailPage from '../../../../../src/app/(dashboard)/recipes/[id]/page';
beforeEach(() => vi.clearAllMocks());

View file

@ -28,7 +28,7 @@ vi.mock('next/link', () => ({
default: (props: any) => <a href={props.href}>{props.children}</a>,
}));
import NewRecipePage from '../page';
import NewRecipePage from '../../../../../src/app/(dashboard)/recipes/new/page';
beforeEach(() => vi.clearAllMocks());

View file

@ -29,7 +29,7 @@ vi.mock('next/link', () => ({
default: (props: any) => <a href={props.href}>{props.children}</a>,
}));
import RecipesPage from '../page';
import RecipesPage from '../../../../src/app/(dashboard)/recipes/page';
beforeEach(() => vi.clearAllMocks());

View file

@ -34,7 +34,7 @@ vi.mock('next/link', () => ({
default: (props: { href?: string; children: React.ReactNode }) => props.children,
}));
import RefillsPage from '../page';
import RefillsPage from '../../../../src/app/(dashboard)/refills/page';
const emptyAlerts = { data: [], pagination: { cursor: null, hasMore: false } };
const emptyLists = { data: [], pagination: { cursor: null, hasMore: false } };

View file

@ -29,7 +29,7 @@ vi.mock('@/services/households', () => ({
generateInviteCode: mockGenerateInviteCode,
}));
import SettingsPage from '../page';
import SettingsPage from '../../../../src/app/(dashboard)/settings/page';
const household = {
name: 'My House',

View file

@ -1,7 +1,7 @@
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { SWRConfig } from 'swr';
import ShoppingListDetailPage from '../page';
import ShoppingListDetailPage from '../../../../../src/app/(dashboard)/shopping-lists/[id]/page';
import * as useApiModule from '@/lib/useApi';
import * as ShoppingListsService from '@/services/shopping-lists';
import * as ProductsService from '@/services/products';

View file

@ -1,6 +1,6 @@
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import ShoppingListsPage from '../page';
import ShoppingListsPage from '../../../../src/app/(dashboard)/shopping-lists/page';
import * as useApiModule from '@/lib/useApi';
import * as ShoppingListsService from '@/services/shopping-lists';
import * as MealPlansService from '@/services/meal-plans';

View file

@ -1,6 +1,6 @@
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import ShoppingListPricesPage from '../page';
import ShoppingListPricesPage from '../../../../../src/app/(dashboard)/shopping-lists/prices/page';
import * as useApiModule from '@/lib/useApi';
import * as PricesService from '@/services/prices';

View file

@ -29,7 +29,7 @@ vi.mock('next/link', () => {
return { default: (props: any) => props.children };
});
import StoresPage from '../page';
import StoresPage from '../../../../src/app/(dashboard)/stores/page';
beforeEach(() => vi.clearAllMocks());

View file

@ -6,7 +6,7 @@ vi.mock('next/link', () => ({
default: (props: any) => <a href={props.href}>{props.children}</a>,
}));
import HomePage from '../page';
import HomePage from '../../src/app/page';
describe('HomePage', () => {
it('renders MeshiTrack heading', () => {

View file

@ -20,7 +20,7 @@ vi.mock('next/link', () => ({
vi.mock('@/lib/useApi', () => ({ useApi: mockUseApi }));
import { Sidebar } from '../layout/Sidebar';
import { Sidebar } from '../../src/components/layout/Sidebar';
describe('Sidebar', () => {
beforeEach(() => {

View file

@ -1,7 +1,7 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen, fireEvent, act } from '@testing-library/react';
import { ThemeProvider, useTheme } from '../ThemeProvider';
import { Providers } from '../Providers';
import { ThemeProvider, useTheme } from '../../src/components/ThemeProvider';
import { Providers } from '../../src/components/Providers';
// Mock next-auth SessionProvider
vi.mock('next-auth/react', () => ({

View file

@ -16,7 +16,7 @@ vi.mock('@/components/layout/PageHeaderContext', () => ({
}),
}));
import { TopBar } from '../layout/TopBar';
import { TopBar } from '../../src/components/layout/TopBar';
describe('TopBar', () => {
it('renders title and subtitle', () => {

View file

@ -1,6 +1,6 @@
import { describe, it, expect } from 'vitest';
import { render, screen, fireEvent } from '@testing-library/react';
import { PageHeaderProvider, usePageHeader } from '../PageHeaderContext';
import { PageHeaderProvider, usePageHeader } from '../../../src/components/layout/PageHeaderContext';
function TestComponent() {
const { header, setHeader } = usePageHeader();

View file

@ -1,11 +1,11 @@
import { describe, it, expect } from 'vitest';
import { render, screen } from '@testing-library/react';
import { Avatar } from '../ui/Avatar';
import { IconButton } from '../ui/IconButton';
import { Ring } from '../ui/Ring';
import { SparkBars } from '../ui/SparkBars';
import { SupplyBar } from '../ui/SupplyBar';
import { Card, CardHeader, CardBody } from '../ui/Card';
import { Avatar } from '../../src/components/ui/Avatar';
import { IconButton } from '../../src/components/ui/IconButton';
import { Ring } from '../../src/components/ui/Ring';
import { SparkBars } from '../../src/components/ui/SparkBars';
import { SupplyBar } from '../../src/components/ui/SupplyBar';
import { Card, CardHeader, CardBody } from '../../src/components/ui/Card';
describe('Avatar', () => {
it('renders initial from name', () => {

View file

@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest';
import * as UI from '../index';
import * as UI from '../../../src/components/ui/index';
describe('UI Index Exports', () => {
it('should export all defined UI components', () => {

View file

@ -27,7 +27,7 @@ vi.mock('@/services/api-client', () => ({
apiClient: mockApiClient,
}));
import { useApi } from '../useApi';
import { useApi } from '../../src/lib/useApi';
beforeEach(() => {
vi.clearAllMocks();

View file

@ -1,6 +1,6 @@
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { renderHook, act } from '@testing-library/react';
import { useShoppingListSync } from './useShoppingListSync';
import { useShoppingListSync } from '../../src/lib/useShoppingListSync';
vi.mock('@/services/shopping-lists', () => ({
getShoppingListSyncSocketUrl: vi.fn(() => 'ws://localhost/sync'),

View file

@ -1,6 +1,6 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import type { apiClient as ApiClientType } from '../api-client';
import type { apiClient as ApiClientType } from '../../src/services/api-client';
// Create a fresh ApiClient for each test by re-importing
let apiClient: typeof ApiClientType;
@ -9,7 +9,7 @@ beforeEach(async () => {
vi.restoreAllMocks();
// Reset module to get a fresh singleton
vi.resetModules();
const mod = await import('../api-client');
const mod = await import('../../src/services/api-client');
apiClient = mod.apiClient;
});

View file

@ -4,11 +4,11 @@ const { mockGet } = vi.hoisted(() => ({
mockGet: vi.fn(),
}));
vi.mock('../api-client', () => ({
vi.mock('../../src/services/api-client', () => ({
apiClient: { get: mockGet },
}));
import { listCabinetEvents, getEventsByItem, getSpendingSummary } from '../cabinet-events';
import { listCabinetEvents, getEventsByItem, getSpendingSummary } from '../../src/services/cabinet-events';
beforeEach(() => vi.clearAllMocks());

View file

@ -7,7 +7,7 @@ const { mockGet, mockPost, mockPatch, mockDelete } = vi.hoisted(() => ({
mockDelete: vi.fn(),
}));
vi.mock('../api-client', () => ({
vi.mock('../../src/services/api-client', () => ({
apiClient: { get: mockGet, post: mockPost, patch: mockPatch, delete: mockDelete },
}));
@ -20,7 +20,7 @@ import {
updateCabinetItem,
adjustCabinetItemQuantity,
deleteCabinetItem,
} from '../cabinet';
} from '../../src/services/cabinet';
beforeEach(() => vi.clearAllMocks());

View file

@ -6,7 +6,7 @@ const { mockGet, mockPost, mockPatch } = vi.hoisted(() => ({
mockPatch: vi.fn(),
}));
vi.mock('../api-client', () => ({
vi.mock('../../src/services/api-client', () => ({
apiClient: { get: mockGet, post: mockPost, patch: mockPatch },
}));
@ -16,7 +16,7 @@ import {
updateHousehold,
generateInviteCode,
joinHousehold,
} from '../households';
} from '../../src/services/households';
beforeEach(() => vi.clearAllMocks());

View file

@ -1,8 +1,8 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { apiClient } from './api-client';
import * as MealPlansService from './meal-plans';
import { apiClient } from '../../src/services/api-client';
import * as MealPlansService from '../../src/services/meal-plans';
vi.mock('./api-client', () => ({
vi.mock('../../src/services/api-client', () => ({
apiClient: {
get: vi.fn(),
post: vi.fn(),

View file

@ -5,11 +5,11 @@ const { mockGet, mockPost } = vi.hoisted(() => ({
mockPost: vi.fn(),
}));
vi.mock('../api-client', () => ({
vi.mock('../../src/services/api-client', () => ({
apiClient: { get: mockGet, post: mockPost },
}));
import { recordPrice, getPriceHistory, compareStores, getPriceAnalytics } from '../medicine-prices';
import { recordPrice, getPriceHistory, compareStores, getPriceAnalytics } from '../../src/services/medicine-prices';
beforeEach(() => vi.clearAllMocks());

View file

@ -7,7 +7,7 @@ const { mockGet, mockPost, mockPatch, mockDelete } = vi.hoisted(() => ({
mockDelete: vi.fn(),
}));
vi.mock('../api-client', () => ({
vi.mock('../../src/services/api-client', () => ({
apiClient: { get: mockGet, post: mockPost, patch: mockPatch, delete: mockDelete },
}));
@ -21,7 +21,7 @@ import {
createMedicineProduct,
updateMedicineProduct,
deleteMedicineProduct,
} from '../medicines';
} from '../../src/services/medicines';
beforeEach(() => vi.clearAllMocks());

View file

@ -1,8 +1,8 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { apiClient } from './api-client';
import * as NutritionTargetsService from './nutrition-targets';
import { apiClient } from '../../src/services/api-client';
import * as NutritionTargetsService from '../../src/services/nutrition-targets';
vi.mock('./api-client', () => ({
vi.mock('../../src/services/api-client', () => ({
apiClient: {
get: vi.fn(),
post: vi.fn(),

View file

@ -5,11 +5,11 @@ const { mockGet, mockPost } = vi.hoisted(() => ({
mockPost: vi.fn(),
}));
vi.mock('../api-client', () => ({
vi.mock('../../src/services/api-client', () => ({
apiClient: { get: mockGet, post: mockPost },
}));
import { listFills, getFill, previewFill, executeFill, undoFill } from '../organizer';
import { listFills, getFill, previewFill, executeFill, undoFill } from '../../src/services/organizer';
beforeEach(() => vi.clearAllMocks());

View file

@ -7,7 +7,7 @@ const { mockGet, mockPost, mockPatch, mockDelete } = vi.hoisted(() => ({
mockDelete: vi.fn(),
}));
vi.mock('../api-client', () => ({
vi.mock('../../src/services/api-client', () => ({
apiClient: { get: mockGet, post: mockPost, patch: mockPatch, delete: mockDelete },
}));
@ -21,7 +21,7 @@ import {
getExpiringSoon,
getWasteStats,
deletePantryItem,
} from '../pantry';
} from '../../src/services/pantry';
beforeEach(() => vi.clearAllMocks());

View file

@ -1,8 +1,8 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { apiClient } from './api-client';
import * as PricesService from './prices';
import { apiClient } from '../../src/services/api-client';
import * as PricesService from '../../src/services/prices';
vi.mock('./api-client', () => ({
vi.mock('../../src/services/api-client', () => ({
apiClient: {
get: vi.fn(),
post: vi.fn(),

View file

@ -7,7 +7,7 @@ const { mockGet, mockPost, mockPatch, mockDelete } = vi.hoisted(() => ({
mockDelete: vi.fn(),
}));
vi.mock('../api-client', () => ({
vi.mock('../../src/services/api-client', () => ({
apiClient: { get: mockGet, post: mockPost, patch: mockPatch, delete: mockDelete },
}));
@ -20,7 +20,7 @@ import {
deleteProduct,
smartAddProduct,
importProducts,
} from '../products';
} from '../../src/services/products';
beforeEach(() => vi.clearAllMocks());

View file

@ -7,7 +7,7 @@ const { mockGet, mockPost, mockPatch, mockDelete } = vi.hoisted(() => ({
mockDelete: vi.fn(),
}));
vi.mock('../api-client', () => ({
vi.mock('../../src/services/api-client', () => ({
apiClient: { get: mockGet, post: mockPost, patch: mockPatch, delete: mockDelete },
}));
@ -18,7 +18,7 @@ import {
updatePurchase,
receivePurchase,
deletePurchase,
} from '../purchases';
} from '../../src/services/purchases';
beforeEach(() => vi.clearAllMocks());

View file

@ -7,7 +7,7 @@ const { mockGet, mockPost, mockPatch, mockDelete } = vi.hoisted(() => ({
mockDelete: vi.fn(),
}));
vi.mock('../api-client', () => ({
vi.mock('../../src/services/api-client', () => ({
apiClient: { get: mockGet, post: mockPost, patch: mockPatch, delete: mockDelete },
}));
@ -21,7 +21,7 @@ import {
importRecipeFromText,
importRecipeFromUrl,
listRecipesByProduct,
} from '../recipes';
} from '../../src/services/recipes';
beforeEach(() => vi.clearAllMocks());

View file

@ -6,7 +6,7 @@ const { mockGet, mockPost, mockPatch } = vi.hoisted(() => ({
mockPatch: vi.fn(),
}));
vi.mock('../api-client', () => ({
vi.mock('../../src/services/api-client', () => ({
apiClient: { get: mockGet, post: mockPost, patch: mockPatch },
}));
@ -18,7 +18,7 @@ import {
updateRefillList,
updateRefillListItem,
addToCabinet,
} from '../refills';
} from '../../src/services/refills';
beforeEach(() => vi.clearAllMocks());

View file

@ -7,7 +7,7 @@ const { mockGet, mockPost, mockPatch, mockDelete } = vi.hoisted(() => ({
mockDelete: vi.fn(),
}));
vi.mock('../api-client', () => ({
vi.mock('../../src/services/api-client', () => ({
apiClient: { get: mockGet, post: mockPost, patch: mockPatch, delete: mockDelete },
}));
@ -18,7 +18,7 @@ import {
createRegimen,
updateRegimen,
deleteRegimen,
} from '../regimens';
} from '../../src/services/regimens';
beforeEach(() => vi.clearAllMocks());

View file

@ -1,8 +1,8 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { apiClient } from './api-client';
import * as ShoppingListsService from './shopping-lists';
import { apiClient } from '../../src/services/api-client';
import * as ShoppingListsService from '../../src/services/shopping-lists';
vi.mock('./api-client', () => ({
vi.mock('../../src/services/api-client', () => ({
apiClient: {
get: vi.fn(),
post: vi.fn(),

View file

@ -7,11 +7,11 @@ const { mockGet, mockPost, mockPatch, mockDelete } = vi.hoisted(() => ({
mockDelete: vi.fn(),
}));
vi.mock('../api-client', () => ({
vi.mock('../../src/services/api-client', () => ({
apiClient: { get: mockGet, post: mockPost, patch: mockPatch, delete: mockDelete },
}));
import { listStores, getStore, createStore, updateStore, deactivateStore } from '../stores';
import { listStores, getStore, createStore, updateStore, deactivateStore } from '../../src/services/stores';
beforeEach(() => vi.clearAllMocks());

View file

@ -14,7 +14,7 @@ export default defineConfig({
test: {
globals: true,
environment: 'jsdom',
include: ['src/**/*.test.{ts,tsx}'],
include: ['tests/**/*.test.{ts,tsx}'],
setupFiles: ['./vitest.setup.ts'],
css: false,
coverage: {
@ -24,7 +24,6 @@ export default defineConfig({
all: true,
include: ['src/**/*.{ts,tsx}'],
exclude: [
'src/**/*.test.{ts,tsx}',
'src/test-utils.tsx',
'src/app/layout.tsx',
'src/app/api/**',