Skip to content
Draft
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
19 changes: 19 additions & 0 deletions static/app/views/organizationStats/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,25 @@ describe('OrganizationStats', () => {
);
});

it('defaults to errors when dataCategory does not support external stats', async () => {
// Categories like monitorSeats have showExternalStats=false and are absent from
// CHART_OPTIONS_DATACATEGORY. Passing them via the URL should fall back to errors
// rather than crashing the chart with "Selected item is not supported".
render(<OrganizationStats />, {
organization,
initialRouterConfig: {
location: {
pathname: '/organizations/org-slug/stats/',
query: {dataCategory: DATA_CATEGORY_INFO.monitor_seat.plural},
},
},
});

// Should render without throwing and default to the Errors category
expect(await screen.findByText('Project(s) Stats')).toBeInTheDocument();
expect(screen.getAllByText('Errors')[0]).toBeInTheDocument();
});

it('does not leak query params onto next page links', async () => {
render(<OrganizationStats />, {
organization,
Expand Down
7 changes: 6 additions & 1 deletion static/app/views/organizationStats/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ export class OrganizationStatsInner extends Component<OrganizationStatsProps> {
const dataCategoryPlural = this.props.location?.query?.dataCategory;

const categories = Object.values(DATA_CATEGORY_INFO);
const info = categories.find(c => c.plural === dataCategoryPlural);
// Only consider categories that are shown in the usage chart (showExternalStats).
// Categories that don't have showExternalStats (e.g. monitorSeats) are not
// present in CHART_OPTIONS_DATACATEGORY and would cause a crash in UsageChart.
const info = categories.find(
c => c.plural === dataCategoryPlural && c.statsInfo.showExternalStats
);

// Default to errors
return info ?? DATA_CATEGORY_INFO.error;
Expand Down
Loading