|
@@ -11,6 +11,7 @@ import * as modal from 'sentry/actionCreators/modal';
|
|
|
import {Client} from 'sentry/api';
|
|
|
import * as LineChart from 'sentry/components/charts/lineChart';
|
|
|
import SimpleTableChart from 'sentry/components/charts/simpleTableChart';
|
|
|
+import {MINUTE, SECOND} from 'sentry/utils/formatters';
|
|
|
import {MEPSettingProvider} from 'sentry/utils/performance/contexts/metricsEnhancedSetting';
|
|
|
import {DisplayType, Widget, WidgetType} from 'sentry/views/dashboards/types';
|
|
|
import WidgetCard from 'sentry/views/dashboards/widgetCard';
|
|
@@ -650,7 +651,7 @@ describe('Dashboards > WidgetCard', function () {
|
|
|
},
|
|
|
units: {
|
|
|
time: null,
|
|
|
- p95_measurements_custom: 'minute',
|
|
|
+ p95_measurements_custom: 'millisecond',
|
|
|
},
|
|
|
isMetricsData: true,
|
|
|
tips: {},
|
|
@@ -700,6 +701,101 @@ describe('Dashboards > WidgetCard', function () {
|
|
|
expect(yAxis.axisLabel.formatter(24, 'p95(measurements.custom)')).toEqual('24ms');
|
|
|
});
|
|
|
|
|
|
+ it('renders label in seconds when there is a transition from seconds to minutes in the y axis', async function () {
|
|
|
+ const spy = jest.spyOn(LineChart, 'LineChart');
|
|
|
+ const eventsStatsMock = MockApiClient.addMockResponse({
|
|
|
+ url: '/organizations/org-slug/events-stats/',
|
|
|
+ body: {
|
|
|
+ data: [
|
|
|
+ [
|
|
|
+ 1658262600,
|
|
|
+ [
|
|
|
+ {
|
|
|
+ count: 40 * SECOND,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 1658262601,
|
|
|
+ [
|
|
|
+ {
|
|
|
+ count: 50 * SECOND,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 1658262602,
|
|
|
+ [
|
|
|
+ {
|
|
|
+ count: MINUTE,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 1658262603,
|
|
|
+ [
|
|
|
+ {
|
|
|
+ count: 1.3 * MINUTE,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ meta: {
|
|
|
+ fields: {
|
|
|
+ time: 'date',
|
|
|
+ p50_transaction_duration: 'duration',
|
|
|
+ },
|
|
|
+ units: {
|
|
|
+ time: null,
|
|
|
+ p50_transaction_duration: 'millisecond',
|
|
|
+ },
|
|
|
+ isMetricsData: false,
|
|
|
+ tips: {},
|
|
|
+ },
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ renderWithProviders(
|
|
|
+ <WidgetCard
|
|
|
+ api={api}
|
|
|
+ organization={organization}
|
|
|
+ widget={{
|
|
|
+ title: '',
|
|
|
+ interval: '5m',
|
|
|
+ widgetType: WidgetType.DISCOVER,
|
|
|
+ displayType: DisplayType.LINE,
|
|
|
+ queries: [
|
|
|
+ {
|
|
|
+ conditions: '',
|
|
|
+ name: '',
|
|
|
+ fields: [],
|
|
|
+ columns: [],
|
|
|
+ aggregates: ['p50(transaction.duration)'],
|
|
|
+ orderby: '',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ }}
|
|
|
+ selection={selection}
|
|
|
+ isEditing={false}
|
|
|
+ onDelete={() => undefined}
|
|
|
+ onEdit={() => undefined}
|
|
|
+ onDuplicate={() => undefined}
|
|
|
+ renderErrorMessage={() => undefined}
|
|
|
+ showContextMenu
|
|
|
+ widgetLimitReached={false}
|
|
|
+ />
|
|
|
+ );
|
|
|
+ await waitFor(function () {
|
|
|
+ expect(eventsStatsMock).toHaveBeenCalled();
|
|
|
+ });
|
|
|
+ const {yAxis} = spy.mock.calls.pop()?.[0] ?? {};
|
|
|
+ expect(yAxis).toBeDefined();
|
|
|
+
|
|
|
+ // @ts-ignore
|
|
|
+ expect(yAxis.axisLabel.formatter(60000, 'p50(transaction.duration)')).toEqual('60s');
|
|
|
+ expect((yAxis as any).minInterval).toEqual(SECOND);
|
|
|
+ });
|
|
|
+
|
|
|
it('displays indexed badge in preview mode', async function () {
|
|
|
renderWithProviders(
|
|
|
<WidgetCard
|