Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .server-changes/billing-alert-preview-current-limit.md
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 0 additions & 3 deletions apps/webapp/app/components/billing/billingAlertsFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
12 changes: 12 additions & 0 deletions apps/webapp/test/billingAlertsFormat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down