Skip to content

Commit 923dc42

Browse files
authored
chore(billing): Cleanup NextPlanInfo interface and related tests (#94716)
This PR cleans up some unused stuff in the nextPlanInfo interface and updates the related tests. Originally I had recreated a wrapper around the categoryCredits object where the errorCredits stuff was, but realized that was already being accounted for in `getAM3MigrationCredits` function. So I just wrote a new test confirming that and marked the cohort as for test only. It can be updated in the future Closes https://linear.app/getsentry/issue/BIL-963/clean-up-category-specific-fields-for-nextplaninfo <!-- Sentry employees and contractors can delete or ignore the following. --> ### Legal Boilerplate Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.
1 parent 94bcdf1 commit 923dc42

File tree

4 files changed

+87
-69
lines changed

4 files changed

+87
-69
lines changed

static/gsApp/types/index.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,7 @@ export enum CohortId {
804804
EIGHTH = 8,
805805
NINTH = 9,
806806
TENTH = 10,
807+
TEST_ONE = 111,
807808
}
808809

809810
/** @internal exported for tests only */
@@ -813,18 +814,13 @@ export type Cohort = {
813814
secondDiscount: number;
814815
};
815816

816-
// TODO(data categories): BIL-963
817817
export type NextPlanInfo = {
818818
contractPeriod: string;
819819
discountAmount: number;
820820
discountMonths: number;
821-
errorCredits: number;
822-
errorCreditsMonths: number;
823821
id: string;
824822
name: string;
825823
reserved: Partial<Record<DataCategory, number>>;
826-
reservedAttachments: number;
827-
reservedErrors: number;
828824
totalPrice: number;
829825
categoryCredits?: Partial<
830826
Record<
@@ -835,7 +831,6 @@ export type NextPlanInfo = {
835831
}
836832
>
837833
>;
838-
reservedTransactions?: number;
839834
};
840835

841836
export type PlanMigration = {

static/gsApp/views/subscriptionPage/planMigrationActive/index.spec.tsx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,3 +869,46 @@ describe('PlanMigrationActive cohort 10', function () {
869869
);
870870
});
871871
});
872+
873+
describe('PlanMigrationActive cohort 111 -- TEST ONLY', function () {
874+
const organization = OrganizationFixture();
875+
const subscription = SubscriptionFixture({
876+
plan: 'am3_business_auf',
877+
organization,
878+
});
879+
880+
const migrationDate = moment().add(1, 'days').format('ll');
881+
const migration = PlanMigrationFixture({
882+
cohortId: CohortId.TEST_ONE,
883+
effectiveAt: migrationDate,
884+
});
885+
886+
function renderSimple() {
887+
render(<PlanMigrationActive migration={migration} subscription={subscription} />);
888+
}
889+
890+
it('renders with active migration', function () {
891+
renderSimple();
892+
});
893+
894+
it('renders plan migration table', function () {
895+
renderSimple();
896+
expect(screen.getByRole('table')).toBeInTheDocument();
897+
expect(screen.getAllByRole('row')).toHaveLength(8);
898+
});
899+
900+
it('renders combined credit message', function () {
901+
renderSimple();
902+
expect(screen.getByTestId('recurring-credits')).toHaveTextContent(
903+
/\*We'll provide an additional 100000 errors for the next 1 months, 100000 replays for the next 1 months, and 100000 spans for the next 1 months following the end of your current annual contract, at no charge./
904+
);
905+
});
906+
907+
it('renders monitor seats row', function () {
908+
renderSimple();
909+
expect(screen.getByTestId('current-monitorSeats')).toHaveTextContent(
910+
/1 cron monitor/
911+
);
912+
expect(screen.getByTestId('new-monitorSeats')).toHaveTextContent(/1 cron monitor/);
913+
});
914+
});

static/gsApp/views/subscriptionPage/planMigrationActive/planMigrationTable.tsx

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
type PlanMigration,
1414
type Subscription,
1515
} from 'getsentry/types';
16-
import {formatReservedWithUnits} from 'getsentry/utils/billing';
1716
import {displayPrice} from 'getsentry/views/amCheckout/utils';
1817
import {AlertStripedTable} from 'getsentry/views/subscriptionPage/styles';
1918

