Skip to content

Commit 5225c26

Browse files
committed
fix(webapp): absolute base marker wins over legacy-dollar heuristic
1 parent 958275d commit 5225c26

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

apps/webapp/app/components/billing/billingAlertsFormat.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ export function isLegacyDollarAmountField(
208208
return false;
209209
}
210210

211+
// The exact $1 absolute base marker always wins, even with levels below 100 (e.g. a $5 alert).
212+
if (rawAmount === ABSOLUTE_ALERT_BASE_CENTS) {
213+
return false;
214+
}
215+
211216
if (!Number.isFinite(rawAmount) || rawAmount < 10) {
212217
return false;
213218
}

apps/webapp/test/billingAlertsFormat.test.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,22 @@ describe("billingAlertsFormat", () => {
163163
);
164164
});
165165

166+
it("keeps seeded absolute defaults absolute when the plan limit is exactly $100", () => {
167+
const normalized = normalizeBillingAlertsFromApi(
168+
{
169+
amount: 100,
170+
emails: [],
171+
alertLevels: [5, 100, 500, 1000, 2500],
172+
},
173+
{ planLimitCents: 10_000, effectiveLimitCents: 10_000 }
174+
);
175+
176+
expect(normalized.amount).toBe(1);
177+
expect(storedAlertsToThresholds(normalized, "none", 10_000, 10_000)).toEqual([
178+
5, 100, 500, 1000, 2500,
179+
]);
180+
});
181+
166182
it("normalizes cents-based alerts with whole-number levels when amount matches limit", () => {
167183
const normalized = normalizeBillingAlertsFromApi(
168184
{
@@ -186,14 +202,14 @@ describe("billingAlertsFormat", () => {
186202
expect(
187203
normalizeBillingAlertsFromApi(
188204
{
189-
amount: 100,
205+
amount: 300,
190206
emails: [],
191207
alertLevels: [10, 50, 80],
192208
},
193-
{ planLimitCents: 10_000, effectiveLimitCents: 10_000 }
209+
{ planLimitCents: 30_000, effectiveLimitCents: 30_000 }
194210
)
195211
).toEqual({
196-
amount: 100,
212+
amount: 300,
197213
emails: [],
198214
alertLevels: [10, 50, 80],
199215
});

0 commit comments

Comments
 (0)