Skip to content

Commit 558da58

Browse files
committed
test(webapp): exercise isPercentageMode in alert preview raised-limit test
Pass the isPercentageMode argument to getAlertPreviewLimitCents so the raised-limit regression test drives the percentage-mode branch instead of the fallback path, matching the current function signature.
1 parent 1cb99ba commit 558da58

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

apps/webapp/test/billingAlertsFormat.test.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,22 @@ describe("billingAlertsFormat", () => {
8686
).toEqual([10, 50, 80]);
8787

8888
expect(
89-
getAlertPreviewLimitCents({ amount: 100, emails: [], alertLevels: [] }, 25_000, 10_000)
89+
getAlertPreviewLimitCents({ amount: 100, emails: [], alertLevels: [] }, 25_000, 10_000, true)
9090
).toBe(10_000);
9191
});
9292

93-
it("previews saved percentage alerts against the current limit after it changes", () => {
93+
it("previews saved percentage alerts against the current limit after it is raised", () => {
9494
// Percentage alerts saved against a $30 custom limit, limit later raised to $300.
95+
// In percentage mode the preview must track the current limit (30_000 cents), not the
96+
// $30 base snapshotted at the last alert save.
9597
const alerts = { amount: 30, emails: [], alertLevels: [0.75, 1.0] };
9698

97-
expect(getAlertPreviewLimitCents(alerts, 30_000, 10_000)).toBe(30_000);
99+
expect(getAlertPreviewLimitCents(alerts, 30_000, 10_000, true)).toBe(30_000);
98100
expect(
99-
previewDollarAmountForPercent(100, getAlertPreviewLimitCents(alerts, 30_000, 10_000))
101+
previewDollarAmountForPercent(100, getAlertPreviewLimitCents(alerts, 30_000, 10_000, true))
100102
).toBe(300);
101103
expect(
102-
previewDollarAmountForPercent(75, getAlertPreviewLimitCents(alerts, 30_000, 10_000))
104+
previewDollarAmountForPercent(75, getAlertPreviewLimitCents(alerts, 30_000, 10_000, true))
103105
).toBe(225);
104106
});
105107

@@ -157,10 +159,10 @@ describe("billingAlertsFormat", () => {
157159

158160
expect(storedAlertsToThresholds(normalized, "plan", 500, 500)).toEqual([75, 90]);
159161

160-
expect(getAlertPreviewLimitCents(normalized, 500, 500)).toBe(500);
161-
expect(previewDollarAmountForPercent(75, getAlertPreviewLimitCents(normalized, 500, 500))).toBe(
162-
3.75
163-
);
162+
expect(getAlertPreviewLimitCents(normalized, 500, 500, true)).toBe(500);
163+
expect(
164+
previewDollarAmountForPercent(75, getAlertPreviewLimitCents(normalized, 500, 500, true))
165+
).toBe(3.75);
164166
});
165167

166168
it("keeps seeded absolute defaults absolute when the plan limit is exactly $100", () => {

0 commit comments

Comments
 (0)