favicon and some TODOs

This commit is contained in:
2026-09-18 16:47:15 -04:00
parent 748702a806
commit 31d5322b38
11 changed files with 708 additions and 100 deletions
+39 -19
View File
@@ -3,7 +3,6 @@ import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { loadConfig } from "./configLoader";
import { estimate } from "./engine";
import { parseISODate } from "./dates";
// Read the actual shipped config that gets served at runtime.
const configPath = fileURLToPath(new URL("../public/config.json", import.meta.url));
@@ -16,45 +15,66 @@ describe("real config sanity", () => {
expect(result.ok).toBe(true);
});
it("produces sensible Green-plan numbers at the halfway point", () => {
it("produces sensible first-plan numbers partway through the term", () => {
if (!result.ok) throw new Error("config failed to load");
const config = result.config;
const plan = config.plans[0];
// Target a date roughly in the middle of the meal window.
const midMs =
(config.mealStartDate.getTime() + config.mealEndDate.getTime()) / 2;
const midDate = new Date(midMs);
// Roughly mid-semester target.
const r = estimate(config, {
selectedPlanId: "green",
targetDate: parseISODate("2026-10-18")!,
selectedPlanId: plan.id,
targetDate: midDate,
activeMissingPeriodIds: new Set(),
extraExcludedDays: 0,
actualMealBlocks: null,
actualFlexDollars: null,
});
// Green = 210 blocks / 500 flex over ~112 days (Aug 24 -> Dec 13).
expect(r.totalActiveDays).toBe(112);
// per-week block rate ~ 210/112*7 = 13.125
expect(r.perWeekMealBlocks).toBeCloseTo(13.125, 2);
// consumed + remaining conserves the total
expect(r.consumedMealBlocks + r.remainingMealBlocks).toBeCloseTo(210);
expect(r.consumedFlexDollars + r.remainingFlexDollars).toBeCloseTo(500);
// partway through, consumption is strictly between 0 and total
// Per-week rate matches the plan total spread over the active days.
expect(r.perWeekMealBlocks).toBeCloseTo(
(plan.totalMealBlocks / r.totalActiveDays) * 7,
2
);
// Consumed + remaining conserves the plan totals.
expect(r.consumedMealBlocks + r.remainingMealBlocks).toBeCloseTo(
plan.totalMealBlocks
);
expect(r.consumedFlexDollars + r.remainingFlexDollars).toBeCloseTo(
plan.totalFlexDollars
);
// Partway through, consumption is strictly between 0 and the total.
expect(r.consumedMealBlocks).toBeGreaterThan(0);
expect(r.consumedMealBlocks).toBeLessThan(210);
expect(r.consumedMealBlocks).toBeLessThan(plan.totalMealBlocks);
});
it("checking a break reduces total active days", () => {
if (!result.ok) throw new Error("config failed to load");
const config = result.config;
if (config.missingPeriods.length === 0) return; // nothing to check
const plan = config.plans[0];
const period = config.missingPeriods[0];
const endDate = config.mealEndDate;
const base = estimate(config, {
selectedPlanId: "green",
targetDate: parseISODate("2026-12-13")!,
selectedPlanId: plan.id,
targetDate: endDate,
activeMissingPeriodIds: new Set(),
extraExcludedDays: 0,
actualMealBlocks: null,
actualFlexDollars: null,
});
const withBreak = estimate(config, {
selectedPlanId: "green",
targetDate: parseISODate("2026-12-13")!,
activeMissingPeriodIds: new Set(["thanksgiving"]),
selectedPlanId: plan.id,
targetDate: endDate,
activeMissingPeriodIds: new Set([period.id]),
extraExcludedDays: 0,
actualMealBlocks: null,
actualFlexDollars: null,
});
expect(withBreak.totalActiveDays).toBeLessThan(base.totalActiveDays);