test(analytics): read the default body where it now lives

This commit is contained in:
Marc-André Bombeck committed 2026-10-23 15:41:54 +02:00
1 parent 356d947ab0
commit c22c302ebe
2 files changed
+8 -3

No files matched your search

+6 -2
View File
@@ -21,7 +21,11 @@ import { join } from "node:path";
const ROOT = join(__dirname, "../../..");
const INSIGHTS_PATH = join(ROOT, "src/app/insights/page-client.tsx");
const ANALYTICS_ROUTE_PATH = join(ROOT, "src/app/api/analytics/route.ts");
/** The analytics default body, built outside its route. */
const ANALYTICS_BODY_PATHS = [
join(ROOT, "src/lib/analytics/response/default-body.ts"),
join(ROOT, "src/lib/analytics/response/correlations.ts"),
];
const ADVISOR_HOOK_PATH = join(
ROOT,
"src/components/insights/use-insights-advisor.ts",
@@ -84,7 +88,7 @@ describe("v1.4.20 B3 — /api/analytics surfaces correlations", () => {
});
it("returns a `correlations` block on the success payload", () => {
const src = load(ANALYTICS_ROUTE_PATH);
const src = ANALYTICS_BODY_PATHS.map(load).join("\n");
expect(src).toMatch(/correlations:\s*correlationsWithPatterns,/);
expect(src).toMatch(/computeCorrelationHypotheses/);
});
+2 -1
View File
@@ -213,8 +213,9 @@ describe("v1.4.22 W5 reconcile (Code-H2) — BD-Zielbereich tile compareDelta us
});
it("ships priorMonth + priorYear pcts in the analytics envelope", () => {
// The default body is built outside the route.
const ROUTE_SRC = readFileSync(
join(ROOT, "src/app/api/analytics/route.ts"),
join(ROOT, "src/lib/analytics/response/default-body.ts"),
"utf8",
);
expect(ROUTE_SRC).toContain("bpInTargetPctPriorMonth");