summaryrefslogtreecommitdiff
path: root/spec/frontend/monitoring/init_utils.js
blob: 10db8b902b5c305e8fc9edf73a3d27161955bc99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import * as types from '~/monitoring/stores/mutation_types';
import {
  metricsGroupsAPIResponse,
  mockedEmptyResult,
  mockedQueryResultPayload,
  mockedQueryResultPayloadCoresTotal,
  mockApiEndpoint,
  environmentData,
} from './mock_data';

export const propsData = {
  hasMetrics: false,
  documentationPath: '/path/to/docs',
  settingsPath: '/path/to/settings',
  clustersPath: '/path/to/clusters',
  tagsPath: '/path/to/tags',
  projectPath: '/path/to/project',
  metricsEndpoint: mockApiEndpoint,
  deploymentsEndpoint: null,
  emptyGettingStartedSvgPath: '/path/to/getting-started.svg',
  emptyLoadingSvgPath: '/path/to/loading.svg',
  emptyNoDataSvgPath: '/path/to/no-data.svg',
  emptyNoDataSmallSvgPath: '/path/to/no-data-small.svg',
  emptyUnableToConnectSvgPath: '/path/to/unable-to-connect.svg',
  environmentsEndpoint: '/root/hello-prometheus/environments/35',
  currentEnvironmentName: 'production',
  customMetricsAvailable: false,
  customMetricsPath: '',
  validateQueryPath: '',
};

export const setupComponentStore = wrapper => {
  wrapper.vm.$store.commit(
    `monitoringDashboard/${types.RECEIVE_METRICS_DATA_SUCCESS}`,
    metricsGroupsAPIResponse,
  );

  // Load 3 panels to the dashboard, one with an empty result
  wrapper.vm.$store.commit(
    `monitoringDashboard/${types.RECEIVE_METRIC_RESULT_SUCCESS}`,
    mockedEmptyResult,
  );
  wrapper.vm.$store.commit(
    `monitoringDashboard/${types.RECEIVE_METRIC_RESULT_SUCCESS}`,
    mockedQueryResultPayload,
  );
  wrapper.vm.$store.commit(
    `monitoringDashboard/${types.RECEIVE_METRIC_RESULT_SUCCESS}`,
    mockedQueryResultPayloadCoresTotal,
  );

  wrapper.vm.$store.commit(
    `monitoringDashboard/${types.RECEIVE_ENVIRONMENTS_DATA_SUCCESS}`,
    environmentData,
  );
};