diff --git a/.server-changes/billing-alert-preview-current-limit.md b/.server-changes/billing-alert-preview-current-limit.md new file mode 100644 index 0000000000..9ab90e952e --- /dev/null +++ b/.server-changes/billing-alert-preview-current-limit.md @@ -0,0 +1,6 @@ +--- +area: webapp +type: fix +--- + +Raising your billing limit now updates the alert threshold preview amounts right away, instead of showing figures based on the previous limit until you save your alerts again. diff --git a/apps/webapp/app/components/billing/billingAlertsFormat.ts b/apps/webapp/app/components/billing/billingAlertsFormat.ts index dc99c49ff1..27b2fe035c 100644 --- a/apps/webapp/app/components/billing/billingAlertsFormat.ts +++ b/apps/webapp/app/components/billing/billingAlertsFormat.ts @@ -315,9 +315,6 @@ export function getAlertPreviewLimitCents( planLimitCents: number ): number { const amountCents = getSavedAlertAmountCents(alerts); - if (amountCents > 0 && percentageAlertLevelsToUiThresholds(alerts.alertLevels).length > 0) { - return amountCents; - } if (percentageAlertAmountMatches(amountCents, effectiveLimitCents, planLimitCents)) { return amountCents; } diff --git a/apps/webapp/test/billingAlertsFormat.test.ts b/apps/webapp/test/billingAlertsFormat.test.ts index 7ef84770d7..275dc5adfb 100644 --- a/apps/webapp/test/billingAlertsFormat.test.ts +++ b/apps/webapp/test/billingAlertsFormat.test.ts @@ -90,6 +90,18 @@ describe("billingAlertsFormat", () => { ).toBe(10_000); }); + it("previews percentage alerts against the current limit after it is raised", () => { + // Alerts were saved against an old $30 limit; the customer has since raised + // it to $300. The preview should follow the current limit, not the snapshot. + expect( + getAlertPreviewLimitCents( + { amount: 30, emails: [], alertLevels: [0.75, 0.9] }, + 30_000, + 10_000 + ) + ).toBe(30_000); + }); + it("normalizes legacy API alerts with dollar amount field and whole percents", () => { expect( normalizeBillingAlertsFromApi(