feat: add business brand assets and health checks
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
import { afterEach, describe, expect, test } from "bun:test";
|
||||
import {
|
||||
EXPENSE_CATEGORIES as domainExpenseCategories,
|
||||
addCalendarDays,
|
||||
calendarDateFromInstant,
|
||||
formatElapsedSeconds as formatDomainElapsedSeconds,
|
||||
getEffectiveInvoiceStatus,
|
||||
} from "@beenvoice/domain";
|
||||
@@ -14,9 +16,7 @@ import { generateInvoiceNumber as generateMobileInvoiceNumber } from "../lib/inv
|
||||
import { formatElapsedSeconds as formatAppElapsedSeconds } from "../lib/time-clock";
|
||||
import { generateInvoiceNumber as generateWebInvoiceNumber } from "../../web/src/lib/draft-invoice";
|
||||
import { safeCallbackPath } from "../../web/src/lib/safe-callback-url";
|
||||
import {
|
||||
normalizeOptionalId,
|
||||
} from "../../web/src/lib/time-clock";
|
||||
import { normalizeOptionalId } from "../../web/src/lib/time-clock";
|
||||
|
||||
const originalFetch = globalThis.fetch;
|
||||
|
||||
@@ -52,15 +52,18 @@ describe("invoice parity", () => {
|
||||
test("web and mobile use the device-local date in invoice numbers", () => {
|
||||
const lateLocalEvening = new Date(2026, 7, 16, 23, 30, 0, 123);
|
||||
|
||||
expect(generateMobileInvoiceNumber(lateLocalEvening)).toStartWith("INV-20260816-");
|
||||
expect(generateWebInvoiceNumber(lateLocalEvening)).toStartWith("INV-20260816-");
|
||||
expect(generateMobileInvoiceNumber(lateLocalEvening)).toStartWith(
|
||||
"INV-20260816-",
|
||||
);
|
||||
expect(generateWebInvoiceNumber(lateLocalEvening)).toStartWith(
|
||||
"INV-20260816-",
|
||||
);
|
||||
});
|
||||
|
||||
test("web and mobile agree on draft, paid, sent, and overdue states", () => {
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
const yesterday = new Date(today);
|
||||
yesterday.setDate(yesterday.getDate() - 1);
|
||||
const timeZone = "America/New_York";
|
||||
const today = calendarDateFromInstant(new Date(), timeZone);
|
||||
const yesterday = addCalendarDays(today, -1);
|
||||
|
||||
const fixtures = [
|
||||
{
|
||||
@@ -82,11 +85,15 @@ describe("invoice parity", () => {
|
||||
];
|
||||
|
||||
for (const fixture of fixtures) {
|
||||
expect(getEffectiveInvoiceStatus(fixture.stored, fixture.dueDate)).toBe(
|
||||
fixture.expected,
|
||||
);
|
||||
expect(
|
||||
getInvoiceStatus({ status: fixture.stored, dueDate: fixture.dueDate }),
|
||||
getEffectiveInvoiceStatus(fixture.stored, fixture.dueDate, timeZone),
|
||||
).toBe(fixture.expected);
|
||||
expect(
|
||||
getInvoiceStatus({
|
||||
status: fixture.stored,
|
||||
dueDate: fixture.dueDate,
|
||||
createdBy: { timeZone },
|
||||
}),
|
||||
).toBe(fixture.expected);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user