106 lines
3.9 KiB
TypeScript
106 lines
3.9 KiB
TypeScript
|
|
import { vi } from "vitest";
|
||
|
|
|
||
|
|
// Manual mock for the API layer. Every endpoint resolves with the standard
|
||
|
|
// `{ code: 0, data }` envelope so pages can render without a live backend.
|
||
|
|
// Object envelope covering the shapes pages read: `data.list` for paginated
|
||
|
|
// tables plus the nested arrays detail pages iterate (`details`, etc.). All
|
||
|
|
// default to empty so `.map`/`.length` access never throws.
|
||
|
|
function makeData() {
|
||
|
|
return {
|
||
|
|
list: [],
|
||
|
|
total: 0,
|
||
|
|
records: [],
|
||
|
|
nodes: [],
|
||
|
|
edges: [],
|
||
|
|
details: [],
|
||
|
|
payments: [],
|
||
|
|
receipts: [],
|
||
|
|
items: [],
|
||
|
|
children: [],
|
||
|
|
bolts: [],
|
||
|
|
pans: [],
|
||
|
|
colors: [],
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
const ok = () => Promise.resolve({ code: 0, msg: "ok", success: true, data: makeData() });
|
||
|
|
|
||
|
|
export const login = vi.fn(() =>
|
||
|
|
Promise.resolve({ code: 0, msg: "ok", data: { token: "test-token", userInfo: { tenantId: "t1", name: "tester" } } }),
|
||
|
|
);
|
||
|
|
export const getUserInfo = vi.fn(() =>
|
||
|
|
Promise.resolve({ code: 0, msg: "ok", data: { name: "tester", menuPaths: [], roles: [] } }),
|
||
|
|
);
|
||
|
|
export const logout = vi.fn(ok);
|
||
|
|
export const changePassword = vi.fn(ok);
|
||
|
|
export const listUsers = vi.fn(ok);
|
||
|
|
export const getUser = vi.fn(ok);
|
||
|
|
export const createUser = vi.fn(ok);
|
||
|
|
export const updateUser = vi.fn(ok);
|
||
|
|
export const deleteUser = vi.fn(ok);
|
||
|
|
export const updateUserStatus = vi.fn(ok);
|
||
|
|
export const listRoles = vi.fn(ok);
|
||
|
|
export const createRole = vi.fn(ok);
|
||
|
|
export const updateRole = vi.fn(ok);
|
||
|
|
export const deleteRole = vi.fn(ok);
|
||
|
|
export const setRolePermissions = vi.fn(ok);
|
||
|
|
export const listMenus = vi.fn(ok);
|
||
|
|
export const createMenu = vi.fn(ok);
|
||
|
|
export const updateMenu = vi.fn(ok);
|
||
|
|
export const deleteMenu = vi.fn(ok);
|
||
|
|
export const listLogs = vi.fn(ok);
|
||
|
|
export const listConfigs = vi.fn(ok);
|
||
|
|
export const updateConfig = vi.fn(ok);
|
||
|
|
export const listProducts = vi.fn(ok);
|
||
|
|
export const getProduct = vi.fn(ok);
|
||
|
|
export const createProduct = vi.fn(ok);
|
||
|
|
export const updateProduct = vi.fn(ok);
|
||
|
|
export const deleteProduct = vi.fn(ok);
|
||
|
|
export const exportProducts = vi.fn(ok);
|
||
|
|
export const getProductSummary = vi.fn(ok);
|
||
|
|
export const getColorDetail = vi.fn(ok);
|
||
|
|
export const getProductTree = vi.fn(ok);
|
||
|
|
export const listPans = vi.fn(ok);
|
||
|
|
export const savePans = vi.fn(ok);
|
||
|
|
export const listBolts = vi.fn(ok);
|
||
|
|
export const saveBolts = vi.fn(ok);
|
||
|
|
export const listPanView = vi.fn(ok);
|
||
|
|
export const listBoltView = vi.fn(ok);
|
||
|
|
export const getStockSummary = vi.fn(ok);
|
||
|
|
export const getStockByColor = vi.fn(ok);
|
||
|
|
export const getStockByLocation = vi.fn(ok);
|
||
|
|
export const listStockChecks = vi.fn(ok);
|
||
|
|
export const getStockCheck = vi.fn(ok);
|
||
|
|
export const createStockCheck = vi.fn(ok);
|
||
|
|
export const confirmStockCheck = vi.fn(ok);
|
||
|
|
export const listStockAdjusts = vi.fn(ok);
|
||
|
|
export const getStockAdjust = vi.fn(ok);
|
||
|
|
export const createStockAdjust = vi.fn(ok);
|
||
|
|
export const approveStockAdjust = vi.fn(ok);
|
||
|
|
export const listUpstream = vi.fn(ok);
|
||
|
|
export const listDownstream = vi.fn(ok);
|
||
|
|
export const createRelation = vi.fn(ok);
|
||
|
|
export const updateRelation = vi.fn(ok);
|
||
|
|
export const listRelationHistory = vi.fn(ok);
|
||
|
|
export const listSuppliers = vi.fn(ok);
|
||
|
|
export const getSupplier = vi.fn(ok);
|
||
|
|
export const createSupplier = vi.fn(ok);
|
||
|
|
export const updateSupplier = vi.fn(ok);
|
||
|
|
export const deleteSupplier = vi.fn(ok);
|
||
|
|
export const listPurchaseOrders = vi.fn(ok);
|
||
|
|
export const getPurchaseOrder = vi.fn(ok);
|
||
|
|
export const createPurchaseOrder = vi.fn(ok);
|
||
|
|
export const updatePurchaseOrder = vi.fn(ok);
|
||
|
|
export const confirmPurchaseOrder = vi.fn(ok);
|
||
|
|
export const cancelPurchaseOrder = vi.fn(ok);
|
||
|
|
export const listPurchaseReceipts = vi.fn(ok);
|
||
|
|
export const getPurchaseReceipt = vi.fn(ok);
|
||
|
|
export const createPurchaseReceipt = vi.fn(ok);
|
||
|
|
export const confirmPurchaseReceipt = vi.fn(ok);
|
||
|
|
export const listPurchasePayments = vi.fn(ok);
|
||
|
|
export const createPurchasePayment = vi.fn(ok);
|
||
|
|
export const getPurchaseStatsSummary = vi.fn(ok);
|
||
|
|
export const getPurchaseStatsBySupplier = vi.fn(ok);
|
||
|
|
export const getPurchaseStatsByProduct = vi.fn(ok);
|
||
|
|
export const listInventoryLogs = vi.fn(ok);
|