Skip to content

fix(billing): Hide gift budget action when no applicable budgets #93284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2025
Merged
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
18 changes: 17 additions & 1 deletion static/gsAdmin/views/customerDetails.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {OnboardingTasksFixture} from 'getsentry-test/fixtures/onboardingTasks';
import {OwnerFixture} from 'getsentry-test/fixtures/owner';
import {PoliciesFixture} from 'getsentry-test/fixtures/policies';
import {ProjectFixture} from 'getsentry-test/fixtures/project';
import {SeerReservedBudgetFixture} from 'getsentry-test/fixtures/reservedBudget';
import {
Am3DsEnterpriseSubscriptionFixture,
SubscriptionFixture,
Expand Down Expand Up @@ -1100,7 +1101,19 @@ describe('Customer Details', function () {
});

it('renders correct sections', async function () {
setUpMocks(organization);
const subscription = SubscriptionFixture({
organization,
plan: 'am3_f',
planTier: 'am3',
hasReservedBudgets: true,
});
subscription.reservedBudgets = [
SeerReservedBudgetFixture({
id: '0',
reservedBudget: 0,
}),
];
setUpMocks(organization, subscription);

render(<CustomerDetails />, {
initialRouterConfig: {
Expand Down Expand Up @@ -1139,6 +1152,9 @@ describe('Customer Details', function () {
expect(screen.getByRole('option', {name: /Gift errors/})).toBeInTheDocument();
expect(screen.getByRole('option', {name: /Gift transactions/})).toBeInTheDocument();
expect(screen.getByRole('option', {name: /Gift attachments/})).toBeInTheDocument();
expect(
screen.queryByRole('option', {name: /Gift to reserved budget/})
).not.toBeInTheDocument();
expect(screen.getByRole('option', {name: /Change Plan/})).toBeInTheDocument();
expect(
screen.getByRole('option', {name: /Start Enterprise Trial/})
Expand Down
5 changes: 4 additions & 1 deletion static/gsAdmin/views/customerDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {useEffect} from 'react';
import cloneDeep from 'lodash/cloneDeep';
import some from 'lodash/some';
import scrollToElement from 'scroll-to-element';

import {
Expand Down Expand Up @@ -752,7 +753,9 @@ export default function CustomerDetails() {
key: 'addGiftBudgetAction',
name: 'Gift to reserved budget',
help: 'Select a reserved budget and gift it free dollars for the current billing period.',
visible: subscription.hasReservedBudgets,
visible:
(subscription.reservedBudgets?.length ?? 0) > 0 &&
some(subscription.reservedBudgets, budget => budget.reservedBudget > 0),
skipConfirmModal: true,
onAction: () => {
addGiftBudgetAction({
Expand Down
Loading