mirror of
https://github.com/Sea-Haven-Industries/seahaven-ap.git
synced 2026-10-01 22:07:58 +00:00
* feat(web): fix shell chrome, logo home, and live nav badges Refs: AP-42 * feat(web): add invoice grid lines and bold headers Refs: AP-44 * feat(web): support auto row height for multi-line invoice cells Refs: AP-44 * feat(web): expand mock invoice fields for Stampli column catalog Refs: AP-47 * feat(web): add Action and Vendor filters to invoice processing Refs: AP-43 * feat(web): add multi-line Stampli invoice cell renderers Refs: AP-47 * feat(web): align filter toolbar layout, field shapes, and tabs Refs: AP-43 * feat(web): add Columns slide-over with Stampli HTML defaults Refs: AP-45 * fix(web): address review feedback * fix(web): address review feedback * fix(web): address review feedback * ci: remove the pr policy caller * fix(web): keep mock catalog dates and updates in sync * fix(web): render the attention banner as text * fix(web): keep pay date editable on the approved grid * fix(web): make the attention banner non-interactive copy * fix(web): derive mock action labels from invoice status * fix(web): restore link-style attention banner copy * fix(ci): drop the unused catalog refresh index * fix(web): assert the vendor column by its grid field * fix(ci): format invoice mock helpers * fix(web): hide Payment Date when the drawer omits it * fix(web): count filtered rows on invoice tabs * fix(web): close the columns drawer before editing pay date
48 lines
2.2 KiB
TypeScript
48 lines
2.2 KiB
TypeScript
import type { GridColDef } from "@mui/x-data-grid";
|
|
import { describe, expect, it } from "vitest";
|
|
import { withEditablePayDate } from "@/dashboard/approved-columns";
|
|
import type { MockInvoice } from "@/mocks";
|
|
import { formatRelativeFromIsoDate, formatSlashDate } from "@/dashboard/invoice-date-format";
|
|
|
|
describe("invoice column date helpers (AP-47)", () => {
|
|
it("formats ISO dates as MM/DD/YYYY", () => {
|
|
expect(formatSlashDate("2026-04-10")).toBe("04/10/2026");
|
|
});
|
|
|
|
it("formats relative ages from a fixed now", () => {
|
|
const now = new Date("2026-08-11T12:00:00");
|
|
expect(formatRelativeFromIsoDate("2026-08-11", now)).toBe("today");
|
|
expect(formatRelativeFromIsoDate("2026-08-10", now)).toBe("1 day ago");
|
|
expect(formatRelativeFromIsoDate("2026-02-11", now)).toBe("6 months ago");
|
|
});
|
|
|
|
it("uses calendar days so early hours still treat yesterday as 1 day ago", () => {
|
|
const earlyMorning = new Date("2026-08-11T01:15:00");
|
|
expect(formatRelativeFromIsoDate("2026-08-10", earlyMorning)).toBe("1 day ago");
|
|
expect(formatRelativeFromIsoDate("2026-08-11", earlyMorning)).toBe("today");
|
|
});
|
|
|
|
it("formats future invoice and due dates instead of clamping to today", () => {
|
|
const now = new Date("2026-08-11T12:00:00");
|
|
expect(formatRelativeFromIsoDate("2026-08-12", now)).toBe("in 1 day");
|
|
expect(formatRelativeFromIsoDate("2026-08-16", now)).toBe("in 5 days");
|
|
expect(formatRelativeFromIsoDate("2026-10-11", now)).toBe("in 2 months");
|
|
});
|
|
});
|
|
|
|
describe("withEditablePayDate", () => {
|
|
const hidden: GridColDef<MockInvoice> = { field: "vendorName", headerName: "Vendor" };
|
|
const payDate: GridColDef<MockInvoice> = { field: "payDate", headerName: "Payment Date" };
|
|
|
|
it("leaves Payment Date hidden when the catalog omits it", () => {
|
|
const columns = withEditablePayDate([hidden]);
|
|
expect(columns.some((column) => column.field === "payDate")).toBe(false);
|
|
});
|
|
|
|
it("keeps a single editable pay date when Payment Date is already visible", () => {
|
|
const columns = withEditablePayDate([hidden, { ...payDate, editable: false }]);
|
|
const matches = columns.filter((column) => column.field === "payDate");
|
|
expect(matches).toHaveLength(1);
|
|
expect(matches[0]?.editable).toBe(true);
|
|
});
|
|
});
|