Build the Solaire inventory intelligence MVP
Some checks failed
CI / verify (push) Has been cancelled
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>
This commit is contained in:
28
tests/recommendations.test.ts
Normal file
28
tests/recommendations.test.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user