summaryrefslogtreecommitdiff
path: root/spec/frontend/alert_management
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-10-13 06:09:09 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-10-13 06:09:09 +0000
commit8f71e69fdbb65d2cf95cf16ef5a0add0919edb45 (patch)
tree0c282e1224b9ff50ba272b698b92919b72973af9 /spec/frontend/alert_management
parentf645d7e060e85cbf442b4e86009bc776688e4661 (diff)
downloadgitlab-ce-8f71e69fdbb65d2cf95cf16ef5a0add0919edb45.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/alert_management')
-rw-r--r--spec/frontend/alert_management/components/alert_details_spec.js68
1 files changed, 50 insertions, 18 deletions
diff --git a/spec/frontend/alert_management/components/alert_details_spec.js b/spec/frontend/alert_management/components/alert_details_spec.js
index 910bb31b573..f3ebdfc5cc2 100644
--- a/spec/frontend/alert_management/components/alert_details_spec.js
+++ b/spec/frontend/alert_management/components/alert_details_spec.js
@@ -1,25 +1,32 @@
-import { mount, shallowMount } from '@vue/test-utils';
import { GlAlert, GlLoadingIcon } from '@gitlab/ui';
+import { mount, shallowMount } from '@vue/test-utils';
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
-import AlertDetailsTable from '~/vue_shared/components/alert_details_table.vue';
import AlertDetails from '~/alert_management/components/alert_details.vue';
import AlertSummaryRow from '~/alert_management/components/alert_summary_row.vue';
-import createIssueMutation from '~/alert_management/graphql/mutations/create_issue_from_alert.mutation.graphql';
-import { joinPaths } from '~/lib/utils/url_utility';
import {
- trackAlertsDetailsViewsOptions,
ALERTS_SEVERITY_LABELS,
+ trackAlertsDetailsViewsOptions,
} from '~/alert_management/constants';
+import createIssueMutation from '~/alert_management/graphql/mutations/create_issue_from_alert.mutation.graphql';
+import { joinPaths } from '~/lib/utils/url_utility';
import Tracking from '~/tracking';
+import AlertDetailsTable from '~/vue_shared/components/alert_details_table.vue';
import mockAlerts from '../mocks/alerts.json';
const mockAlert = mockAlerts[0];
+const environmentName = 'Production';
+const environmentPath = '/fake/path';
describe('AlertDetails', () => {
- let wrapper;
+ let environmentData = {
+ name: environmentName,
+ path: environmentPath,
+ };
+ let glFeatures = { exposeEnvironmentPathInAlertDetails: false };
let mock;
+ let wrapper;
const projectPath = 'root/alerts';
const projectIssuesPath = 'root/alerts/-/issues';
const projectId = '1';
@@ -33,9 +40,17 @@ describe('AlertDetails', () => {
projectPath,
projectIssuesPath,
projectId,
+ glFeatures,
},
data() {
- return { alert: { ...mockAlert }, sidebarStatus: false, ...data };
+ return {
+ alert: {
+ ...mockAlert,
+ environment: environmentData,
+ },
+ sidebarStatus: false,
+ ...data,
+ };
},
mocks: {
$apollo: {
@@ -72,7 +87,8 @@ describe('AlertDetails', () => {
const findCreateIncidentBtn = () => wrapper.findByTestId('createIncidentBtn');
const findViewIncidentBtn = () => wrapper.findByTestId('viewIncidentBtn');
const findIncidentCreationAlert = () => wrapper.findByTestId('incidentCreationError');
- const findEnvironmentLink = () => wrapper.findByTestId('environmentUrl');
+ const findEnvironmentName = () => wrapper.findByTestId('environmentName');
+ const findEnvironmentPath = () => wrapper.findByTestId('environmentPath');
const findDetailsTable = () => wrapper.find(AlertDetailsTable);
describe('Alert details', () => {
@@ -120,8 +136,6 @@ describe('AlertDetails', () => {
field | data | isShown
${'eventCount'} | ${1} | ${true}
${'eventCount'} | ${undefined} | ${false}
- ${'environment'} | ${undefined} | ${false}
- ${'environment'} | ${'Production'} | ${true}
${'monitoringTool'} | ${'New Relic'} | ${true}
${'monitoringTool'} | ${undefined} | ${false}
${'service'} | ${'Prometheus'} | ${true}
@@ -144,16 +158,34 @@ describe('AlertDetails', () => {
});
});
- describe('environment URL fields', () => {
- it('should show the environment URL when available', () => {
- const environment = 'Production';
- const environmentUrl = 'fake/url';
- mountComponent({
- data: { alert: { ...mockAlert, environment, environmentUrl } },
+ describe('environment fields', () => {
+ describe('when exposeEnvironmentPathInAlertDetails is disabled', () => {
+ beforeEach(mountComponent);
+
+ it('should not show the environment', () => {
+ expect(findEnvironmentName().exists()).toBe(false);
+ expect(findEnvironmentPath().exists()).toBe(false);
});
+ });
- expect(findEnvironmentLink().text()).toBe(environment);
- expect(findEnvironmentLink().attributes('href')).toBe(environmentUrl);
+ describe('when exposeEnvironmentPathInAlertDetails is enabled', () => {
+ beforeEach(() => {
+ glFeatures = { exposeEnvironmentPathInAlertDetails: true };
+ mountComponent();
+ });
+
+ it('should show the environment name with link to path', () => {
+ expect(findEnvironmentName().exists()).toBe(false);
+ expect(findEnvironmentPath().text()).toBe(environmentName);
+ expect(findEnvironmentPath().attributes('href')).toBe(environmentPath);
+ });
+
+ it('should only show the environment name if the path is not provided', () => {
+ environmentData = { name: environmentName, path: null };
+ mountComponent();
+ expect(findEnvironmentPath().exists()).toBe(false);
+ expect(findEnvironmentName().text()).toBe(environmentName);
+ });
});
});