2020-01-01 13:55:28 +05:30
|
|
|
import httpStatusCodes from '~/lib/utils/http_status';
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
import mutations from '~/monitoring/stores/mutations';
|
|
|
|
import * as types from '~/monitoring/stores/mutation_types';
|
|
|
|
import state from '~/monitoring/stores/state';
|
2020-01-01 13:55:28 +05:30
|
|
|
import { metricStates } from '~/monitoring/constants';
|
2020-04-08 14:13:33 +05:30
|
|
|
|
|
|
|
import { deploymentData, dashboardGitResponse } from '../mock_data';
|
2020-04-22 19:07:51 +05:30
|
|
|
import { metricsDashboardPayload } from '../fixture_data';
|
2019-09-04 21:01:54 +05:30
|
|
|
|
|
|
|
describe('Monitoring mutations', () => {
|
|
|
|
let stateCopy;
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
beforeEach(() => {
|
|
|
|
stateCopy = state();
|
|
|
|
});
|
2020-04-08 14:13:33 +05:30
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
describe('RECEIVE_METRICS_DASHBOARD_SUCCESS', () => {
|
2020-01-01 13:55:28 +05:30
|
|
|
let payload;
|
2020-04-08 14:13:33 +05:30
|
|
|
const getGroups = () => stateCopy.dashboard.panelGroups;
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
beforeEach(() => {
|
2020-04-08 14:13:33 +05:30
|
|
|
stateCopy.dashboard.panelGroups = [];
|
2020-03-13 15:44:24 +05:30
|
|
|
payload = metricsDashboardPayload;
|
2019-09-04 21:01:54 +05:30
|
|
|
});
|
2019-12-26 22:10:19 +05:30
|
|
|
it('adds a key to the group', () => {
|
2020-04-22 19:07:51 +05:30
|
|
|
mutations[types.RECEIVE_METRICS_DASHBOARD_SUCCESS](stateCopy, payload);
|
2020-01-01 13:55:28 +05:30
|
|
|
const groups = getGroups();
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
expect(groups[0].key).toBe('system-metrics-kubernetes-0');
|
|
|
|
expect(groups[1].key).toBe('response-metrics-nginx-ingress-vts-1');
|
|
|
|
expect(groups[2].key).toBe('response-metrics-nginx-ingress-2');
|
2019-09-04 21:01:54 +05:30
|
|
|
});
|
2019-12-26 22:10:19 +05:30
|
|
|
it('normalizes values', () => {
|
2020-04-22 19:07:51 +05:30
|
|
|
mutations[types.RECEIVE_METRICS_DASHBOARD_SUCCESS](stateCopy, payload);
|
2020-04-08 14:13:33 +05:30
|
|
|
const expectedLabel = 'Pod average (MB)';
|
|
|
|
|
|
|
|
const { label, queryRange } = getGroups()[0].panels[2].metrics[0];
|
2019-12-26 22:10:19 +05:30
|
|
|
expect(label).toEqual(expectedLabel);
|
2020-04-08 14:13:33 +05:30
|
|
|
expect(queryRange.length).toBeGreaterThan(0);
|
2019-09-04 21:01:54 +05:30
|
|
|
});
|
2020-04-08 14:13:33 +05:30
|
|
|
it('contains six groups, with panels with a metric each', () => {
|
2020-04-22 19:07:51 +05:30
|
|
|
mutations[types.RECEIVE_METRICS_DASHBOARD_SUCCESS](stateCopy, payload);
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
const groups = getGroups();
|
|
|
|
|
|
|
|
expect(groups).toBeDefined();
|
2020-04-08 14:13:33 +05:30
|
|
|
expect(groups).toHaveLength(6);
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
expect(groups[0].panels).toHaveLength(7);
|
2020-01-01 13:55:28 +05:30
|
|
|
expect(groups[0].panels[0].metrics).toHaveLength(1);
|
2020-04-08 14:13:33 +05:30
|
|
|
expect(groups[0].panels[1].metrics).toHaveLength(1);
|
|
|
|
expect(groups[0].panels[2].metrics).toHaveLength(1);
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
expect(groups[1].panels).toHaveLength(3);
|
2020-01-01 13:55:28 +05:30
|
|
|
expect(groups[1].panels[0].metrics).toHaveLength(1);
|
2019-09-04 21:01:54 +05:30
|
|
|
});
|
2020-01-01 13:55:28 +05:30
|
|
|
it('assigns metrics a metric id', () => {
|
2020-04-22 19:07:51 +05:30
|
|
|
mutations[types.RECEIVE_METRICS_DASHBOARD_SUCCESS](stateCopy, payload);
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
const groups = getGroups();
|
|
|
|
|
|
|
|
expect(groups[0].panels[0].metrics[0].metricId).toEqual(
|
2020-04-22 19:07:51 +05:30
|
|
|
'NO_DB_system_metrics_kubernetes_container_memory_total',
|
2020-01-01 13:55:28 +05:30
|
|
|
);
|
|
|
|
expect(groups[1].panels[0].metrics[0].metricId).toEqual(
|
2020-04-22 19:07:51 +05:30
|
|
|
'NO_DB_response_metrics_nginx_ingress_throughput_status_code',
|
2020-04-08 14:13:33 +05:30
|
|
|
);
|
|
|
|
expect(groups[2].panels[0].metrics[0].metricId).toEqual(
|
2020-04-22 19:07:51 +05:30
|
|
|
'NO_DB_response_metrics_nginx_ingress_16_throughput_status_code',
|
2019-12-26 22:10:19 +05:30
|
|
|
);
|
2019-09-04 21:01:54 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
describe('Dashboard starring mutations', () => {
|
|
|
|
it('REQUEST_DASHBOARD_STARRING', () => {
|
|
|
|
stateCopy = { isUpdatingStarredValue: false };
|
|
|
|
mutations[types.REQUEST_DASHBOARD_STARRING](stateCopy);
|
|
|
|
|
|
|
|
expect(stateCopy.isUpdatingStarredValue).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('RECEIVE_DASHBOARD_STARRING_SUCCESS', () => {
|
|
|
|
let allDashboards;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
allDashboards = [...dashboardGitResponse];
|
|
|
|
stateCopy = {
|
|
|
|
allDashboards,
|
|
|
|
currentDashboard: allDashboards[1].path,
|
|
|
|
isUpdatingStarredValue: true,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
it('sets a dashboard as starred', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mutations[types.RECEIVE_DASHBOARD_STARRING_SUCCESS](stateCopy, {
|
|
|
|
selectedDashboard: stateCopy.allDashboards[1],
|
|
|
|
newStarredValue: true,
|
|
|
|
});
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
expect(stateCopy.isUpdatingStarredValue).toBe(false);
|
|
|
|
expect(stateCopy.allDashboards[1].starred).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('sets a dashboard as unstarred', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mutations[types.RECEIVE_DASHBOARD_STARRING_SUCCESS](stateCopy, {
|
|
|
|
selectedDashboard: stateCopy.allDashboards[1],
|
|
|
|
newStarredValue: false,
|
|
|
|
});
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
expect(stateCopy.isUpdatingStarredValue).toBe(false);
|
|
|
|
expect(stateCopy.allDashboards[1].starred).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('RECEIVE_DASHBOARD_STARRING_FAILURE', () => {
|
|
|
|
stateCopy = { isUpdatingStarredValue: true };
|
|
|
|
mutations[types.RECEIVE_DASHBOARD_STARRING_FAILURE](stateCopy);
|
|
|
|
|
|
|
|
expect(stateCopy.isUpdatingStarredValue).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
describe('RECEIVE_DEPLOYMENTS_DATA_SUCCESS', () => {
|
2019-09-04 21:01:54 +05:30
|
|
|
it('stores the deployment data', () => {
|
|
|
|
stateCopy.deploymentData = [];
|
|
|
|
mutations[types.RECEIVE_DEPLOYMENTS_DATA_SUCCESS](stateCopy, deploymentData);
|
|
|
|
expect(stateCopy.deploymentData).toBeDefined();
|
2020-01-01 13:55:28 +05:30
|
|
|
expect(stateCopy.deploymentData).toHaveLength(3);
|
2019-09-04 21:01:54 +05:30
|
|
|
expect(typeof stateCopy.deploymentData[0]).toEqual('object');
|
|
|
|
});
|
|
|
|
});
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
describe('SET_INITIAL_STATE', () => {
|
|
|
|
it('should set all the endpoints', () => {
|
|
|
|
mutations[types.SET_INITIAL_STATE](stateCopy, {
|
|
|
|
deploymentsEndpoint: 'deployments.json',
|
|
|
|
dashboardEndpoint: 'dashboard.json',
|
|
|
|
projectPath: '/gitlab-org/gitlab-foss',
|
|
|
|
currentEnvironmentName: 'production',
|
|
|
|
});
|
|
|
|
expect(stateCopy.deploymentsEndpoint).toEqual('deployments.json');
|
|
|
|
expect(stateCopy.dashboardEndpoint).toEqual('dashboard.json');
|
|
|
|
expect(stateCopy.projectPath).toEqual('/gitlab-org/gitlab-foss');
|
|
|
|
expect(stateCopy.currentEnvironmentName).toEqual('production');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not remove previously set properties', () => {
|
|
|
|
const defaultLogsPath = stateCopy.logsPath;
|
|
|
|
|
|
|
|
mutations[types.SET_INITIAL_STATE](stateCopy, {
|
|
|
|
logsPath: defaultLogsPath,
|
|
|
|
});
|
|
|
|
mutations[types.SET_INITIAL_STATE](stateCopy, {
|
|
|
|
dashboardEndpoint: 'dashboard.json',
|
|
|
|
});
|
|
|
|
mutations[types.SET_INITIAL_STATE](stateCopy, {
|
|
|
|
projectPath: '/gitlab-org/gitlab-foss',
|
|
|
|
});
|
|
|
|
mutations[types.SET_INITIAL_STATE](stateCopy, {
|
|
|
|
currentEnvironmentName: 'canary',
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(stateCopy).toMatchObject({
|
|
|
|
logsPath: defaultLogsPath,
|
|
|
|
dashboardEndpoint: 'dashboard.json',
|
|
|
|
projectPath: '/gitlab-org/gitlab-foss',
|
|
|
|
currentEnvironmentName: 'canary',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not update unknown properties', () => {
|
|
|
|
mutations[types.SET_INITIAL_STATE](stateCopy, {
|
|
|
|
dashboardEndpoint: 'dashboard.json',
|
|
|
|
someOtherProperty: 'some invalid value', // someOtherProperty is not allowed
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(stateCopy.dashboardEndpoint).toBe('dashboard.json');
|
|
|
|
expect(stateCopy.someOtherProperty).toBeUndefined();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
describe('SET_ENDPOINTS', () => {
|
|
|
|
it('should set all the endpoints', () => {
|
|
|
|
mutations[types.SET_ENDPOINTS](stateCopy, {
|
|
|
|
deploymentsEndpoint: 'deployments.json',
|
|
|
|
dashboardEndpoint: 'dashboard.json',
|
2019-12-04 20:38:33 +05:30
|
|
|
projectPath: '/gitlab-org/gitlab-foss',
|
2019-09-04 21:01:54 +05:30
|
|
|
});
|
|
|
|
expect(stateCopy.deploymentsEndpoint).toEqual('deployments.json');
|
|
|
|
expect(stateCopy.dashboardEndpoint).toEqual('dashboard.json');
|
2019-12-04 20:38:33 +05:30
|
|
|
expect(stateCopy.projectPath).toEqual('/gitlab-org/gitlab-foss');
|
2019-09-04 21:01:54 +05:30
|
|
|
});
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
it('should not remove previously set properties', () => {
|
|
|
|
const defaultLogsPath = stateCopy.logsPath;
|
|
|
|
|
|
|
|
mutations[types.SET_ENDPOINTS](stateCopy, {
|
|
|
|
logsPath: defaultLogsPath,
|
|
|
|
});
|
|
|
|
mutations[types.SET_ENDPOINTS](stateCopy, {
|
|
|
|
dashboardEndpoint: 'dashboard.json',
|
|
|
|
});
|
|
|
|
mutations[types.SET_ENDPOINTS](stateCopy, {
|
|
|
|
projectPath: '/gitlab-org/gitlab-foss',
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(stateCopy).toMatchObject({
|
|
|
|
logsPath: defaultLogsPath,
|
|
|
|
dashboardEndpoint: 'dashboard.json',
|
|
|
|
projectPath: '/gitlab-org/gitlab-foss',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not update unknown properties', () => {
|
|
|
|
mutations[types.SET_ENDPOINTS](stateCopy, {
|
|
|
|
dashboardEndpoint: 'dashboard.json',
|
|
|
|
someOtherProperty: 'some invalid value', // someOtherProperty is not allowed
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(stateCopy.dashboardEndpoint).toBe('dashboard.json');
|
|
|
|
expect(stateCopy.someOtherProperty).toBeUndefined();
|
|
|
|
});
|
2019-09-04 21:01:54 +05:30
|
|
|
});
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
describe('Individual panel/metric results', () => {
|
2020-04-22 19:07:51 +05:30
|
|
|
const metricId = 'NO_DB_response_metrics_nginx_ingress_throughput_status_code';
|
2019-12-26 22:10:19 +05:30
|
|
|
const result = [
|
|
|
|
{
|
|
|
|
values: [[0, 1], [1, 1], [1, 3]],
|
|
|
|
},
|
|
|
|
];
|
2020-04-08 14:13:33 +05:30
|
|
|
const dashboard = metricsDashboardPayload;
|
|
|
|
const getMetric = () => stateCopy.dashboard.panelGroups[1].panels[0].metrics[0];
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
describe('REQUEST_METRIC_RESULT', () => {
|
|
|
|
beforeEach(() => {
|
2020-04-22 19:07:51 +05:30
|
|
|
mutations[types.RECEIVE_METRICS_DASHBOARD_SUCCESS](stateCopy, dashboard);
|
2020-01-01 13:55:28 +05:30
|
|
|
});
|
|
|
|
it('stores a loading state on a metric', () => {
|
|
|
|
expect(stateCopy.showEmptyState).toBe(true);
|
|
|
|
|
|
|
|
mutations[types.REQUEST_METRIC_RESULT](stateCopy, {
|
|
|
|
metricId,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(stateCopy.showEmptyState).toBe(true);
|
|
|
|
expect(getMetric()).toEqual(
|
|
|
|
expect.objectContaining({
|
|
|
|
loading: true,
|
|
|
|
}),
|
|
|
|
);
|
2019-09-04 21:01:54 +05:30
|
|
|
});
|
|
|
|
});
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
describe('RECEIVE_METRIC_RESULT_SUCCESS', () => {
|
|
|
|
beforeEach(() => {
|
2020-04-22 19:07:51 +05:30
|
|
|
mutations[types.RECEIVE_METRICS_DASHBOARD_SUCCESS](stateCopy, dashboard);
|
2020-01-01 13:55:28 +05:30
|
|
|
});
|
|
|
|
it('clears empty state', () => {
|
|
|
|
expect(stateCopy.showEmptyState).toBe(true);
|
|
|
|
|
|
|
|
mutations[types.RECEIVE_METRIC_RESULT_SUCCESS](stateCopy, {
|
|
|
|
metricId,
|
|
|
|
result,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(stateCopy.showEmptyState).toBe(false);
|
2019-12-26 22:10:19 +05:30
|
|
|
});
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
it('adds results to the store', () => {
|
2020-04-22 19:07:51 +05:30
|
|
|
expect(getMetric().result).toBe(null);
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
mutations[types.RECEIVE_METRIC_RESULT_SUCCESS](stateCopy, {
|
|
|
|
metricId,
|
|
|
|
result,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(getMetric().result).toHaveLength(result.length);
|
|
|
|
expect(getMetric()).toEqual(
|
|
|
|
expect.objectContaining({
|
|
|
|
loading: false,
|
|
|
|
state: metricStates.OK,
|
|
|
|
}),
|
|
|
|
);
|
2019-09-04 21:01:54 +05:30
|
|
|
});
|
|
|
|
});
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
describe('RECEIVE_METRIC_RESULT_FAILURE', () => {
|
|
|
|
beforeEach(() => {
|
2020-04-22 19:07:51 +05:30
|
|
|
mutations[types.RECEIVE_METRICS_DASHBOARD_SUCCESS](stateCopy, dashboard);
|
2020-01-01 13:55:28 +05:30
|
|
|
});
|
|
|
|
it('maintains the loading state when a metric fails', () => {
|
|
|
|
expect(stateCopy.showEmptyState).toBe(true);
|
|
|
|
|
|
|
|
mutations[types.RECEIVE_METRIC_RESULT_FAILURE](stateCopy, {
|
|
|
|
metricId,
|
|
|
|
error: 'an error',
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(stateCopy.showEmptyState).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('stores a timeout error in a metric', () => {
|
|
|
|
mutations[types.RECEIVE_METRIC_RESULT_FAILURE](stateCopy, {
|
|
|
|
metricId,
|
|
|
|
error: { message: 'BACKOFF_TIMEOUT' },
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(getMetric()).toEqual(
|
|
|
|
expect.objectContaining({
|
|
|
|
loading: false,
|
|
|
|
result: null,
|
|
|
|
state: metricStates.TIMEOUT,
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('stores a connection failed error in a metric', () => {
|
|
|
|
mutations[types.RECEIVE_METRIC_RESULT_FAILURE](stateCopy, {
|
|
|
|
metricId,
|
|
|
|
error: {
|
|
|
|
response: {
|
|
|
|
status: httpStatusCodes.SERVICE_UNAVAILABLE,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
expect(getMetric()).toEqual(
|
|
|
|
expect.objectContaining({
|
|
|
|
loading: false,
|
|
|
|
result: null,
|
|
|
|
state: metricStates.CONNECTION_FAILED,
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('stores a bad data error in a metric', () => {
|
|
|
|
mutations[types.RECEIVE_METRIC_RESULT_FAILURE](stateCopy, {
|
|
|
|
metricId,
|
|
|
|
error: {
|
|
|
|
response: {
|
|
|
|
status: httpStatusCodes.BAD_REQUEST,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(getMetric()).toEqual(
|
|
|
|
expect.objectContaining({
|
|
|
|
loading: false,
|
|
|
|
result: null,
|
|
|
|
state: metricStates.BAD_QUERY,
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('stores an unknown error in a metric', () => {
|
|
|
|
mutations[types.RECEIVE_METRIC_RESULT_FAILURE](stateCopy, {
|
|
|
|
metricId,
|
|
|
|
error: null, // no reason in response
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(getMetric()).toEqual(
|
|
|
|
expect.objectContaining({
|
|
|
|
loading: false,
|
|
|
|
result: null,
|
|
|
|
state: metricStates.UNKNOWN_ERROR,
|
|
|
|
}),
|
|
|
|
);
|
2019-09-04 21:01:54 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2019-09-30 21:07:59 +05:30
|
|
|
describe('SET_ALL_DASHBOARDS', () => {
|
2019-12-26 22:10:19 +05:30
|
|
|
it('stores `undefined` dashboards as an empty array', () => {
|
|
|
|
mutations[types.SET_ALL_DASHBOARDS](stateCopy, undefined);
|
2019-09-30 21:07:59 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
expect(stateCopy.allDashboards).toEqual([]);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('stores `null` dashboards as an empty array', () => {
|
|
|
|
mutations[types.SET_ALL_DASHBOARDS](stateCopy, null);
|
|
|
|
|
|
|
|
expect(stateCopy.allDashboards).toEqual([]);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('stores dashboards loaded from the git repository', () => {
|
|
|
|
mutations[types.SET_ALL_DASHBOARDS](stateCopy, dashboardGitResponse);
|
2019-09-30 21:07:59 +05:30
|
|
|
expect(stateCopy.allDashboards).toEqual(dashboardGitResponse);
|
|
|
|
});
|
|
|
|
});
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
describe('SET_EXPANDED_PANEL', () => {
|
|
|
|
it('no expanded panel is set initally', () => {
|
|
|
|
expect(stateCopy.expandedPanel.panel).toEqual(null);
|
|
|
|
expect(stateCopy.expandedPanel.group).toEqual(null);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('sets a panel id as the expanded panel', () => {
|
|
|
|
const group = 'group_1';
|
|
|
|
const panel = { title: 'A Panel' };
|
|
|
|
mutations[types.SET_EXPANDED_PANEL](stateCopy, { group, panel });
|
|
|
|
|
|
|
|
expect(stateCopy.expandedPanel).toEqual({ group, panel });
|
|
|
|
});
|
|
|
|
|
|
|
|
it('clears panel as the expanded panel', () => {
|
|
|
|
mutations[types.SET_EXPANDED_PANEL](stateCopy, { group: null, panel: null });
|
|
|
|
|
|
|
|
expect(stateCopy.expandedPanel.group).toEqual(null);
|
|
|
|
expect(stateCopy.expandedPanel.panel).toEqual(null);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('SET_VARIABLES', () => {
|
|
|
|
it('stores an empty variables array when no custom variables are given', () => {
|
|
|
|
mutations[types.SET_VARIABLES](stateCopy, {});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(stateCopy.variables).toEqual({});
|
2020-05-24 23:13:21 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('stores variables in the key key_value format in the array', () => {
|
|
|
|
mutations[types.SET_VARIABLES](stateCopy, { pod: 'POD', stage: 'main ops' });
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(stateCopy.variables).toEqual({ pod: 'POD', stage: 'main ops' });
|
2020-05-24 23:13:21 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
describe('UPDATE_VARIABLES', () => {
|
2020-05-24 23:13:21 +05:30
|
|
|
afterEach(() => {
|
|
|
|
mutations[types.SET_VARIABLES](stateCopy, {});
|
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
it('updates only the value of the variable in variables', () => {
|
2020-05-24 23:13:21 +05:30
|
|
|
mutations[types.SET_VARIABLES](stateCopy, { environment: { value: 'prod', type: 'text' } });
|
2020-06-23 00:09:42 +05:30
|
|
|
mutations[types.UPDATE_VARIABLES](stateCopy, { key: 'environment', value: 'new prod' });
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(stateCopy.variables).toEqual({ environment: { value: 'new prod', type: 'text' } });
|
2020-05-24 23:13:21 +05:30
|
|
|
});
|
|
|
|
});
|
2019-09-04 21:01:54 +05:30
|
|
|
});
|