Skip to content

Commit b03002c

Browse files
typing fixes
1 parent 99d062b commit b03002c

File tree

14 files changed

+100
-105
lines changed

14 files changed

+100
-105
lines changed

static/gsApp/views/amCheckout/checkoutOverview.spec.tsx

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import SubscriptionStore from 'getsentry/stores/subscriptionStore';
1010
import {OnDemandBudgetMode, PlanTier} from 'getsentry/types';
1111
import AMCheckout from 'getsentry/views/amCheckout/';
1212
import CheckoutOverview from 'getsentry/views/amCheckout/checkoutOverview';
13-
import type {CheckoutFormData} from 'getsentry/views/amCheckout/types';
13+
import {type CheckoutFormData, SelectableProduct} from 'getsentry/views/amCheckout/types';
1414

1515
describe('CheckoutOverview', function () {
1616
const api = new MockApiClient();
@@ -175,12 +175,16 @@ describe('CheckoutOverview', function () {
175175
expect(screen.queryByTestId('on-demand-additional-cost')).not.toBeInTheDocument();
176176
});
177177

178-
it('displays Seer Agent AI when enabled and feature flag is present', () => {
178+
it('displays Seer Agent AI when enabled', () => {
179179
const orgWithSeerFeature = {...organization, features: ['seer-billing']};
180180
const formData: CheckoutFormData = {
181181
plan: 'am2_team',
182182
reserved: {errors: 100000, transactions: 500000, attachments: 25},
183-
seerEnabled: true,
183+
selectedProducts: {
184+
[SelectableProduct.SEER]: {
185+
enabled: true,
186+
},
187+
},
184188
};
185189

186190
render(
@@ -194,19 +198,20 @@ describe('CheckoutOverview', function () {
194198
/>
195199
);
196200

197-
expect(screen.getByTestId('seer')).toBeInTheDocument();
198-
expect(screen.getByText('Seer: Sentry AI Enhancements')).toBeInTheDocument();
199-
expect(
200-
screen.getByText('Surface insights and propose solutions to fix bugs faster.')
201-
).toBeInTheDocument();
201+
expect(screen.getByTestId('seer-reserved')).toBeInTheDocument();
202+
expect(screen.getByText('Seer')).toBeInTheDocument();
202203
});
203204

204-
it('does not display Seer Agent AI when seerEnabled is false', () => {
205+
it('does not display Seer Agent AI when not bought', () => {
205206
const orgWithSeerFeature = {...organization, features: ['seer-billing']};
206207
const formData: CheckoutFormData = {
207208
plan: 'am2_team',
208209
reserved: {errors: 100000, transactions: 500000, attachments: 25},
209-
seerEnabled: false,
210+
selectedProducts: {
211+
[SelectableProduct.SEER]: {
212+
enabled: false,
213+
},
214+
},
210215
};
211216

212217
render(
@@ -221,31 +226,6 @@ describe('CheckoutOverview', function () {
221226
);
222227

223228
expect(screen.queryByTestId('seer')).not.toBeInTheDocument();
224-
expect(screen.queryByText('Seer: Sentry AI Enhancements')).not.toBeInTheDocument();
225-
});
226-
227-
it('does not display Seer Agent AI when enabled but feature flag is missing', () => {
228-
const orgWithoutSeerFeature = {...organization, features: []};
229-
const formData: CheckoutFormData = {
230-
plan: 'am2_team',
231-
reserved: {errors: 100000, transactions: 500000, attachments: 25},
232-
seerEnabled: true,
233-
};
234-
235-
jest.spyOn(CheckoutOverview.prototype, 'renderSeer').mockReturnValue(null);
236-
237-
render(
238-
<CheckoutOverview
239-
activePlan={teamPlanMonthly}
240-
billingConfig={billingConfig}
241-
formData={formData}
242-
onUpdate={jest.fn()}
243-
organization={orgWithoutSeerFeature}
244-
subscription={subscription}
245-
/>
246-
);
247-
248-
expect(screen.queryByTestId('seer')).not.toBeInTheDocument();
249-
expect(screen.queryByText('Seer: Sentry AI Enhancements')).not.toBeInTheDocument();
229+
expect(screen.queryByText('Seer')).not.toBeInTheDocument();
250230
});
251231
});

static/gsApp/views/amCheckout/checkoutOverview.tsx

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -174,47 +174,6 @@ class CheckoutOverview extends Component<Props> {
174174
);
175175
}
176176

177-
// renderAdditionalFeature({
178-
// featureKey,
179-
// title,
180-
// description,
181-
// priceCents,
182-
// enabledField,
183-
// }: {
184-
// description: string;
185-
// enabledField: string;
186-
// featureKey: string;
187-
// priceCents: number;
188-
// title: string;
189-
// }) {
190-
// const {formData} = this.props;
191-
// const isEnabled = formData[enabledField as keyof CheckoutFormData];
192-
193-
// if (!isEnabled) {
194-
// return null;
195-
// }
196-
197-
// return (
198-
// <DetailItem key={featureKey} data-test-id={featureKey}>
199-
// <div>
200-
// <DetailTitle>{title}</DetailTitle>
201-
// {description}
202-
// </div>
203-
// <DetailPrice>{`${utils.displayPrice({cents: priceCents})}/mo`}</DetailPrice>
204-
// </DetailItem>
205-
// );
206-
// }
207-
208-
// renderSeer() {
209-
// return this.renderAdditionalFeature({
210-
// featureKey: 'seer',
211-
// title: t('Seer: Sentry AI Enhancements'),
212-
// description: t('Surface insights and propose solutions to fix bugs faster.'),
213-
// priceCents: SEER_MONTHLY_PRICE_CENTS,
214-
// enabledField: 'seerEnabled',
215-
// });
216-
// }
217-
218177
renderDetailItems = () => {
219178
const {activePlan, discountInfo} = this.props;
220179

static/gsApp/views/amCheckout/checkoutOverviewV2.spec.tsx

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import SubscriptionStore from 'getsentry/stores/subscriptionStore';
88
import {PlanTier} from 'getsentry/types';
99
import AMCheckout from 'getsentry/views/amCheckout/';
1010
import CheckoutOverviewV2 from 'getsentry/views/amCheckout/checkoutOverviewV2';
11-
import type {CheckoutFormData} from 'getsentry/views/amCheckout/types';
11+
import {type CheckoutFormData, SelectableProduct} from 'getsentry/views/amCheckout/types';
1212

1313
describe('CheckoutOverviewV2', function () {
1414
const api = new MockApiClient();
@@ -81,6 +81,11 @@ describe('CheckoutOverviewV2', function () {
8181
uptime: 1,
8282
},
8383
onDemandMaxSpend: 5000,
84+
selectedProducts: {
85+
[SelectableProduct.SEER]: {
86+
enabled: true,
87+
},
88+
},
8489
};
8590

8691
render(
@@ -94,8 +99,8 @@ describe('CheckoutOverviewV2', function () {
9499
/>
95100
);
96101

97-
expect(screen.getByText('Sentry Team Plan')).toBeInTheDocument();
98102
expect(screen.getByText('All Sentry Products')).toBeInTheDocument();
103+
expect(screen.getByTestId('seer-reserved')).toBeInTheDocument(); // .toHaveTextContent('Seer $216/yr'); TODO(seer): uncomment this once fixtures are updated with pricing schedule
99104
expect(screen.getByText('Total Annual Charges')).toBeInTheDocument();
100105
expect(screen.getByText('$312/yr')).toBeInTheDocument();
101106
expect(screen.getByTestId('additional-monthly-charge')).toHaveTextContent(
@@ -161,4 +166,39 @@ describe('CheckoutOverviewV2', function () {
161166
expect(screen.queryByTestId('additional-monthly-charge')).not.toBeInTheDocument();
162167
expect(screen.getAllByText('Product not available')[0]).toBeInTheDocument();
163168
});
169+
170+
it('does not show seer when not enabled', function () {
171+
const formData: CheckoutFormData = {
172+
plan: 'am3_team_auf',
173+
reserved: {
174+
errors: 100000,
175+
attachments: 25,
176+
replays: 50,
177+
spans: 10_000_000,
178+
monitorSeats: 1,
179+
profileDuration: 0,
180+
profileDurationUI: 0,
181+
uptime: 1,
182+
},
183+
onDemandMaxSpend: 5000,
184+
selectedProducts: {
185+
[SelectableProduct.SEER]: {
186+
enabled: false,
187+
},
188+
},
189+
};
190+
191+
render(
192+
<CheckoutOverviewV2
193+
activePlan={teamPlanAnnual}
194+
billingConfig={billingConfig}
195+
formData={formData}
196+
onUpdate={jest.fn()}
197+
organization={organization}
198+
subscription={subscription}
199+
/>
200+
);
201+
202+
expect(screen.queryByTestId('seer-reserved')).not.toBeInTheDocument();
203+
});
164204
});

static/gsApp/views/amCheckout/checkoutOverviewV2.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ function CheckoutOverviewV2({activePlan, formData, onUpdate: _onUpdate}: Props)
170170
const hasAtLeastOneSelectedProduct = Object.values(
171171
activePlan.availableReservedBudgetTypes
172172
).some(budgetTypeInfo => {
173-
return formData.selectedProducts[
173+
return formData.selectedProducts?.[
174174
budgetTypeInfo.apiName as string as SelectableProduct
175175
]?.enabled;
176176
});
@@ -187,7 +187,7 @@ function CheckoutOverviewV2({activePlan, formData, onUpdate: _onUpdate}: Props)
187187
{Object.values(activePlan.availableReservedBudgetTypes).map(
188188
budgetTypeInfo => {
189189
const formDataForProduct =
190-
formData.selectedProducts[
190+
formData.selectedProducts?.[
191191
budgetTypeInfo.apiName as string as SelectableProduct
192192
];
193193
if (!formDataForProduct) {

static/gsApp/views/amCheckout/steps/productSelect.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function ProductSelect({
8484
...formData.selectedProducts,
8585
[productInfo.apiName]: {
8686
enabled:
87-
!formData.selectedProducts[
87+
!formData.selectedProducts?.[
8888
productInfo.apiName as string as SelectableProduct
8989
]?.enabled,
9090
},
@@ -94,14 +94,14 @@ function ProductSelect({
9494
>
9595
<ButtonContent
9696
color={
97-
formData.selectedProducts[
97+
formData.selectedProducts?.[
9898
productInfo.apiName as string as SelectableProduct
9999
]?.enabled
100100
? checkoutInfo.color
101101
: theme.textColor
102102
}
103103
>
104-
{formData.selectedProducts[
104+
{formData.selectedProducts?.[
105105
productInfo.apiName as string as SelectableProduct
106106
]?.enabled ? (
107107
<Fragment>

static/gsApp/views/amCheckout/steps/reviewAndConfirm.spec.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import SubscriptionStore from 'getsentry/stores/subscriptionStore';
1717
import {PlanTier} from 'getsentry/types';
1818
import trackGetsentryAnalytics from 'getsentry/utils/trackGetsentryAnalytics';
1919
import AMCheckout from 'getsentry/views/amCheckout/';
20+
import {SelectableProduct} from 'getsentry/views/amCheckout/types';
2021
import {getCheckoutAPIData} from 'getsentry/views/amCheckout/utils';
2122

2223
import ReviewAndConfirm from './reviewAndConfirm';
@@ -264,6 +265,11 @@ describe('AmCheckout > ReviewAndConfirm', function () {
264265
const updatedData = {
265266
...formData,
266267
reserved: {...formData.reserved, errors: reservedErrors},
268+
selectedProducts: {
269+
[SelectableProduct.SEER]: {
270+
enabled: true,
271+
},
272+
},
267273
};
268274
render(<ReviewAndConfirm {...stepProps} formData={updatedData} isActive />, {
269275
deprecatedRouterMocks: true,
@@ -287,6 +293,7 @@ describe('AmCheckout > ReviewAndConfirm', function () {
287293
)
288294
);
289295

296+
// TODO: Add seer analytics
290297
expect(trackGetsentryAnalytics).toHaveBeenCalledWith('checkout.upgrade', {
291298
organization,
292299
subscription,

static/gsApp/views/amCheckout/types.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ export enum SelectableProduct {
1717

1818
type BaseCheckoutData = {
1919
plan: string;
20-
selectedProducts: Record<SelectableProduct, SelectedProductData>;
2120
applyNow?: boolean;
2221
onDemandBudget?: OnDemandBudgets;
2322
onDemandMaxSpend?: number;
23+
selectedProducts?: Record<SelectableProduct, SelectedProductData>;
2424
};
2525

2626
export type SelectedProductData = {

static/gsApp/views/amCheckout/utils.spec.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {PlanDetailsLookupFixture} from 'getsentry-test/fixtures/planDetailsLooku
33
import {DataCategory} from 'sentry/types/core';
44

55
import {InvoiceItemType, PlanTier} from 'getsentry/types';
6+
import {SelectableProduct} from 'getsentry/views/amCheckout/types';
67
import * as utils from 'getsentry/views/amCheckout/utils';
78
import {getCheckoutAPIData} from 'getsentry/views/amCheckout/utils';
89

@@ -11,6 +12,11 @@ describe('utils', function () {
1112
const teamPlanAnnual = PlanDetailsLookupFixture('am1_team_auf')!;
1213
const bizPlan = PlanDetailsLookupFixture('am1_business')!;
1314
const bizPlanAnnual = PlanDetailsLookupFixture('am1_business_auf')!;
15+
const DEFAULT_SELECTED_PRODUCTS = {
16+
[SelectableProduct.SEER]: {
17+
enabled: false,
18+
},
19+
};
1420

1521
describe('getReservedTotal', function () {
1622
it('can get base price for team plan', function () {
@@ -21,6 +27,7 @@ describe('utils', function () {
2127
transactions: 100_000,
2228
attachments: 1,
2329
},
30+
selectedProducts: DEFAULT_SELECTED_PRODUCTS,
2431
});
2532
expect(priceDollars).toBe('29');
2633
});
@@ -33,6 +40,7 @@ describe('utils', function () {
3340
transactions: 100_000,
3441
attachments: 1,
3542
},
43+
selectedProducts: DEFAULT_SELECTED_PRODUCTS,
3644
});
3745
expect(priceDollars).toBe('312');
3846
});
@@ -45,6 +53,7 @@ describe('utils', function () {
4553
transactions: 100_000,
4654
attachments: 1,
4755
},
56+
selectedProducts: DEFAULT_SELECTED_PRODUCTS,
4857
});
4958
expect(priceDollars).toBe('89');
5059
});
@@ -57,6 +66,7 @@ describe('utils', function () {
5766
transactions: 100_000,
5867
attachments: 1,
5968
},
69+
selectedProducts: DEFAULT_SELECTED_PRODUCTS,
6070
});
6171
expect(priceDollars).toBe('960');
6272
});
@@ -69,6 +79,7 @@ describe('utils', function () {
6979
transactions: 100_000,
7080
attachments: 1,
7181
},
82+
selectedProducts: DEFAULT_SELECTED_PRODUCTS,
7283
});
7384
expect(priceDollars).toBe('1,992');
7485
});
@@ -81,8 +92,7 @@ describe('utils', function () {
8192
transactions: 100_000,
8293
attachments: 1,
8394
},
84-
seerEnabled: true,
85-
seerBudget: 2000,
95+
selectedProducts: DEFAULT_SELECTED_PRODUCTS,
8696
});
8797
expect(priceDollars).toBe('49');
8898
});
@@ -95,8 +105,7 @@ describe('utils', function () {
95105
transactions: 100_000,
96106
attachments: 1,
97107
},
98-
seerEnabled: false,
99-
seerBudget: 2000,
108+
selectedProducts: DEFAULT_SELECTED_PRODUCTS,
100109
});
101110
expect(priceDollars).toBe('29');
102111
});
@@ -369,6 +378,7 @@ describe('utils', function () {
369378
attachments: 70,
370379
profileDuration: 80,
371380
},
381+
selectedProducts: DEFAULT_SELECTED_PRODUCTS,
372382
};
373383

374384
expect(getCheckoutAPIData({formData})).toEqual({
@@ -383,6 +393,7 @@ describe('utils', function () {
383393
reservedUptime: 60,
384394
reservedAttachments: 70,
385395
reservedProfileDuration: 80,
396+
seer: false,
386397
});
387398
});
388399
});

0 commit comments

Comments
 (0)