Files
AgentCompany/tests/unit/budget-policy-input.test.ts
T
ZacharyZhang-NY 237db05e37 Package release 0.4.167 from the current workspace snapshot
Constraint: Windows and Linux artifacts are built on native GitHub runners from a temporary snapshot branch
Rejected: Build Windows/Linux locally on Apple Silicon | docker/wine packaging is not stable on this host
Confidence: medium
Scope-risk: moderate
Directive: This snapshot branch is transport-only and should be deleted after the release completes
Tested: local verify/build stages before snapshot creation
Not-tested: remote packaging before workflow execution
2026-04-11 02:11:07 -04:00

42 lines
1.3 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { buildBudgetPolicyInput, getBudgetPolicyAmountDollars } from "../../src/renderer/lib/budget-policy-input";
describe("budget-policy-input", () => {
it("preserves the existing policy id on edit", () => {
const payload = buildBudgetPolicyInput({
policyId: "policy-123",
companyId: "00000000-0000-0000-0000-000000000001",
scopeType: "agent",
scopeId: "00000000-0000-0000-0000-000000000002",
amountDollars: "250.00",
warnPercent: "85",
hardStopEnabled: true,
notifyEnabled: true,
});
expect(payload?.id).toBe("policy-123");
expect(payload?.amount).toBe(25000);
expect(payload?.warnPercent).toBe(85);
});
it("formats stored cents back to dollars for edit forms", () => {
expect(
getBudgetPolicyAmountDollars({
id: "policy-123",
companyId: "company-1",
scopeType: "agent",
scopeId: "agent-1",
metric: "billed_cents",
windowKind: "calendar_month_utc",
amount: 12550,
warnPercent: 80,
hardStopEnabled: true,
notifyEnabled: true,
isActive: true,
createdAt: "2026-01-01T00:00:00.000Z",
updatedAt: "2026-01-01T00:00:00.000Z",
}),
).toBe("125.50");
});
});