summaryrefslogtreecommitdiff
path: root/spec/javascripts/monitoring/store/mutations_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/javascripts/monitoring/store/mutations_spec.js')
-rw-r--r--spec/javascripts/monitoring/store/mutations_spec.js64
1 files changed, 15 insertions, 49 deletions
diff --git a/spec/javascripts/monitoring/store/mutations_spec.js b/spec/javascripts/monitoring/store/mutations_spec.js
index 49aed1b85e6..498c1a9e9b1 100644
--- a/spec/javascripts/monitoring/store/mutations_spec.js
+++ b/spec/javascripts/monitoring/store/mutations_spec.js
@@ -21,79 +21,46 @@ describe('Monitoring mutations', () => {
beforeEach(() => {
stateCopy.dashboard.panel_groups = [];
- groups = metricsGroupsAPIResponse.data;
+ groups = metricsGroupsAPIResponse;
});
it('adds a key to the group', () => {
mutations[types.RECEIVE_METRICS_DATA_SUCCESS](stateCopy, groups);
- expect(stateCopy.dashboard.panel_groups[0].key).toBe('kubernetes-0');
- expect(stateCopy.dashboard.panel_groups[1].key).toBe('nginx-1');
+ expect(stateCopy.dashboard.panel_groups[0].key).toBe('system-metrics-kubernetes--0');
});
it('normalizes values', () => {
mutations[types.RECEIVE_METRICS_DATA_SUCCESS](stateCopy, groups);
- const expectedTimestamp = '2017-05-25T08:22:34.925Z';
- const expectedValue = 8.0390625;
- const [
- timestamp,
- value,
- ] = stateCopy.dashboard.panel_groups[0].metrics[0].queries[0].result[0].values[0];
+ const expectedLabel = 'Pod average';
+ const { label, query_range } = stateCopy.dashboard.panel_groups[0].metrics[0].metrics[0];
- expect(timestamp).toEqual(expectedTimestamp);
- expect(value).toEqual(expectedValue);
+ expect(label).toEqual(expectedLabel);
+ expect(query_range.length).toBeGreaterThan(0);
});
- it('contains two groups that contains, one of which has two queries sorted by priority', () => {
+ it('contains one group, which it has two panels and one metrics property', () => {
mutations[types.RECEIVE_METRICS_DATA_SUCCESS](stateCopy, groups);
expect(stateCopy.dashboard.panel_groups).toBeDefined();
- expect(stateCopy.dashboard.panel_groups.length).toEqual(2);
- expect(stateCopy.dashboard.panel_groups[0].metrics.length).toEqual(2);
+ expect(stateCopy.dashboard.panel_groups.length).toEqual(1);
+ expect(stateCopy.dashboard.panel_groups[0].panels.length).toEqual(2);
+ expect(stateCopy.dashboard.panel_groups[0].panels[0].metrics.length).toEqual(1);
+ expect(stateCopy.dashboard.panel_groups[0].panels[1].metrics.length).toEqual(1);
});
it('assigns queries a metric id', () => {
mutations[types.RECEIVE_METRICS_DATA_SUCCESS](stateCopy, groups);
- expect(stateCopy.dashboard.panel_groups[1].metrics[0].queries[0].metricId).toEqual('100');
+ expect(stateCopy.dashboard.panel_groups[0].metrics[0].queries[0].metricId).toEqual(
+ '17_system_metrics_kubernetes_container_memory_average',
+ );
});
- it('removes the data if all the values from a query are not defined', () => {
- mutations[types.RECEIVE_METRICS_DATA_SUCCESS](stateCopy, groups);
-
- expect(stateCopy.dashboard.panel_groups[1].metrics[0].queries[0].result.length).toEqual(0);
- });
-
- it('assigns metric id of null if metric has no id', () => {
- stateCopy.dashboard.panel_groups = [];
- const noId = groups.map(group => ({
- ...group,
- ...{
- metrics: group.metrics.map(metric => {
- const { id, ...metricWithoutId } = metric;
-
- return metricWithoutId;
- }),
- },
- }));
-
- mutations[types.RECEIVE_METRICS_DATA_SUCCESS](stateCopy, noId);
-
- stateCopy.dashboard.panel_groups.forEach(group => {
- group.metrics.forEach(metric => {
- expect(metric.queries.every(query => query.metricId === null)).toBe(true);
- });
- });
- });
-
- describe('dashboard endpoint enabled', () => {
+ describe('dashboard endpoint', () => {
const dashboardGroups = metricsDashboardResponse.dashboard.panel_groups;
- beforeEach(() => {
- stateCopy.useDashboardEndpoint = true;
- });
-
it('aliases group panels to metrics for backwards compatibility', () => {
mutations[types.RECEIVE_METRICS_DATA_SUCCESS](stateCopy, dashboardGroups);
@@ -143,7 +110,6 @@ describe('Monitoring mutations', () => {
const result = [{ values: [[0, 1], [1, 1], [1, 3]] }];
beforeEach(() => {
- stateCopy.useDashboardEndpoint = true;
const dashboardGroups = metricsDashboardResponse.dashboard.panel_groups;
mutations[types.RECEIVE_METRICS_DATA_SUCCESS](stateCopy, dashboardGroups);
});