@@ -41,7 +40,6 @@ function PlanMigrationTable({subscription, migration}: Props) {
4140
// Setting default to monthly to handle nextPlan if the endpoint update is not updated yet
4241
// Prior plan migrations are all monthly contracts
4342
const nextPlanTerm = nextPlan.contractPeriod ?? MONTHLY;
44-
const hasErrorCredits = !!(nextPlan.errorCredits && nextPlan.errorCreditsMonths);
4543
// The nextPlan.discountAmount is handled differently for monthly & annual billing intervals. Using these checks to display correct info
4644
const hasMonthlyDiscount = !!(
4745
nextPlan.discountAmount &&
@@ -109,7 +107,7 @@ function PlanMigrationTable({subscription, migration}: Props) {
109107
DataCategoryExact.ERROR,
110108
subscription
111109
)}
112-
hasCredits={hasErrorCredits}
110+
hasCredits={!!nextPlan.categoryCredits?.[DataCategory.ERRORS]?.credits}
113111
/>
114112
{/* TODO(data categories): BIL-955 */}
115113
{isAM3Migration
@@ -185,24 +183,6 @@ function PlanMigrationTable({subscription, migration}: Props) {
185183
)}
186184
</tbody>
187185
</AlertStripedTable>
188-
{hasErrorCredits && (
189-
<Credits data-test-id="error-credits">
190-
*
191-
{tct(
192-
'We will provide an extra [errorCredits] errors for [errorCreditsMonths] months at no additional charge.',
193-
{
194-
errorCredits: formatReservedWithUnits(
195-
nextPlan.errorCredits || 0,
196-
DataCategory.ERRORS,
197-
{
198-
isAbbreviated: true,
199-
}
200-
),
201-
errorCreditsMonths: nextPlan.errorCreditsMonths,
202-
}
203-
)}
204-
</Credits>
205-
)}
206186
{hasMonthlyDiscount && (
207187
<Credits data-test-id="dollar-credits">
208188
*

tests/js/getsentry-test/fixtures/planMigration.ts

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@ const SecondCohort: Cohort = {
77
id: 'am1_team',
88
name: 'Team',
99
totalPrice: 4400,
10-
reservedErrors: 100000,
11-
reservedTransactions: 100000,
12-
reservedAttachments: 1,
10+
1311
reserved: {errors: 100000, transactions: 100000, attachments: 1},
14-
errorCredits: 0,
15-
errorCreditsMonths: 0,
1612
discountAmount: 1500,
1713
discountMonths: 5,
1814
contractPeriod: 'monthly',
15+
categoryCredits: {
16+
errors: {
17+
credits: 0,
18+
months: 0,
19+
},
20+
},
1921
},
2022
secondDiscount: 0,
2123
};
@@ -26,12 +28,7 @@ const ThirdCohort: Cohort = {
2628
id: 'am2_team',
2729
name: 'Team',
2830
totalPrice: 4400,
29-
reservedErrors: 100000,
30-
reservedTransactions: 100000,
31-
reservedAttachments: 1,
3231
reserved: {errors: 100000, transactions: 100000, attachments: 1},
33-
errorCredits: 0,
34-
errorCreditsMonths: 0,
3532
discountAmount: 1800,
3633
discountMonths: 5,
3734
contractPeriod: 'monthly',
@@ -45,12 +42,7 @@ const FourthCohort: Cohort = {
4542
id: 'am2_team',
4643
name: 'Team',
4744
totalPrice: 48000,
48-
reservedErrors: 100000,
49-
reservedTransactions: 100000,
50-
reservedAttachments: 1,
5145
reserved: {errors: 100000, transactions: 100000, attachments: 1},
52-
errorCredits: 0,
53-
errorCreditsMonths: 0,
5446
discountAmount: 16800,
5547
discountMonths: 1,
5648
contractPeriod: 'annual',
@@ -64,12 +56,7 @@ const FifthCohort: Cohort = {
6456
id: 'am2_business',
6557
name: 'Business',
6658
totalPrice: 48400,
67-
reservedErrors: 1_000_000,
68-
reservedTransactions: 100000,
69-
reservedAttachments: 1,
7059
reserved: {errors: 1_000_000, transactions: 100000, attachments: 1},
71-
errorCredits: 0,
72-
errorCreditsMonths: 0,
7360
discountAmount: 28500,
7461
discountMonths: 5,
7562
contractPeriod: 'monthly',
@@ -83,12 +70,7 @@ const SixthCohort: Cohort = {
8370
id: 'am2_team',
8471
name: 'Team',
8572
totalPrice: 4400,
86-
reservedErrors: 100000,
87-
reservedTransactions: 100000,
88-
reservedAttachments: 1,
8973
reserved: {errors: 100000, transactions: 100000, attachments: 1},
90-
errorCredits: 0,
91-
errorCreditsMonths: 0,
9274
discountAmount: 1800,
9375
discountMonths: 5,
9476
contractPeriod: 'monthly',
@@ -102,12 +84,7 @@ const SeventhCohort: Cohort = {
10284
id: 'am2_business',
10385
name: 'Business',
10486
totalPrice: 523200,
105-
reservedErrors: 1_000_000,
106-
reservedTransactions: 100000,
107-
reservedAttachments: 1,
10887
reserved: {errors: 1_000_000, transactions: 100000, attachments: 1},
109-
errorCredits: 0,
110-
errorCreditsMonths: 0,
11188
discountAmount: 308400,
11289
discountMonths: 1,
11390
contractPeriod: 'annual',
@@ -121,8 +98,6 @@ const EighthCohort: Cohort = {
12198
id: 'am3_business',
12299
name: 'Business',
123100
totalPrice: 89_00,
124-
reservedErrors: 50_000,
125-
reservedAttachments: 1,
126101
reserved: {
127102
errors: 50_000,
128103
replays: 50,
@@ -136,8 +111,6 @@ const EighthCohort: Cohort = {
136111
months: 2,
137112
},
138113
},
139-
errorCredits: 0,
140-
errorCreditsMonths: 0,
141114
discountAmount: 0,
142115
discountMonths: 1,
143116
contractPeriod: 'monthly',
@@ -151,8 +124,6 @@ const NinthCohort: Cohort = {
151124
id: 'am3_business',
152125
name: 'Business',
153126
totalPrice: 960_00,
154-
reservedErrors: 50_000,
155-
reservedAttachments: 1,
156127
reserved: {
157128
errors: 50_000,
158129
replays: 50,
@@ -166,8 +137,6 @@ const NinthCohort: Cohort = {
166137
months: 2,
167138
},
168139
},
169-
errorCredits: 0,
170-
errorCreditsMonths: 0,
171140
discountAmount: 0,
172141
discountMonths: 1,
173142
contractPeriod: 'annual',
@@ -181,17 +150,47 @@ const TenthCohort: Cohort = {
181150
id: 'am3_business',
182151
name: 'Business',
183152
totalPrice: 960_00,
184-
reservedErrors: 50_000,
185-
reservedAttachments: 1,
186153
reserved: {
187154
errors: 50_000,
188155
replays: 50,
189156
spans: 10_000_000,
190157
attachments: 1,
191158
monitorSeats: 1,
192159
},
193-
errorCredits: 0,
194-
errorCreditsMonths: 0,
160+
discountAmount: 0,
161+
discountMonths: 1,
162+
contractPeriod: 'annual',
163+
},
164+
secondDiscount: 0,
165+
};
166+
167+
const testOneCohort: Cohort = {
168+
cohortId: CohortId.TEST_ONE,
169+
nextPlan: {
170+
id: 'am3_business',
171+
name: 'Business',
172+
totalPrice: 960_00,
173+
reserved: {
174+
errors: 50_000,
175+
replays: 50,
176+
spans: 10_000_000,
177+
attachments: 1,
178+
monitorSeats: 1,
179+
},
180+
categoryCredits: {
181+
errors: {
182+
credits: 100_000,
183+
months: 1,
184+
},
185+
replays: {
186+
credits: 100_000,
187+
months: 1,
188+
},
189+
spans: {
190+
credits: 100_000,
191+
months: 1,
192+
},
193+
},
195194
discountAmount: 0,
196195
discountMonths: 1,
197196
contractPeriod: 'annual',
@@ -209,6 +208,7 @@ const CohortLookup: Record<CohortId, Cohort> = {
209208
[CohortId.EIGHTH]: EighthCohort,
210209
[CohortId.NINTH]: NinthCohort,
211210
[CohortId.TENTH]: TenthCohort,
211+
[CohortId.TEST_ONE]: testOneCohort,
212212
};
213213

214214
export function PlanMigrationFixture({

0 commit comments

Comments
 (0)