Skip to content

Commit 22ebf38

Browse files
ref(plan migrations): Parse categories + general improvements (#95709)
Closes https://linear.app/getsentry/issue/BIL-955/parse-categories-for-plan-migration-table
1 parent 077396c commit 22ebf38

File tree

4 files changed

+140
-157
lines changed

4 files changed

+140
-157
lines changed

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ describe('PlanMigrationActive cohort 8', function () {
604604
expect(screen.queryByTestId('current-renewal')).not.toBeInTheDocument();
605605
});
606606

607+
// TODO(isabella): condense category-specific assertions into a single test
607608
it('renders errors row', function () {
608609
renderSimple();
609610
expect(screen.getByTestId('current-errors')).toHaveTextContent(/100K errors/);
@@ -616,6 +617,7 @@ describe('PlanMigrationActive cohort 8', function () {
616617
/100K performance units/
617618
);
618619
expect(screen.getByTestId('new-spans')).toHaveTextContent(/10M spans/);
620+
expect(screen.getByText(/Tracing and Performance Monitoring/)).toBeInTheDocument();
619621
});
620622

621623
it('renders attachments row', function () {
@@ -727,6 +729,7 @@ describe('PlanMigrationActive cohort 9', function () {
727729
/100K performance units/
728730
);
729731
expect(screen.getByTestId('new-spans')).toHaveTextContent(/10M spans/);
732+
expect(screen.getByText(/Tracing and Performance Monitoring/)).toBeInTheDocument();
730733
});
731734

732735
it('renders attachments row', function () {
@@ -832,6 +835,7 @@ describe('PlanMigrationActive cohort 10', function () {
832835
/100K performance units/
833836
);
834837
expect(screen.getByTestId('new-spans')).toHaveTextContent(/10M spans/);
838+
expect(screen.getByText(/Tracing and Performance Monitoring/)).toBeInTheDocument();
835839
});
836840

837841
it('renders attachments row', function () {
@@ -881,10 +885,7 @@ describe('PlanMigrationActive cohort 111 -- TEST ONLY', function () {
881885

882886
it('renders with active migration', function () {
883887
renderSimple();
884-
});
885-
886-
it('renders plan migration table', function () {
887-
renderSimple();
888+
expect(screen.getByTestId('plan-migration-panel')).toBeInTheDocument();
888889
expect(screen.getByRole('table')).toBeInTheDocument();
889890
expect(screen.getAllByRole('row')).toHaveLength(8);
890891
});
@@ -896,11 +897,12 @@ describe('PlanMigrationActive cohort 111 -- TEST ONLY', function () {
896897
);
897898
});
898899

899-
it('renders monitor seats row', function () {
900+
it('renders spans row with existing spans', function () {
900901
renderSimple();
901-
expect(screen.getByTestId('current-monitorSeats')).toHaveTextContent(
902-
/1 cron monitor/
903-
);
904-
expect(screen.getByTestId('new-monitorSeats')).toHaveTextContent(/1 cron monitor/);
902+
expect(screen.getByTestId('current-spans')).toHaveTextContent(/10M spans/);
903+
expect(screen.getByTestId('new-spans')).toHaveTextContent(/10M spans/);
904+
expect(
905+
screen.queryByText(/Tracing and Performance Monitoring/)
906+
).not.toBeInTheDocument();
905907
});
906908
});

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

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import styled from '@emotion/styled';
22

33
import {DATA_CATEGORY_INFO} from 'sentry/constants';
44
import {IconArrow} from 'sentry/icons';
5-
import {t, tct} from 'sentry/locale';
6-
import {space} from 'sentry/styles/space';
5+
import {tct} from 'sentry/locale';
76
import type {DataCategory} from 'sentry/types/core';
87
import {DataCategoryExact} from 'sentry/types/core';
98

@@ -17,6 +16,8 @@ type DataRow = {
1716
nextValue: number | null;
1817
type: DataCategoryExact;
1918
hasCredits?: boolean;
19+
previousType?: DataCategoryExact;
20+
titleOverride?: string;
2021
};
2122

2223
type PriceRow = {
@@ -100,34 +101,6 @@ function PlanMigrationRow(props: Props) {
100101
currentValue = props.currentValue;
101102
nextValue = props.nextValue;
102103
break;
103-
case DataCategoryExact.ERROR:
104-
currentValue = formatCategoryRowString(props.type, props.currentValue, options);
105-
// eslint-disable-next-line no-case-declarations
106-
const formattedErrors = formatCategoryRowString(
107-
props.type,
108-
props.nextValue,
109-
options
110-
);
111-
nextValue = props.hasCredits ? `${formattedErrors}*` : formattedErrors;
112-
break;
113-
case DataCategoryExact.TRANSACTION:
114-
case DataCategoryExact.REPLAY:
115-
case DataCategoryExact.MONITOR_SEAT:
116-
case DataCategoryExact.ATTACHMENT:
117-
case DataCategoryExact.LOG_BYTE:
118-
case DataCategoryExact.PROFILE_DURATION:
119-
currentValue = formatCategoryRowString(props.type, props.currentValue, options);
120-
nextValue = formatCategoryRowString(props.type, props.nextValue, options);
121-
break;
122-
case DataCategoryExact.SPAN:
123-
currentValue = formatCategoryRowString(
124-
DataCategoryExact.TRANSACTION,
125-
props.currentValue,
126-
options
127-
);
128-
nextValue = formatCategoryRowString(props.type, props.nextValue, options);
129-
currentTitle = t('Tracing and Performance Monitoring');
130-
break;
131104
case 'price':
132105
currentValue = displayPrice({cents: props.currentValue});
133106
discountPrice = displayPrice({cents: props.discountPrice});
@@ -139,8 +112,24 @@ function PlanMigrationRow(props: Props) {
139112
nextValue = displayPrice({cents: props.nextValue});
140113
currentTitle = 'renewal price';
141114
break;
142-
default:
143-
return null;
115+
default: {
116+
// assume DataCategoryExact
117+
currentValue = formatCategoryRowString(
118+
props.previousType ?? props.type,
119+
props.currentValue,
120+
options
121+
);
122+
const formattedNextValue = formatCategoryRowString(
123+
props.type,
124+
props.nextValue,
125+
options
126+
);
127+
nextValue = props.hasCredits ? `${formattedNextValue}*` : formattedNextValue;
128+
if (props.titleOverride) {
129+
currentTitle = props.titleOverride;
130+
}
131+
break;
132+
}
144133
}
145134

146135
const hasDiscount =
@@ -171,7 +160,7 @@ const Title = styled('td')`
171160

172161
const DiscountCell = styled('td')`
173162
display: flex;
174-
gap: ${space(1)};
163+
gap: ${p => p.theme.space.md};
175164
justify-content: flex-end;
176165
`;
177166

0 commit comments

Comments
 (0)