|
@@ -1,11 +1,42 @@
|
|
|
import {mountWithTheme} from 'sentry-test/enzyme';
|
|
|
import {initializeOrg} from 'sentry-test/initializeOrg';
|
|
|
+import {addMetricsDataMock} from 'sentry-test/performance/addMetricsDataMock';
|
|
|
import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
|
|
|
|
|
|
import {t} from 'sentry/locale';
|
|
|
+import {Organization} from 'sentry/types/organization';
|
|
|
+import {Project} from 'sentry/types/project';
|
|
|
import {DisplayModes} from 'sentry/utils/discover/types';
|
|
|
+import {MetricsCardinalityProvider} from 'sentry/utils/performance/contexts/metricsCardinality';
|
|
|
import ChartFooter from 'sentry/views/eventsV2/chartFooter';
|
|
|
|
|
|
+function metricsCardinalityWrapped(
|
|
|
+ children: React.ReactNode,
|
|
|
+ organization: Organization,
|
|
|
+ project: Project
|
|
|
+) {
|
|
|
+ const routerLocation: {query: {project?: number}} = {
|
|
|
+ query: {project: parseInt(project.id, 10)},
|
|
|
+ };
|
|
|
+
|
|
|
+ const router = {
|
|
|
+ location: routerLocation,
|
|
|
+ };
|
|
|
+
|
|
|
+ const initialData = initializeOrg({
|
|
|
+ organization,
|
|
|
+ projects: [project],
|
|
|
+ project,
|
|
|
+ router,
|
|
|
+ });
|
|
|
+ const location = initialData.router.location;
|
|
|
+ return (
|
|
|
+ <MetricsCardinalityProvider location={location} organization={organization}>
|
|
|
+ {children}
|
|
|
+ </MetricsCardinalityProvider>
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
describe('EventsV2 > ChartFooter', function () {
|
|
|
const features = ['discover-basic'];
|
|
|
const yAxisValue = ['count()', 'failure_count()'];
|
|
@@ -14,9 +45,11 @@ describe('EventsV2 > ChartFooter', function () {
|
|
|
{label: 'failure_count()', value: 'failure_count()'},
|
|
|
];
|
|
|
|
|
|
+ const project = TestStubs.Project();
|
|
|
+
|
|
|
afterEach(function () {});
|
|
|
|
|
|
- it('renders yAxis option using OptionCheckboxSelector using entire yAxisValue', async function () {
|
|
|
+ it('renders yAxis option using OptionCheckboxSelector using entire yAxisValue', function () {
|
|
|
const organization = TestStubs.Organization({
|
|
|
features: [...features],
|
|
|
});
|
|
@@ -31,7 +64,7 @@ describe('EventsV2 > ChartFooter', function () {
|
|
|
projects: [],
|
|
|
});
|
|
|
|
|
|
- const wrapper = mountWithTheme(
|
|
|
+ const chartFooter = (
|
|
|
<ChartFooter
|
|
|
organization={organization}
|
|
|
total={100}
|
|
@@ -43,11 +76,16 @@ describe('EventsV2 > ChartFooter', function () {
|
|
|
onDisplayChange={() => undefined}
|
|
|
onTopEventsChange={() => undefined}
|
|
|
topEvents="5"
|
|
|
- />,
|
|
|
+ showBaseline={false}
|
|
|
+ setShowBaseline={() => undefined}
|
|
|
+ />
|
|
|
+ );
|
|
|
+
|
|
|
+ const wrapper = mountWithTheme(
|
|
|
+ metricsCardinalityWrapped(chartFooter, organization, project),
|
|
|
initialData.routerContext
|
|
|
);
|
|
|
|
|
|
- await tick();
|
|
|
wrapper.update();
|
|
|
|
|
|
const optionCheckboxSelector = wrapper.find('OptionSelector').last();
|
|
@@ -69,7 +107,7 @@ describe('EventsV2 > ChartFooter', function () {
|
|
|
projects: [],
|
|
|
});
|
|
|
|
|
|
- const wrapper = mountWithTheme(
|
|
|
+ const chartFooter = (
|
|
|
<ChartFooter
|
|
|
organization={organization}
|
|
|
total={100}
|
|
@@ -81,7 +119,13 @@ describe('EventsV2 > ChartFooter', function () {
|
|
|
onDisplayChange={() => undefined}
|
|
|
onTopEventsChange={() => undefined}
|
|
|
topEvents="5"
|
|
|
- />,
|
|
|
+ showBaseline={false}
|
|
|
+ setShowBaseline={() => undefined}
|
|
|
+ />
|
|
|
+ );
|
|
|
+
|
|
|
+ const wrapper = mountWithTheme(
|
|
|
+ metricsCardinalityWrapped(chartFooter, organization, project),
|
|
|
initialData.routerContext
|
|
|
);
|
|
|
|
|
@@ -98,7 +142,7 @@ describe('EventsV2 > ChartFooter', function () {
|
|
|
});
|
|
|
let yAxis = ['count()'];
|
|
|
|
|
|
- render(
|
|
|
+ const chartFooter = (
|
|
|
<ChartFooter
|
|
|
organization={organization}
|
|
|
total={100}
|
|
@@ -110,21 +154,92 @@ describe('EventsV2 > ChartFooter', function () {
|
|
|
onDisplayChange={() => undefined}
|
|
|
onTopEventsChange={() => undefined}
|
|
|
topEvents="5"
|
|
|
+ showBaseline={false}
|
|
|
+ setShowBaseline={() => undefined}
|
|
|
/>
|
|
|
);
|
|
|
|
|
|
+ render(metricsCardinalityWrapped(chartFooter, organization, project));
|
|
|
+
|
|
|
userEvent.click(screen.getByText('count()'));
|
|
|
userEvent.click(screen.getByText('failure_count()'));
|
|
|
expect(yAxis).toEqual(['failure_count()']);
|
|
|
});
|
|
|
|
|
|
+ it('disables processed baseline toggle if metrics cardinality conditions not met', function () {
|
|
|
+ const organization = TestStubs.Organization({
|
|
|
+ features: [...features, 'discover-metrics-baseline'],
|
|
|
+ });
|
|
|
+
|
|
|
+ const chartFooter = (
|
|
|
+ <ChartFooter
|
|
|
+ organization={organization}
|
|
|
+ total={100}
|
|
|
+ yAxisValue={['count()']}
|
|
|
+ yAxisOptions={yAxisOptions}
|
|
|
+ onAxisChange={jest.fn}
|
|
|
+ displayMode={DisplayModes.DEFAULT}
|
|
|
+ displayOptions={[{label: DisplayModes.DEFAULT, value: DisplayModes.DEFAULT}]}
|
|
|
+ onDisplayChange={() => undefined}
|
|
|
+ onTopEventsChange={() => undefined}
|
|
|
+ topEvents="5"
|
|
|
+ showBaseline={false}
|
|
|
+ setShowBaseline={() => undefined}
|
|
|
+ />
|
|
|
+ );
|
|
|
+
|
|
|
+ render(metricsCardinalityWrapped(chartFooter, organization, project));
|
|
|
+
|
|
|
+ expect(screen.getByText(/Processed events/i)).toBeInTheDocument();
|
|
|
+ expect(screen.getByTestId('processed-events-toggle')).toBeDisabled();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('enables processed baseline toggle if metrics cardinality conditions met', function () {
|
|
|
+ addMetricsDataMock({
|
|
|
+ metricsCount: 100,
|
|
|
+ nullCount: 0,
|
|
|
+ unparamCount: 1,
|
|
|
+ });
|
|
|
+
|
|
|
+ const organization = TestStubs.Organization({
|
|
|
+ features: [
|
|
|
+ ...features,
|
|
|
+ 'discover-metrics-baseline',
|
|
|
+ 'performance-transaction-name-only-search',
|
|
|
+ 'organizations:performance-transaction-name-only-search',
|
|
|
+ ],
|
|
|
+ });
|
|
|
+
|
|
|
+ const chartFooter = (
|
|
|
+ <ChartFooter
|
|
|
+ organization={organization}
|
|
|
+ total={100}
|
|
|
+ yAxisValue={['count()']}
|
|
|
+ yAxisOptions={yAxisOptions}
|
|
|
+ onAxisChange={jest.fn}
|
|
|
+ displayMode={DisplayModes.DEFAULT}
|
|
|
+ displayOptions={[{label: DisplayModes.DEFAULT, value: DisplayModes.DEFAULT}]}
|
|
|
+ onDisplayChange={() => undefined}
|
|
|
+ onTopEventsChange={() => undefined}
|
|
|
+ topEvents="5"
|
|
|
+ showBaseline={false}
|
|
|
+ setShowBaseline={() => undefined}
|
|
|
+ />
|
|
|
+ );
|
|
|
+
|
|
|
+ render(metricsCardinalityWrapped(chartFooter, organization, project));
|
|
|
+
|
|
|
+ expect(screen.getByText(/Processed events/i)).toBeInTheDocument();
|
|
|
+ expect(screen.getByTestId('processed-events-toggle')).toBeEnabled();
|
|
|
+ });
|
|
|
+
|
|
|
it('renders multi value y-axis dropdown selector on a non-Top display', function () {
|
|
|
const organization = TestStubs.Organization({
|
|
|
features,
|
|
|
});
|
|
|
let yAxis = ['count()'];
|
|
|
|
|
|
- render(
|
|
|
+ const chartFooter = (
|
|
|
<ChartFooter
|
|
|
organization={organization}
|
|
|
total={100}
|
|
@@ -136,9 +251,13 @@ describe('EventsV2 > ChartFooter', function () {
|
|
|
onDisplayChange={() => undefined}
|
|
|
onTopEventsChange={() => undefined}
|
|
|
topEvents="5"
|
|
|
+ showBaseline={false}
|
|
|
+ setShowBaseline={() => undefined}
|
|
|
/>
|
|
|
);
|
|
|
|
|
|
+ render(metricsCardinalityWrapped(chartFooter, organization, project));
|
|
|
+
|
|
|
userEvent.click(screen.getByText('count()'));
|
|
|
userEvent.click(screen.getByText('failure_count()'));
|
|
|
expect(yAxis).toEqual(['count()', 'failure_count()']);
|