Closes the pre-Fix-#1 stock pricing gap so the till and the POS see prices on day one. What's new: - price-list-service: addPriceListItems now mirrors the upserted selling_price + markup onto the matching stock_items row when (and only when) the stock row has no price yet. Sync failures are returned as warnings — never as a failed price_list write, so a single broken stock row can't poison a 500-item batch. - stock-quick-draft-service: addQuickDraftLine seeds cost_price + bootstraps a one-entry cost_history on inline-create when the buyer supplies newStockItem.costPrice. Existing-item path backfills cost_price when zero and always appends a cost_history entry so the line addition shows up in the audit log without waiting on bookStockFromInvoice. - stock/items/create (POST): accepts optional costPrice, sellingPrice, and markup on the standalone create endpoint so the operator can stamp a price and bootstrap cost_history in one round-trip. Empty bodies still produce an empty cost_history (legacy callers unchanged). - scripts/backfill-stock-prices.ts: one-shot operator tool that mirrors price_list rows onto existing stock_items rows whose selling_price is still zero. Pure decision function exported for unit tests; --commit / --limit / --sku CLI; idempotent (never overwrites a non-zero shelf price or cost). - vitest.config.ts: pull scripts/**/*.test.ts into the vitest include list so backfill-stock-prices.test.ts runs in `npx vitest run` without a per-script config. Tests: 65 new test cases across price-list-service, stock-quick-draft-service, stock/items create, and backfill-stock-prices.
33 lines
1 KiB
TypeScript
33 lines
1 KiB
TypeScript
import { defineConfig } from "vitest/config";
|
|
import react from "@vitejs/plugin-react";
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
// Native tsconfig path resolution (replaces vite-tsconfig-paths in Vite 5+/Vitest 2+).
|
|
resolve: {
|
|
tsconfigPaths: true,
|
|
},
|
|
test: {
|
|
// jsdom covers the few client-helper modules we test (auth-provider, csv export, etc.)
|
|
// Server-side unit tests don't depend on the DOM.
|
|
environment: "jsdom",
|
|
globals: false,
|
|
include: [
|
|
"src/**/*.{test,spec}.{ts,tsx}",
|
|
// One-shot scripts under `scripts/` ship their own *.test.ts
|
|
// (e.g. scripts/backfill-stock-prices.test.ts for the pure
|
|
// decision logic). Pulled in here so `vitest run scripts/<x>`
|
|
// picks them up without a per-script config file.
|
|
"scripts/**/*.test.ts",
|
|
],
|
|
// Exclude Playwright E2E specs from Vitest.
|
|
exclude: [
|
|
"node_modules/**",
|
|
".next/**",
|
|
"e2e/**",
|
|
"playwright-report/**",
|
|
"test-results/**",
|
|
],
|
|
setupFiles: ["./src/test-setup.ts"],
|
|
},
|
|
});
|