summaryrefslogtreecommitdiff
path: root/spec/frontend/incidents_settings
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/incidents_settings')
-rw-r--r--spec/frontend/incidents_settings/components/__snapshots__/alerts_form_spec.js.snap114
-rw-r--r--spec/frontend/incidents_settings/components/__snapshots__/incidents_settings_tabs_spec.js.snap18
-rw-r--r--spec/frontend/incidents_settings/components/__snapshots__/pagerduty_form_spec.js.snap16
-rw-r--r--spec/frontend/incidents_settings/components/alerts_form_spec.js51
-rw-r--r--spec/frontend/incidents_settings/components/incidents_settings_service_spec.js7
-rw-r--r--spec/frontend/incidents_settings/components/pagerduty_form_spec.js23
6 files changed, 21 insertions, 208 deletions
diff --git a/spec/frontend/incidents_settings/components/__snapshots__/alerts_form_spec.js.snap b/spec/frontend/incidents_settings/components/__snapshots__/alerts_form_spec.js.snap
deleted file mode 100644
index 85d21f231b1..00000000000
--- a/spec/frontend/incidents_settings/components/__snapshots__/alerts_form_spec.js.snap
+++ /dev/null
@@ -1,114 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`Alert integration settings form default state should match the default snapshot 1`] = `
-<div>
- <p>
- <gl-sprintf-stub
- message="Action to take when receiving an alert. %{docsLink}"
- />
- </p>
-
- <form>
- <gl-form-group-stub
- class="gl-pl-0"
- >
- <gl-form-checkbox-stub
- checked="true"
- data-qa-selector="create_issue_checkbox"
- >
- <span>
- Create an incident. Incidents are created for each alert triggered.
- </span>
- </gl-form-checkbox-stub>
- </gl-form-group-stub>
-
- <gl-form-group-stub
- class="col-8 col-md-9 gl-px-6"
- label-for="alert-integration-settings-issue-template"
- label-size="sm"
- >
- <label
- class="gl-display-inline-flex"
- for="alert-integration-settings-issue-template"
- >
-
- Incident template (optional)
-
- <gl-link-stub
- href="/help/user/project/description_templates#create-an-issue-template"
- target="_blank"
- >
- <gl-icon-stub
- name="question"
- size="12"
- />
- </gl-link-stub>
- </label>
-
- <gl-dropdown-stub
- block="true"
- category="primary"
- data-qa-selector="incident_templates_dropdown"
- headertext=""
- hideheaderborder="true"
- id="alert-integration-settings-issue-template"
- size="medium"
- text="selecte_tmpl"
- variant="default"
- >
- <gl-dropdown-item-stub
- avatarurl=""
- data-qa-selector="incident_templates_item"
- iconcolor=""
- iconname=""
- iconrightarialabel=""
- iconrightname=""
- ischeckitem="true"
- secondarytext=""
- >
-
- No template selected
-
- </gl-dropdown-item-stub>
- </gl-dropdown-stub>
- </gl-form-group-stub>
-
- <gl-form-group-stub
- class="gl-pl-0 gl-mb-5"
- >
- <gl-form-checkbox-stub>
- <span>
- Send a single email notification to Owners and Maintainers for new alerts.
- </span>
- </gl-form-checkbox-stub>
- </gl-form-group-stub>
-
- <gl-form-group-stub
- class="gl-pl-0 gl-mb-5"
- >
- <gl-form-checkbox-stub
- checked="true"
- >
- <span>
- Automatically close associated incident when a recovery alert notification resolves an alert
- </span>
- </gl-form-checkbox-stub>
- </gl-form-group-stub>
-
- <gl-button-stub
- buttontextclasses=""
- category="primary"
- class="js-no-auto-disable"
- data-qa-selector="save_changes_button"
- icon=""
- size="medium"
- type="submit"
- variant="success"
- >
-
- Save changes
-
- </gl-button-stub>
- </form>
-</div>
-`;
diff --git a/spec/frontend/incidents_settings/components/__snapshots__/incidents_settings_tabs_spec.js.snap b/spec/frontend/incidents_settings/components/__snapshots__/incidents_settings_tabs_spec.js.snap
index 07f90a12f0f..4f70f908c4a 100644
--- a/spec/frontend/incidents_settings/components/__snapshots__/incidents_settings_tabs_spec.js.snap
+++ b/spec/frontend/incidents_settings/components/__snapshots__/incidents_settings_tabs_spec.js.snap
@@ -2,7 +2,7 @@
exports[`IncidentsSettingTabs should render the component 1`] = `
<section
- class="settings no-animate qa-incident-management-settings"
+ class="settings no-animate"
data-qa-selector="incidents_settings_content"
id="incident-management-settings"
>
@@ -30,7 +30,7 @@ exports[`IncidentsSettingTabs should render the component 1`] = `
<p>
- Set up integrations with external tools to help better manage incidents.
+ Fine-tune incident settings and set up integrations with external tools to help better manage incidents.
</p>
</div>
@@ -41,15 +41,8 @@ exports[`IncidentsSettingTabs should render the component 1`] = `
<gl-tabs-stub
theme="indigo"
>
- <gl-tab-stub
- title="Alert integration"
- titlelinkclass=""
- >
- <alertssettingsform-stub
- class="gl-pt-3"
- data-testid="AlertsSettingsForm-tab"
- />
- </gl-tab-stub>
+ <!---->
+
<gl-tab-stub
title="PagerDuty integration"
titlelinkclass=""
@@ -59,9 +52,6 @@ exports[`IncidentsSettingTabs should render the component 1`] = `
data-testid="PagerDutySettingsForm-tab"
/>
</gl-tab-stub>
- <!---->
-
- <!---->
</gl-tabs-stub>
</div>
</section>
diff --git a/spec/frontend/incidents_settings/components/__snapshots__/pagerduty_form_spec.js.snap b/spec/frontend/incidents_settings/components/__snapshots__/pagerduty_form_spec.js.snap
index 79ad5ad1bb9..2a976c04319 100644
--- a/spec/frontend/incidents_settings/components/__snapshots__/pagerduty_form_spec.js.snap
+++ b/spec/frontend/incidents_settings/components/__snapshots__/pagerduty_form_spec.js.snap
@@ -13,6 +13,7 @@ exports[`Alert integration settings form should match the default snapshot 1`] =
<form>
<gl-form-group-stub
class="col-8 col-md-9 gl-p-0"
+ labeldescription=""
>
<gl-toggle-stub
id="active"
@@ -26,6 +27,7 @@ exports[`Alert integration settings form should match the default snapshot 1`] =
class="col-8 col-md-9 gl-p-0"
label="Webhook URL"
label-for="url"
+ labeldescription=""
>
<gl-form-input-group-stub
data-testid="webhook-url"
@@ -66,20 +68,6 @@ exports[`Alert integration settings form should match the default snapshot 1`] =
</gl-modal-stub>
</gl-form-group-stub>
-
- <gl-button-stub
- buttontextclasses=""
- category="primary"
- class="js-no-auto-disable"
- icon=""
- size="medium"
- type="submit"
- variant="success"
- >
-
- Save changes
-
- </gl-button-stub>
</form>
</div>
`;
diff --git a/spec/frontend/incidents_settings/components/alerts_form_spec.js b/spec/frontend/incidents_settings/components/alerts_form_spec.js
deleted file mode 100644
index 2516e8afdfa..00000000000
--- a/spec/frontend/incidents_settings/components/alerts_form_spec.js
+++ /dev/null
@@ -1,51 +0,0 @@
-import { shallowMount } from '@vue/test-utils';
-import AlertsSettingsForm from '~/incidents_settings/components/alerts_form.vue';
-
-describe('Alert integration settings form', () => {
- let wrapper;
- const service = { updateSettings: jest.fn().mockResolvedValue() };
-
- const findForm = () => wrapper.find({ ref: 'settingsForm' });
-
- beforeEach(() => {
- wrapper = shallowMount(AlertsSettingsForm, {
- provide: {
- service,
- alertSettings: {
- issueTemplateKey: 'selecte_tmpl',
- createIssue: true,
- sendEmail: false,
- templates: [],
- autoCloseIncident: true,
- },
- },
- });
- });
-
- afterEach(() => {
- if (wrapper) {
- wrapper.destroy();
- wrapper = null;
- }
- });
-
- describe('default state', () => {
- it('should match the default snapshot', () => {
- expect(wrapper.element).toMatchSnapshot();
- });
- });
-
- describe('form', () => {
- it('should call service `updateSettings` on submit', () => {
- findForm().trigger('submit');
- expect(service.updateSettings).toHaveBeenCalledWith(
- expect.objectContaining({
- create_issue: wrapper.vm.createIssueEnabled,
- issue_template_key: wrapper.vm.issueTemplate,
- send_email: wrapper.vm.sendEmailEnabled,
- auto_close_incident: wrapper.vm.autoCloseIncident,
- }),
- );
- });
- });
-});
diff --git a/spec/frontend/incidents_settings/components/incidents_settings_service_spec.js b/spec/frontend/incidents_settings/components/incidents_settings_service_spec.js
index 5476e895c68..f4342c56f98 100644
--- a/spec/frontend/incidents_settings/components/incidents_settings_service_spec.js
+++ b/spec/frontend/incidents_settings/components/incidents_settings_service_spec.js
@@ -1,5 +1,5 @@
import AxiosMockAdapter from 'axios-mock-adapter';
-import { deprecatedCreateFlash as createFlash } from '~/flash';
+import createFlash from '~/flash';
import { ERROR_MSG } from '~/incidents_settings/constants';
import IncidentsSettingsService from '~/incidents_settings/incidents_settings_service';
import axios from '~/lib/utils/axios_utils';
@@ -37,7 +37,10 @@ describe('IncidentsSettingsService', () => {
mock.onPatch().reply(httpStatusCodes.BAD_REQUEST);
return service.updateSettings({}).then(() => {
- expect(createFlash).toHaveBeenCalledWith(expect.stringContaining(ERROR_MSG), 'alert');
+ expect(createFlash).toHaveBeenCalledWith({
+ message: expect.stringContaining(ERROR_MSG),
+ type: 'alert',
+ });
});
});
});
diff --git a/spec/frontend/incidents_settings/components/pagerduty_form_spec.js b/spec/frontend/incidents_settings/components/pagerduty_form_spec.js
index 2ffd1292ddc..d2b591d427d 100644
--- a/spec/frontend/incidents_settings/components/pagerduty_form_spec.js
+++ b/spec/frontend/incidents_settings/components/pagerduty_form_spec.js
@@ -1,5 +1,5 @@
-import { GlAlert, GlModal } from '@gitlab/ui';
-import { shallowMount } from '@vue/test-utils';
+import { GlAlert, GlModal, GlToggle } from '@gitlab/ui';
+import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import waitForPromises from 'helpers/wait_for_promises';
import PagerDutySettingsForm from '~/incidents_settings/components/pagerduty_form.vue';
@@ -8,13 +8,13 @@ describe('Alert integration settings form', () => {
const resetWebhookUrl = jest.fn();
const service = { updateSettings: jest.fn().mockResolvedValue(), resetWebhookUrl };
- const findForm = () => wrapper.find({ ref: 'settingsForm' });
- const findWebhookInput = () => wrapper.find('[data-testid="webhook-url"]');
- const findModal = () => wrapper.find(GlModal);
- const findAlert = () => wrapper.find(GlAlert);
+ const findWebhookInput = () => wrapper.findByTestId('webhook-url');
+ const findFormToggle = () => wrapper.findComponent(GlToggle);
+ const findModal = () => wrapper.findComponent(GlModal);
+ const findAlert = () => wrapper.findComponent(GlAlert);
beforeEach(() => {
- wrapper = shallowMount(PagerDutySettingsForm, {
+ wrapper = shallowMountExtended(PagerDutySettingsForm, {
provide: {
service,
pagerDutySettings: {
@@ -27,18 +27,15 @@ describe('Alert integration settings form', () => {
});
afterEach(() => {
- if (wrapper) {
- wrapper.destroy();
- wrapper = null;
- }
+ wrapper.destroy();
});
it('should match the default snapshot', () => {
expect(wrapper.element).toMatchSnapshot();
});
- it('should call service `updateSettings` on form submit', () => {
- findForm().trigger('submit');
+ it('should call service `updateSettings` on toggle change', () => {
+ findFormToggle().vm.$emit('change', true);
expect(service.updateSettings).toHaveBeenCalledWith(
expect.objectContaining({ pagerduty_active: wrapper.vm.active }),
);