File tree Expand file tree Collapse file tree 12 files changed +68
-27
lines changed
modals/metricWidgetViewerModal Expand file tree Collapse file tree 12 files changed +68
-27
lines changed Original file line number Diff line number Diff line change 1+ import { render , screen } from 'sentry-test/reactTestingLibrary' ;
2+ import { textWithMarkupMatcher } from 'sentry-test/utils' ;
3+
4+ import {
5+ EquationSymbol ,
6+ getEquationSymbol ,
7+ } from 'sentry/components/metrics/equationSymbol' ;
8+
9+ describe ( 'getEquationSymbol' , ( ) => {
10+ it ( 'should return the correct symbol' , ( ) => {
11+ expect ( getEquationSymbol ( 0 ) ) . toBe ( 'ƒ1' ) ;
12+ expect ( getEquationSymbol ( 1 ) ) . toBe ( 'ƒ2' ) ;
13+ } ) ;
14+ } ) ;
15+
16+ describe ( 'EquationSymbol' , ( ) => {
17+ it ( 'renders' , ( ) => {
18+ render ( < EquationSymbol equationId = { 0 } /> ) ;
19+ expect ( screen . getByText ( textWithMarkupMatcher ( 'ƒ1' ) ) ) . toBeInTheDocument ( ) ;
20+
21+ render ( < EquationSymbol equationId = { 5 } /> ) ;
22+ expect ( screen . getByText ( textWithMarkupMatcher ( 'ƒ6' ) ) ) . toBeInTheDocument ( ) ;
23+ } ) ;
24+ } ) ;
File renamed without changes.
Original file line number Diff line number Diff line change 1+ import { render , screen } from 'sentry-test/reactTestingLibrary' ;
2+
3+ import { getQuerySymbol , QuerySymbol } from 'sentry/components/metrics/querySymbol' ;
4+
5+ describe ( 'getQuerySymbol' , ( ) => {
6+ it ( 'should return the correct symbol' , ( ) => {
7+ expect ( getQuerySymbol ( 0 ) ) . toBe ( 'a' ) ;
8+ expect ( getQuerySymbol ( 1 ) ) . toBe ( 'b' ) ;
9+ expect ( getQuerySymbol ( 25 ) ) . toBe ( 'z' ) ;
10+ expect ( getQuerySymbol ( 26 ) ) . toBe ( 'aa' ) ;
11+ expect ( getQuerySymbol ( 27 ) ) . toBe ( 'ab' ) ;
12+ expect ( getQuerySymbol ( 52 ) ) . toBe ( 'ba' ) ;
13+ expect ( getQuerySymbol ( 53 ) ) . toBe ( 'bb' ) ;
14+ expect ( getQuerySymbol ( 77 ) ) . toBe ( 'bz' ) ;
15+ expect ( getQuerySymbol ( 78 ) ) . toBe ( 'ca' ) ;
16+ expect ( getQuerySymbol ( 702 ) ) . toBe ( 'aaa' ) ;
17+ } ) ;
18+ } ) ;
19+
20+ describe ( 'QuerySymbol' , ( ) => {
21+ it ( 'renders' , ( ) => {
22+ render ( < QuerySymbol queryId = { 0 } /> ) ;
23+ expect ( screen . getByText ( 'a' ) ) . toBeInTheDocument ( ) ;
24+
25+ render ( < QuerySymbol queryId = { 27 } /> ) ;
26+ expect ( screen . getByText ( 'ab' ) ) . toBeInTheDocument ( ) ;
27+ } ) ;
28+
29+ it ( 'does not render for negative query ids' , ( ) => {
30+ const { container} = render ( < QuerySymbol queryId = { - 1 } /> ) ;
31+ expect ( container ) . toBeEmptyDOMElement ( ) ;
32+ } ) ;
33+ } ) ;
File renamed without changes.
Original file line number Diff line number Diff line change @@ -8,7 +8,9 @@ import type {MenuItemProps} from 'sentry/components/dropdownMenu';
88import { DropdownMenu } from 'sentry/components/dropdownMenu' ;
99import Input , { type InputProps } from 'sentry/components/input' ;
1010import { CreateMetricAlertFeature } from 'sentry/components/metrics/createMetricAlertFeature' ;
11+ import { EquationSymbol } from 'sentry/components/metrics/equationSymbol' ;
1112import { QueryBuilder } from 'sentry/components/metrics/queryBuilder' ;
13+ import { getQuerySymbol , QuerySymbol } from 'sentry/components/metrics/querySymbol' ;
1214import { Tooltip } from 'sentry/components/tooltip' ;
1315import { DEFAULT_DEBOUNCE_DURATION , SLOW_TOOLTIP_DELAY } from 'sentry/constants' ;
1416import {
@@ -36,10 +38,8 @@ import type {
3638} from 'sentry/views/dashboards/metrics/types' ;
3739import { getMetricQueryName } from 'sentry/views/dashboards/metrics/utils' ;
3840import { DisplayType } from 'sentry/views/dashboards/types' ;
39- import { EquationSymbol } from 'sentry/views/metrics/equationSymbol' ;
4041import { EquationInput } from 'sentry/views/metrics/formulaInput' ;
4142import { getCreateAlert } from 'sentry/views/metrics/metricQueryContextMenu' ;
42- import { getQuerySymbol , QuerySymbol } from 'sentry/views/metrics/querySymbol' ;
4343
4444interface Props {
4545 addEquation : ( ) => void ;
Original file line number Diff line number Diff line change 11import { Client } from 'sentry/api' ;
2+ import { getQuerySymbol } from 'sentry/components/metrics/querySymbol' ;
23import type { MetricMeta , MRI } from 'sentry/types/metrics' ;
34import { convertToDashboardWidget } from 'sentry/utils/metrics/dashboard' ;
45import type { MetricsQuery } from 'sentry/utils/metrics/types' ;
56import { MetricDisplayType } from 'sentry/utils/metrics/types' ;
67import type { Widget } from 'sentry/views/dashboards/types' ;
7- import { getQuerySymbol } from 'sentry/views/metrics/querySymbol' ;
88// import types
99export type ImportDashboard = {
1010 description : string ;
Original file line number Diff line number Diff line change 11import { useMemo } from 'react' ;
22
3+ import { getEquationSymbol } from 'sentry/components/metrics/equationSymbol' ;
4+ import { getQuerySymbol } from 'sentry/components/metrics/querySymbol' ;
35import type { MRI } from 'sentry/types/metrics' ;
46import { unescapeMetricsFormula } from 'sentry/utils/metrics' ;
57import { NO_QUERY_ID } from 'sentry/utils/metrics/constants' ;
@@ -18,8 +20,6 @@ import {
1820 type WidgetQuery ,
1921 WidgetType ,
2022} from 'sentry/views/dashboards/types' ;
21- import { getEquationSymbol } from 'sentry/views/metrics/equationSymbol' ;
22- import { getQuerySymbol } from 'sentry/views/metrics/querySymbol' ;
2323import { getUniqueQueryIdGenerator } from 'sentry/views/metrics/utils/uniqueQueryId' ;
2424
2525function extendQuery ( query = '' , dashboardFilters ?: DashboardFilters ) {
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import {Button} from 'sentry/components/button';
88import ButtonBar from 'sentry/components/buttonBar' ;
99import { DropdownMenu } from 'sentry/components/dropdownMenu' ;
1010import { CreateMetricAlertFeature } from 'sentry/components/metrics/createMetricAlertFeature' ;
11+ import { QuerySymbol } from 'sentry/components/metrics/querySymbol' ;
1112import {
1213 IconBookmark ,
1314 IconDashboard ,
@@ -25,7 +26,6 @@ import useOrganization from 'sentry/utils/useOrganization';
2526import useRouter from 'sentry/utils/useRouter' ;
2627import { useMetricsContext } from 'sentry/views/metrics/context' ;
2728import { getCreateAlert } from 'sentry/views/metrics/metricQueryContextMenu' ;
28- import { QuerySymbol } from 'sentry/views/metrics/querySymbol' ;
2929import { useCreateDashboard } from 'sentry/views/metrics/useCreateDashboard' ;
3030import { useFormulaDependencies } from 'sentry/views/metrics/utils/useFormulaDependencies' ;
3131
Original file line number Diff line number Diff line change @@ -4,7 +4,9 @@ import * as echarts from 'echarts/core';
44
55import GuideAnchor from 'sentry/components/assistant/guideAnchor' ;
66import { Button } from 'sentry/components/button' ;
7+ import { EquationSymbol } from 'sentry/components/metrics/equationSymbol' ;
78import { QueryBuilder } from 'sentry/components/metrics/queryBuilder' ;
9+ import { getQuerySymbol , QuerySymbol } from 'sentry/components/metrics/querySymbol' ;
810import SwitchButton from 'sentry/components/switchButton' ;
911import { Tooltip } from 'sentry/components/tooltip' ;
1012import { IconAdd } from 'sentry/icons' ;
@@ -23,11 +25,9 @@ import useOrganization from 'sentry/utils/useOrganization';
2325import usePageFilters from 'sentry/utils/usePageFilters' ;
2426import { METRIC_CHART_GROUP } from 'sentry/views/metrics/constants' ;
2527import { useMetricsContext } from 'sentry/views/metrics/context' ;
26- import { EquationSymbol } from 'sentry/views/metrics/equationSymbol' ;
2728import { EquationInput } from 'sentry/views/metrics/formulaInput' ;
2829import { MetricFormulaContextMenu } from 'sentry/views/metrics/metricFormulaContextMenu' ;
2930import { MetricQueryContextMenu } from 'sentry/views/metrics/metricQueryContextMenu' ;
30- import { getQuerySymbol , QuerySymbol } from 'sentry/views/metrics/querySymbol' ;
3131import { useFormulaDependencies } from 'sentry/views/metrics/utils/useFormulaDependencies' ;
3232
3333export function Queries ( ) {
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments