Some checks failed
CI / verify (push) Has been cancelled
Add the tenant-ready dashboard, freshness and pricing analytics, mock integration adapters, persistence schema, and verification tooling needed for the initial pilot. Co-authored-by: Cursor <cursoragent@cursor.com>
29 lines
1.2 KiB
TypeScript
29 lines
1.2 KiB
TypeScript
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);
|
|
});
|
|
});
|