Skip to content

Commit 68c690e

Browse files
isabellaenriquezJesse-Box
authored andcommitted
fix(sub v3): Show PAYG column for all orgs that can use it (#103070)
Originally, we only showed the PAYG spend column for self-serve orgs, or invoiced orgs with special PAYG. There are other non-self-serve orgs that can set PAYG, however, so instead we can use the existing `supportsPayg` util function for determining whether to show it.
1 parent 42d3d3a commit 68c690e

File tree

2 files changed

+53
-10
lines changed

2 files changed

+53
-10
lines changed

static/gsApp/views/subscriptionPage/usageOverview.spec.tsx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ describe('UsageOverview', () => {
4848
usageData={usageData}
4949
/>
5050
);
51+
expect(screen.getAllByRole('columnheader')).toHaveLength(6);
5152
expect(screen.getByRole('columnheader', {name: 'Product'})).toBeInTheDocument();
5253
expect(screen.getByRole('columnheader', {name: 'Total usage'})).toBeInTheDocument();
5354
expect(screen.getByRole('columnheader', {name: 'Reserved'})).toBeInTheDocument();
@@ -73,6 +74,7 @@ describe('UsageOverview', () => {
7374
usageData={usageData}
7475
/>
7576
);
77+
expect(screen.getAllByRole('columnheader')).toHaveLength(6);
7678
expect(screen.getByRole('columnheader', {name: 'Product'})).toBeInTheDocument();
7779
expect(screen.getByRole('columnheader', {name: 'Total usage'})).toBeInTheDocument();
7880
expect(screen.getByRole('columnheader', {name: 'Reserved'})).toBeInTheDocument();
@@ -93,6 +95,54 @@ describe('UsageOverview', () => {
9395
);
9496
});
9597

98+
it('renders some spend columns for non-self-serve with PAYG support', () => {
99+
const newSubscription = SubscriptionFixture({
100+
organization,
101+
plan: 'am3_business',
102+
supportsOnDemand: true,
103+
canSelfServe: false,
104+
});
105+
SubscriptionStore.set(organization.slug, newSubscription);
106+
render(
107+
<UsageOverview
108+
subscription={newSubscription}
109+
organization={organization}
110+
usageData={usageData}
111+
/>
112+
);
113+
expect(screen.getAllByRole('columnheader')).toHaveLength(5);
114+
expect(
115+
screen.queryByRole('columnheader', {name: 'Reserved spend'})
116+
).not.toBeInTheDocument();
117+
expect(
118+
screen.getByRole('columnheader', {name: 'Pay-as-you-go spend'})
119+
).toBeInTheDocument();
120+
});
121+
122+
it('does not render spend columns for non-self-serve without PAYG support', () => {
123+
const newSubscription = SubscriptionFixture({
124+
organization,
125+
plan: 'am3_business',
126+
supportsOnDemand: false,
127+
canSelfServe: false,
128+
});
129+
SubscriptionStore.set(organization.slug, newSubscription);
130+
render(
131+
<UsageOverview
132+
subscription={newSubscription}
133+
organization={organization}
134+
usageData={usageData}
135+
/>
136+
);
137+
expect(screen.getAllByRole('columnheader')).toHaveLength(4);
138+
expect(
139+
screen.queryByRole('columnheader', {name: 'Reserved spend'})
140+
).not.toBeInTheDocument();
141+
expect(
142+
screen.queryByRole('columnheader', {name: 'Pay-as-you-go spend'})
143+
).not.toBeInTheDocument();
144+
});
145+
96146
it('renders table based on subscription state', () => {
97147
subscription.onDemandPeriodStart = '2025-05-02';
98148
subscription.onDemandPeriodEnd = '2025-06-01';

static/gsApp/views/subscriptionPage/usageOverview.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import {
5757
getPotentialProductTrial,
5858
getReservedBudgetCategoryForAddOn,
5959
MILLISECONDS_IN_HOUR,
60+
supportsPayg,
6061
} from 'getsentry/utils/billing';
6162
import {
6263
getCategoryInfoFromPlural,
@@ -274,18 +275,10 @@ function UsageOverviewTable({subscription, organization, usageData}: UsageOvervi
274275
column =>
275276
(subscription.canSelfServe ||
276277
!column.key.endsWith('Spend') ||
277-
((subscription.onDemandInvoiced || subscription.onDemandInvoicedManual) &&
278-
column.key === 'budgetSpend')) &&
278+
(supportsPayg(subscription) && column.key === 'budgetSpend')) &&
279279
(hasAnyPotentialOrActiveProductTrial || column.key !== 'trialInfo')
280280
);
281-
}, [
282-
subscription.planDetails,
283-
subscription.productTrials,
284-
subscription.canSelfServe,
285-
subscription.onDemandInvoiced,
286-
subscription.onDemandInvoicedManual,
287-
isXlScreen,
288-
]);
281+
}, [subscription, isXlScreen]);
289282

290283
// TODO(isabella): refactor this to have better types
291284
const productData: Array<{

0 commit comments

Comments
 (0)