summaryrefslogtreecommitdiff
path: root/spec/frontend/monitoring
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-20 15:40:28 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-20 15:40:28 +0000
commitb595cb0c1dec83de5bdee18284abe86614bed33b (patch)
tree8c3d4540f193c5ff98019352f554e921b3a41a72 /spec/frontend/monitoring
parent2f9104a328fc8a4bddeaa4627b595166d24671d0 (diff)
downloadgitlab-ce-b595cb0c1dec83de5bdee18284abe86614bed33b.tar.gz
Add latest changes from gitlab-org/gitlab@15-2-stable-eev15.2.0-rc42
Diffstat (limited to 'spec/frontend/monitoring')
-rw-r--r--spec/frontend/monitoring/components/__snapshots__/dashboard_template_spec.js.snap2
-rw-r--r--spec/frontend/monitoring/components/dashboard_panel_spec.js98
-rw-r--r--spec/frontend/monitoring/components/dashboard_spec.js37
-rw-r--r--spec/frontend/monitoring/store/mutations_spec.js12
4 files changed, 29 insertions, 120 deletions
diff --git a/spec/frontend/monitoring/components/__snapshots__/dashboard_template_spec.js.snap b/spec/frontend/monitoring/components/__snapshots__/dashboard_template_spec.js.snap
index a9f37f90561..14f04d9b767 100644
--- a/spec/frontend/monitoring/components/__snapshots__/dashboard_template_spec.js.snap
+++ b/spec/frontend/monitoring/components/__snapshots__/dashboard_template_spec.js.snap
@@ -35,7 +35,7 @@ exports[`Dashboard template matches the default snapshot 1`] = `
class="prometheus-graphs-header d-sm-flex flex-sm-wrap pt-2 pr-1 pb-0 pl-2 border-bottom bg-gray-light"
>
<div
- class="mb-2 mr-2 d-flex d-sm-block"
+ class="gl-mb-3 gl-mr-3 gl-display-flex gl-sm-display-block"
>
<dashboards-dropdown-stub
class="flex-grow-1"
diff --git a/spec/frontend/monitoring/components/dashboard_panel_spec.js b/spec/frontend/monitoring/components/dashboard_panel_spec.js
index 1f9eb03b5d4..7c54a4742ac 100644
--- a/spec/frontend/monitoring/components/dashboard_panel_spec.js
+++ b/spec/frontend/monitoring/components/dashboard_panel_spec.js
@@ -5,7 +5,6 @@ import Vuex from 'vuex';
import { nextTick } from 'vue';
import { setTestTimeout } from 'helpers/timeout';
import axios from '~/lib/utils/axios_utils';
-import invalidUrl from '~/lib/utils/invalid_url';
import MonitorAnomalyChart from '~/monitoring/components/charts/anomaly.vue';
import MonitorBarChart from '~/monitoring/components/charts/bar.vue';
@@ -27,13 +26,7 @@ import {
heatmapGraphData,
barGraphData,
} from '../graph_data';
-import {
- mockLogsHref,
- mockLogsPath,
- mockNamespace,
- mockNamespacedData,
- mockTimeRange,
-} from '../mock_data';
+import { mockNamespace, mockNamespacedData, mockTimeRange } from '../mock_data';
const mocks = {
$toast: {
@@ -65,7 +58,6 @@ describe('Dashboard Panel', () => {
},
store,
mocks,
- provide: { glFeatures: { monitorLogging: true } },
...options,
});
};
@@ -335,86 +327,6 @@ describe('Dashboard Panel', () => {
});
});
- describe('View Logs dropdown item', () => {
- const findViewLogsLink = () => wrapper.find({ ref: 'viewLogsLink' });
-
- beforeEach(async () => {
- createWrapper();
- await nextTick();
- });
-
- it('is not present by default', async () => {
- await nextTick();
- expect(findViewLogsLink().exists()).toBe(false);
- });
-
- it('is not present if a time range is not set', async () => {
- state.logsPath = mockLogsPath;
- state.timeRange = null;
-
- await nextTick();
- expect(findViewLogsLink().exists()).toBe(false);
- });
-
- it('is not present if the logs path is default', async () => {
- state.logsPath = invalidUrl;
- state.timeRange = mockTimeRange;
-
- await nextTick();
- expect(findViewLogsLink().exists()).toBe(false);
- });
-
- it('is not present if the logs path is not set', async () => {
- state.logsPath = null;
- state.timeRange = mockTimeRange;
-
- await nextTick();
- expect(findViewLogsLink().exists()).toBe(false);
- });
-
- it('is present when logs path and time a range is present', async () => {
- state.logsPath = mockLogsPath;
- state.timeRange = mockTimeRange;
-
- await nextTick();
- expect(findViewLogsLink().attributes('href')).toMatch(mockLogsHref);
- });
-
- describe(':monitor_logging feature flag', () => {
- it.each`
- flagState | logsState | expected
- ${true} | ${'shows'} | ${true}
- ${false} | ${'hides'} | ${false}
- `('$logsState logs when flag state is $flagState', async ({ flagState, expected }) => {
- createWrapper({}, { provide: { glFeatures: { monitorLogging: flagState } } });
- state.logsPath = mockLogsPath;
- state.timeRange = mockTimeRange;
- await nextTick();
-
- expect(findViewLogsLink().exists()).toBe(expected);
- });
- });
-
- it('it is overridden when a datazoom event is received', async () => {
- state.logsPath = mockLogsPath;
- state.timeRange = mockTimeRange;
-
- const zoomedTimeRange = {
- start: '2020-01-01T00:00:00.000Z',
- end: '2020-01-01T01:00:00.000Z',
- };
-
- findTimeChart().vm.$emit('datazoom', zoomedTimeRange);
-
- await nextTick();
- const start = encodeURIComponent(zoomedTimeRange.start);
- const end = encodeURIComponent(zoomedTimeRange.end);
- expect(findViewLogsLink().attributes('href')).toMatch(
- `${mockLogsPath}?start=${start}&end=${end}`,
- );
- });
- });
-
describe('when clipboard data is available', () => {
const clipboardText = 'A value to copy.';
@@ -507,14 +419,6 @@ describe('Dashboard Panel', () => {
createWrapper({ namespace: mockNamespace });
});
- it('handles namespaced time range and logs path state', async () => {
- store.state[mockNamespace].timeRange = mockTimeRange;
- store.state[mockNamespace].logsPath = mockLogsPath;
-
- await nextTick();
- expect(wrapper.find({ ref: 'viewLogsLink' }).attributes().href).toBe(mockLogsHref);
- });
-
it('handles namespaced deployment data state', async () => {
store.state[mockNamespace].deploymentData = mockDeploymentData;
diff --git a/spec/frontend/monitoring/components/dashboard_spec.js b/spec/frontend/monitoring/components/dashboard_spec.js
index 6c5972e1140..90171cfc65e 100644
--- a/spec/frontend/monitoring/components/dashboard_spec.js
+++ b/spec/frontend/monitoring/components/dashboard_spec.js
@@ -75,6 +75,7 @@ describe('Dashboard', () => {
if (store.dispatch.mockReset) {
store.dispatch.mockReset();
}
+ wrapper.destroy();
});
describe('request information to the server', () => {
@@ -569,28 +570,37 @@ describe('Dashboard', () => {
const findDraggablePanels = () => wrapper.findAll('.js-draggable-panel');
const findRearrangeButton = () => wrapper.find('.js-rearrange-button');
- beforeEach(async () => {
+ const setup = async () => {
// call original dispatch
store.dispatch.mockRestore();
createShallowWrapper({ hasMetrics: true });
setupStoreWithData(store);
await nextTick();
- });
+ };
+
+ it('wraps vuedraggable', async () => {
+ await setup();
- it('wraps vuedraggable', () => {
expect(findDraggablePanels().exists()).toBe(true);
expect(findDraggablePanels().length).toEqual(metricsDashboardPanelCount);
});
- it('is disabled by default', () => {
+ it('is disabled by default', async () => {
+ await setup();
+
expect(findRearrangeButton().exists()).toBe(false);
expect(findEnabledDraggables().length).toBe(0);
});
describe('when rearrange is enabled', () => {
beforeEach(async () => {
- wrapper.setProps({ rearrangePanelsAvailable: true });
+ // call original dispatch
+ store.dispatch.mockRestore();
+
+ createShallowWrapper({ hasMetrics: true, rearrangePanelsAvailable: true });
+ setupStoreWithData(store);
+
await nextTick();
});
@@ -602,17 +612,18 @@ describe('Dashboard', () => {
const findFirstDraggableRemoveButton = () =>
findDraggablePanels().at(0).find('.js-draggable-remove');
- beforeEach(async () => {
+ it('it enables draggables', async () => {
findRearrangeButton().vm.$emit('click');
await nextTick();
- });
- it('it enables draggables', () => {
expect(findRearrangeButton().attributes('pressed')).toBeTruthy();
expect(findEnabledDraggables().wrappers).toEqual(findDraggables().wrappers);
});
it('metrics can be swapped', async () => {
+ findRearrangeButton().vm.$emit('click');
+ await nextTick();
+
const firstDraggable = findDraggables().at(0);
const mockMetrics = [...metricsDashboardViewModel.panelGroups[0].panels];
@@ -624,6 +635,7 @@ describe('Dashboard', () => {
firstDraggable.vm.$emit('input', mockMetrics);
await nextTick();
+
const { panels } = wrapper.vm.dashboard.panelGroups[0];
expect(panels[1].title).toEqual(firstTitle);
@@ -631,18 +643,23 @@ describe('Dashboard', () => {
});
it('shows a remove button, which removes a panel', async () => {
+ findRearrangeButton().vm.$emit('click');
+ await nextTick();
+
expect(findFirstDraggableRemoveButton().find('a').exists()).toBe(true);
expect(findDraggablePanels().length).toEqual(metricsDashboardPanelCount);
- findFirstDraggableRemoveButton().trigger('click');
+ await findFirstDraggableRemoveButton().trigger('click');
- await nextTick();
expect(findDraggablePanels().length).toEqual(metricsDashboardPanelCount - 1);
});
it('it disables draggables when clicked again', async () => {
findRearrangeButton().vm.$emit('click');
await nextTick();
+
+ findRearrangeButton().vm.$emit('click');
+ await nextTick();
expect(findRearrangeButton().attributes('pressed')).toBeFalsy();
expect(findEnabledDraggables().length).toBe(0);
});
diff --git a/spec/frontend/monitoring/store/mutations_spec.js b/spec/frontend/monitoring/store/mutations_spec.js
index ae1a4e16b30..49e8ab9ebd4 100644
--- a/spec/frontend/monitoring/store/mutations_spec.js
+++ b/spec/frontend/monitoring/store/mutations_spec.js
@@ -180,11 +180,6 @@ describe('Monitoring mutations', () => {
});
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',
});
@@ -196,7 +191,6 @@ describe('Monitoring mutations', () => {
});
expect(stateCopy).toMatchObject({
- logsPath: defaultLogsPath,
dashboardEndpoint: 'dashboard.json',
projectPath: '/gitlab-org/gitlab-foss',
currentEnvironmentName: 'canary',
@@ -227,11 +221,6 @@ describe('Monitoring mutations', () => {
});
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',
});
@@ -240,7 +229,6 @@ describe('Monitoring mutations', () => {
});
expect(stateCopy).toMatchObject({
- logsPath: defaultLogsPath,
dashboardEndpoint: 'dashboard.json',
projectPath: '/gitlab-org/gitlab-foss',
});