import { describe, expect, it } from "vitest"; import { getDashboardData } from "@/domain/analytics"; import { marginPercent } from "@/domain/recommendations"; describe("pricing recommendations", () => { const data = getDashboardData(); it("protects every product margin floor", () => { for (const recommendation of data.recommendations) { const product = data.inventory.find((item) => item.productId === recommendation.productId)!.product; expect(marginPercent(product, recommendation.recommendedLow)) .toBeGreaterThanOrEqual(product.marginFloorPercent - 0.01); } }); it("provides explanations and bounded ranges", () => { for (const recommendation of data.recommendations) { expect(recommendation.reason.length).toBeGreaterThan(20); expect(recommendation.recommendedHigh).toBeGreaterThanOrEqual(recommendation.recommendedLow); expect(recommendation.recommendedHigh).toBeLessThanOrEqual(recommendation.currentPrice); } }); it("contains actionable aging-stock recommendations", () => { expect(data.recommendations.some((item) => item.type === "markdown")).toBe(true); expect(data.recommendations.some((item) => item.type === "promotion")).toBe(true); }); });