Skip to content

Commit f1865d8

Browse files
committed
refactor: fixing test
1 parent 1c6c5e9 commit f1865d8

File tree

1 file changed

+50
-44
lines changed

1 file changed

+50
-44
lines changed

projects/observability/src/shared/dashboard/data/graphql/topology/topology-data-source.model.test.ts

Lines changed: 50 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { Color, isEqualIgnoreFunctions } from '@hypertrace/common';
1+
import { Color } from '@hypertrace/common';
22
import { GraphQlTimeRange, MetricAggregationType } from '@hypertrace/distributed-tracing';
33
import { GraphQlRequestCacheability, GraphQlRequestOptions } from '@hypertrace/graphql-client';
44
import { ModelApi } from '@hypertrace/hyperdash';
55
import { ObservabilityEntityType } from '../../../../graphql/model/schema/entity';
6-
import { ObservabilitySpecificationBuilder } from '../../../../graphql/request/builders/selections/observability-specification-builder';
76
import {
87
ENTITY_TOPOLOGY_GQL_REQUEST,
98
TopologyNodeSpecification
@@ -15,7 +14,6 @@ import { TopologyMetricsModel } from './metrics/topology-metrics.model';
1514
import { TopologyDataSourceModel } from './topology-data-source.model';
1615

1716
describe('topology data source model', () => {
18-
const specBuilder = new ObservabilitySpecificationBuilder();
1917
const testTimeRange = { startTime: new Date(1568907645141), endTime: new Date(1568911245141) };
2018
let model!: TopologyDataSourceModel;
2119
let lastEmittedQuery: unknown;
@@ -93,47 +91,55 @@ describe('topology data source model', () => {
9391

9492
test('builds expected request', () => {
9593
model.getData();
96-
expect(
97-
isEqualIgnoreFunctions(lastEmittedQuery, {
98-
requestType: ENTITY_TOPOLOGY_GQL_REQUEST,
99-
rootNodeType: ObservabilityEntityType.Service,
100-
rootNodeSpecification: {
101-
titleSpecification: specBuilder.attributeSpecificationForKey('name'),
102-
metricSpecifications: [specBuilder.metricAggregationSpecForKey('numCalls', MetricAggregationType.Average)]
103-
},
104-
rootNodeFilters: [],
105-
rootNodeLimit: 100,
106-
timeRange: new GraphQlTimeRange(testTimeRange.startTime, testTimeRange.endTime),
107-
downstreamNodeSpecifications: new Map<ObservabilityEntityType, TopologyNodeSpecification>([
108-
[
109-
ObservabilityEntityType.Api,
110-
{
111-
titleSpecification: specBuilder.attributeSpecificationForKey('name'),
112-
metricSpecifications: [specBuilder.metricAggregationSpecForKey('numCalls', MetricAggregationType.Average)]
113-
}
114-
],
115-
[
116-
ObservabilityEntityType.Backend,
117-
{
118-
titleSpecification: specBuilder.attributeSpecificationForKey('name'),
119-
metricSpecifications: [specBuilder.metricAggregationSpecForKey('numCalls', MetricAggregationType.Average)]
120-
}
121-
]
122-
]),
123-
upstreamNodeSpecifications: new Map<ObservabilityEntityType, TopologyNodeSpecification>([
124-
[
125-
ObservabilityEntityType.Service,
126-
{
127-
titleSpecification: specBuilder.attributeSpecificationForKey('name'),
128-
metricSpecifications: [specBuilder.metricAggregationSpecForKey('numCalls', MetricAggregationType.Average)]
129-
}
130-
]
131-
]),
132-
edgeSpecification: {
133-
metricSpecifications: [specBuilder.metricAggregationSpecForKey('duration', MetricAggregationType.Average)]
134-
}
135-
})
136-
).toBe(true);
94+
expect(lastEmittedQuery).toEqual({
95+
requestType: ENTITY_TOPOLOGY_GQL_REQUEST,
96+
rootNodeType: ObservabilityEntityType.Service,
97+
rootNodeSpecification: {
98+
titleSpecification: expect.objectContaining({ name: 'name' }),
99+
metricSpecifications: [
100+
expect.objectContaining({ metric: 'numCalls', aggregation: MetricAggregationType.Average })
101+
]
102+
},
103+
rootNodeFilters: [],
104+
rootNodeLimit: 100,
105+
timeRange: new GraphQlTimeRange(testTimeRange.startTime, testTimeRange.endTime),
106+
downstreamNodeSpecifications: new Map<ObservabilityEntityType, TopologyNodeSpecification>([
107+
[
108+
ObservabilityEntityType.Api,
109+
{
110+
titleSpecification: expect.objectContaining({ name: 'name' }),
111+
metricSpecifications: [
112+
expect.objectContaining({ metric: 'numCalls', aggregation: MetricAggregationType.Average })
113+
]
114+
}
115+
],
116+
[
117+
ObservabilityEntityType.Backend,
118+
{
119+
titleSpecification: expect.objectContaining({ name: 'name' }),
120+
metricSpecifications: [
121+
expect.objectContaining({ metric: 'numCalls', aggregation: MetricAggregationType.Average })
122+
]
123+
}
124+
]
125+
]),
126+
upstreamNodeSpecifications: new Map<ObservabilityEntityType, TopologyNodeSpecification>([
127+
[
128+
ObservabilityEntityType.Service,
129+
{
130+
titleSpecification: expect.objectContaining({ name: 'name' }),
131+
metricSpecifications: [
132+
expect.objectContaining({ metric: 'numCalls', aggregation: MetricAggregationType.Average })
133+
]
134+
}
135+
]
136+
]),
137+
edgeSpecification: {
138+
metricSpecifications: [
139+
expect.objectContaining({ metric: 'duration', aggregation: MetricAggregationType.Average })
140+
]
141+
}
142+
});
137143

138144
expect(lastEmittedQueryRequestOption).toEqual({
139145
cacheability: GraphQlRequestCacheability.Cacheable,

0 commit comments

Comments
 (0)