Skip to content

Commit 1b2028b

Browse files
authored
fix(billing): Fix category display names in pending changes (#109612)
1 parent b507f87 commit 1b2028b

File tree

4 files changed

+71
-11
lines changed

4 files changed

+71
-11
lines changed

static/gsAdmin/components/customers/pendingChanges.spec.tsx

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {OrganizationFixture} from 'sentry-fixture/organization';
22

3+
import {MetricHistoryFixture} from 'getsentry-test/fixtures/metricHistory';
34
import {PlanDetailsLookupFixture} from 'getsentry-test/fixtures/planDetailsLookup';
45
import {PlanMigrationFixture} from 'getsentry-test/fixtures/planMigration';
56
import {SeerReservedBudgetFixture} from 'getsentry-test/fixtures/reservedBudget';
@@ -300,7 +301,7 @@ describe('PendingChanges', () => {
300301
expect(container).toHaveTextContent(
301302
'Reserved performance units — 100,000 → 0 transactions'
302303
);
303-
expect(container).toHaveTextContent('Reserved replays — 500 → 50 replays');
304+
expect(container).toHaveTextContent('Reserved replays — 500 → 50 session replays');
304305
expect(container).toHaveTextContent('Reserved spans — 0 → 10,000,000 spans');
305306

306307
// no actual changes
@@ -480,7 +481,7 @@ describe('PendingChanges', () => {
480481
'Reserved accepted spans — reserved budget → 10,000,000 spans'
481482
);
482483
expect(container).toHaveTextContent(
483-
'Reserved stored spans — reserved budget → 0 spansIndexed'
484+
'Reserved stored spans — reserved budget → 0 stored spans'
484485
);
485486
expect(container).not.toHaveTextContent('Reserved spans —');
486487
expect(container).not.toHaveTextContent('Reserved spansIndexed —');
@@ -489,7 +490,7 @@ describe('PendingChanges', () => {
489490
'Reserved cost-per-event for spans — $0.01000000 → None'
490491
);
491492
expect(container).toHaveTextContent(
492-
'Reserved cost-per-event for spansIndexed — $0.02000000 → None'
493+
'Reserved cost-per-event for stored spans — $0.02000000 → None'
493494
);
494495
expect(container).toHaveTextContent(
495496
'Reserved budgets — $0.00 for seer budget, $100,000.00 for spans budget → $0.00 for seer budget'
@@ -503,4 +504,30 @@ describe('PendingChanges', () => {
503504
const {container} = render(<PendingChanges subscription={subscription} />);
504505
expect(container).not.toHaveTextContent('Reserved budgets —');
505506
});
507+
508+
it('renders size analysis reserved changes with human-readable name', () => {
509+
const subscription = SubscriptionFixture({
510+
organization: OrganizationFixture(),
511+
pendingChanges: PendingChangesFixture({
512+
planDetails: PlanDetailsLookupFixture('am3_business'),
513+
plan: 'am3_business',
514+
planName: 'Business',
515+
reserved: {
516+
sizeAnalyses: 100,
517+
},
518+
}),
519+
});
520+
subscription.categories = {
521+
...subscription.categories,
522+
sizeAnalyses: MetricHistoryFixture({
523+
category: 'sizeAnalyses' as any,
524+
reserved: 50,
525+
}),
526+
};
527+
528+
const {container} = render(<PendingChanges subscription={subscription} />);
529+
expect(container).toHaveTextContent('Reserved size analysis builds');
530+
expect(container).toHaveTextContent('50 → 100');
531+
expect(container).not.toHaveTextContent('sizeAnalyses');
532+
});
506533
});

static/gsApp/utils/dataCategory.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function getPlanCategoryName({
7373
? t('accepted spans')
7474
: displayNames
7575
? displayNames.plural
76-
: category;
76+
: (getCategoryInfoFromPlural(category)?.titleName?.toLowerCase() ?? category);
7777
return title
7878
? toTitleCase(categoryName, {allowInnerUpperCase: true})
7979
: capitalize
@@ -97,7 +97,8 @@ export function getSingularCategoryName({
9797
? t('accepted span')
9898
: displayNames
9999
? displayNames.singular
100-
: category.substring(0, category.length - 1);
100+
: (getCategoryInfoFromPlural(category)?.displayName ??
101+
category.substring(0, category.length - 1));
101102
return title
102103
? toTitleCase(categoryName, {allowInnerUpperCase: true})
103104
: capitalize

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,33 @@ describe('Subscription > PendingChanges', () => {
405405
expect(screen.queryByText(/budget change/)).not.toBeInTheDocument();
406406
});
407407

408+
it('renders size analysis reserved changes with correct display name', () => {
409+
const sub = SubscriptionFixture({
410+
organization,
411+
plan: 'am3_business',
412+
pendingChanges: PendingChangesFixture({
413+
planDetails: PlanDetailsLookupFixture('am3_business'),
414+
plan: 'am3_business',
415+
planName: 'Business',
416+
reserved: {
417+
sizeAnalyses: 100,
418+
},
419+
}),
420+
});
421+
sub.categories = {
422+
...sub.categories,
423+
sizeAnalyses: MetricHistoryFixture({
424+
category: 'sizeAnalyses' as any,
425+
reserved: 50,
426+
}),
427+
};
428+
429+
render(<PendingChanges organization={organization} subscription={sub} />);
430+
expect(
431+
screen.getByText('Reserved size analysis builds change to 100')
432+
).toBeInTheDocument();
433+
});
434+
408435
it('renders reserved budgets with existing budgets without dynamic sampling', () => {
409436
const sub = Am3DsEnterpriseSubscriptionFixture({
410437
organization,

static/gsApp/views/subscriptionPage/pendingChanges.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,19 @@ function PendingChanges({organization, subscription}: Props) {
173173
pendingReserved !== RESERVED_BUDGET_QUOTA &&
174174
pendingReserved !== 0
175175
) {
176+
const formattedQuantity = formatReservedWithUnits(
177+
pendingReserved ?? null,
178+
category
179+
);
180+
const displayName = getPlanCategoryName({
181+
plan: pendingChanges.planDetails,
182+
category,
183+
capitalize: false,
184+
});
176185
results.push(
177186
tct('Reserved [displayName] change to [quantity]', {
178-
displayName: getPlanCategoryName({
179-
plan: pendingChanges.planDetails,
180-
category,
181-
capitalize: false,
182-
}),
183-
quantity: formatReservedWithUnits(pendingReserved ?? null, category),
187+
displayName,
188+
quantity: formattedQuantity,
184189
})
185190
);
186191
}

0 commit comments

Comments
 (0)