Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-01-10 18:14:26 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-01-10 18:14:26 +0300
commit53716bea26fa76ac7176f51bbef672ffcdcd1ba4 (patch)
treee7df7f7921aec99f3d2c20bc5c7284d1e8997007 /spec/frontend/integrations
parentd85be261b2898166676be4f329a548f61e2917f4 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/integrations')
-rw-r--r--spec/frontend/integrations/edit/components/integration_form_spec.js102
-rw-r--r--spec/frontend/integrations/edit/store/actions_spec.js37
-rw-r--r--spec/frontend/integrations/edit/store/mutations_spec.js24
-rw-r--r--spec/frontend/integrations/edit/store/state_spec.js2
4 files changed, 92 insertions, 73 deletions
diff --git a/spec/frontend/integrations/edit/components/integration_form_spec.js b/spec/frontend/integrations/edit/components/integration_form_spec.js
index 4c1394f3a87..6aa955033f7 100644
--- a/spec/frontend/integrations/edit/components/integration_form_spec.js
+++ b/spec/frontend/integrations/edit/components/integration_form_spec.js
@@ -3,7 +3,7 @@ import MockAdapter from 'axios-mock-adapter';
import * as Sentry from '@sentry/browser';
import { setHTMLFixture } from 'helpers/fixtures';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
-import { mockIntegrationProps } from 'jest/integrations/edit/mock_data';
+import waitForPromises from 'helpers/wait_for_promises';
import ActiveCheckbox from '~/integrations/edit/components/active_checkbox.vue';
import ConfirmationModal from '~/integrations/edit/components/confirmation_modal.vue';
import DynamicField from '~/integrations/edit/components/dynamic_field.vue';
@@ -13,7 +13,6 @@ import JiraTriggerFields from '~/integrations/edit/components/jira_trigger_field
import OverrideDropdown from '~/integrations/edit/components/override_dropdown.vue';
import ResetConfirmationModal from '~/integrations/edit/components/reset_confirmation_modal.vue';
import TriggerFields from '~/integrations/edit/components/trigger_fields.vue';
-import waitForPromises from 'helpers/wait_for_promises';
import {
integrationLevels,
I18N_SUCCESSFUL_CONNECTION_MESSAGE,
@@ -23,9 +22,12 @@ import {
import { createStore } from '~/integrations/edit/store';
import eventHub from '~/integrations/edit/event_hub';
import httpStatus from '~/lib/utils/http_status';
+import { refreshCurrentPage } from '~/lib/utils/url_utility';
+import { mockIntegrationProps } from '../mock_data';
jest.mock('~/integrations/edit/event_hub');
jest.mock('@sentry/browser');
+jest.mock('~/lib/utils/url_utility');
describe('IntegrationForm', () => {
const mockToastShow = jest.fn();
@@ -80,7 +82,8 @@ describe('IntegrationForm', () => {
const findConfirmationModal = () => wrapper.findComponent(ConfirmationModal);
const findResetConfirmationModal = () => wrapper.findComponent(ResetConfirmationModal);
const findResetButton = () => wrapper.findByTestId('reset-button');
- const findSaveButton = () => wrapper.findByTestId('save-button');
+ const findProjectSaveButton = () => wrapper.findByTestId('save-button');
+ const findInstanceOrGroupSaveButton = () => wrapper.findByTestId('save-button-instance-group');
const findTestButton = () => wrapper.findByTestId('test-button');
const findJiraTriggerFields = () => wrapper.findComponent(JiraTriggerFields);
const findJiraIssuesFields = () => wrapper.findComponent(JiraIssuesFields);
@@ -395,11 +398,11 @@ describe('IntegrationForm', () => {
},
});
- await findSaveButton().vm.$emit('click', new Event('click'));
+ await findProjectSaveButton().vm.$emit('click', new Event('click'));
});
it('sets save button `loading` prop to `true`', () => {
- expect(findSaveButton().props('loading')).toBe(true);
+ expect(findProjectSaveButton().props('loading')).toBe(true);
});
it('sets test button `disabled` prop to `true`', () => {
@@ -425,7 +428,7 @@ describe('IntegrationForm', () => {
},
});
- await findSaveButton().vm.$emit('click', new Event('click'));
+ await findProjectSaveButton().vm.$emit('click', new Event('click'));
});
it('submit form', () => {
@@ -445,7 +448,7 @@ describe('IntegrationForm', () => {
},
});
- await findSaveButton().vm.$emit('click', new Event('click'));
+ await findProjectSaveButton().vm.$emit('click', new Event('click'));
});
it('does not submit form', () => {
@@ -453,7 +456,7 @@ describe('IntegrationForm', () => {
});
it('sets save button `loading` prop to `false`', () => {
- expect(findSaveButton().props('loading')).toBe(false);
+ expect(findProjectSaveButton().props('loading')).toBe(false);
});
it('sets test button `disabled` prop to `false`', () => {
@@ -507,7 +510,7 @@ describe('IntegrationForm', () => {
});
it('sets save button `disabled` prop to `true`', () => {
- expect(findSaveButton().props('disabled')).toBe(true);
+ expect(findProjectSaveButton().props('disabled')).toBe(true);
});
});
@@ -536,7 +539,7 @@ describe('IntegrationForm', () => {
});
it('sets save button `disabled` prop to `false`', () => {
- expect(findSaveButton().props('disabled')).toBe(false);
+ expect(findProjectSaveButton().props('disabled')).toBe(false);
});
it(`${expectSentry ? 'does' : 'does not'} capture exception in Sentry`, () => {
@@ -545,4 +548,83 @@ describe('IntegrationForm', () => {
});
});
});
+
+ describe('when `reset-confirmation-modal` emits `reset` event', () => {
+ const mockResetPath = '/reset';
+
+ describe('buttons', () => {
+ beforeEach(async () => {
+ createComponent({
+ customStateProps: {
+ integrationLevel: integrationLevels.GROUP,
+ canTest: true,
+ resetPath: mockResetPath,
+ },
+ });
+
+ await findResetConfirmationModal().vm.$emit('reset');
+ });
+
+ it('sets reset button `loading` prop to `true`', () => {
+ expect(findResetButton().props('loading')).toBe(true);
+ });
+
+ it('sets other button `disabled` props to `true`', () => {
+ expect(findInstanceOrGroupSaveButton().props('disabled')).toBe(true);
+ expect(findTestButton().props('disabled')).toBe(true);
+ });
+ });
+
+ describe('when "reset settings" request fails', () => {
+ beforeEach(async () => {
+ mockAxios.onPost(mockResetPath).replyOnce(httpStatus.INTERNAL_SERVER_ERROR);
+ createComponent({
+ customStateProps: {
+ integrationLevel: integrationLevels.GROUP,
+ canTest: true,
+ resetPath: mockResetPath,
+ },
+ });
+
+ await findResetConfirmationModal().vm.$emit('reset');
+ await waitForPromises();
+ });
+
+ it('displays a toast', () => {
+ expect(mockToastShow).toHaveBeenCalledWith(I18N_DEFAULT_ERROR_MESSAGE);
+ });
+
+ it('captures exception in Sentry', () => {
+ expect(Sentry.captureException).toHaveBeenCalledTimes(1);
+ });
+
+ it('sets reset button `loading` prop to `false`', () => {
+ expect(findResetButton().props('loading')).toBe(false);
+ });
+
+ it('sets button `disabled` props to `false`', () => {
+ expect(findInstanceOrGroupSaveButton().props('disabled')).toBe(false);
+ expect(findTestButton().props('disabled')).toBe(false);
+ });
+ });
+
+ describe('when "reset settings" succeeds', () => {
+ beforeEach(async () => {
+ mockAxios.onPost(mockResetPath).replyOnce(httpStatus.OK);
+ createComponent({
+ customStateProps: {
+ integrationLevel: integrationLevels.GROUP,
+ resetPath: mockResetPath,
+ },
+ });
+
+ await findResetConfirmationModal().vm.$emit('reset');
+ await waitForPromises();
+ });
+
+ it('calls `refreshCurrentPage`', () => {
+ expect(refreshCurrentPage).toHaveBeenCalledTimes(1);
+ });
+ });
+ });
});
diff --git a/spec/frontend/integrations/edit/store/actions_spec.js b/spec/frontend/integrations/edit/store/actions_spec.js
index b413de2b286..a5627d8b669 100644
--- a/spec/frontend/integrations/edit/store/actions_spec.js
+++ b/spec/frontend/integrations/edit/store/actions_spec.js
@@ -4,17 +4,12 @@ import testAction from 'helpers/vuex_action_helper';
import { I18N_FETCH_TEST_SETTINGS_DEFAULT_ERROR_MESSAGE } from '~/integrations/constants';
import {
setOverride,
- setIsResetting,
- requestResetIntegration,
- receiveResetIntegrationSuccess,
- receiveResetIntegrationError,
requestJiraIssueTypes,
receiveJiraIssueTypesSuccess,
receiveJiraIssueTypesError,
} from '~/integrations/edit/store/actions';
import * as types from '~/integrations/edit/store/mutation_types';
import createState from '~/integrations/edit/store/state';
-import { refreshCurrentPage } from '~/lib/utils/url_utility';
import { mockJiraIssueTypes } from '../mock_data';
jest.mock('~/lib/utils/url_utility');
@@ -38,38 +33,6 @@ describe('Integration form store actions', () => {
});
});
- describe('setIsResetting', () => {
- it('should commit isResetting mutation', () => {
- return testAction(setIsResetting, true, state, [
- { type: types.SET_IS_RESETTING, payload: true },
- ]);
- });
- });
-
- describe('requestResetIntegration', () => {
- it('should commit REQUEST_RESET_INTEGRATION mutation', () => {
- return testAction(requestResetIntegration, null, state, [
- { type: types.REQUEST_RESET_INTEGRATION },
- ]);
- });
- });
-
- describe('receiveResetIntegrationSuccess', () => {
- it('should call refreshCurrentPage()', () => {
- return testAction(receiveResetIntegrationSuccess, null, state, [], [], () => {
- expect(refreshCurrentPage).toHaveBeenCalled();
- });
- });
- });
-
- describe('receiveResetIntegrationError', () => {
- it('should commit RECEIVE_RESET_INTEGRATION_ERROR mutation', () => {
- return testAction(receiveResetIntegrationError, null, state, [
- { type: types.RECEIVE_RESET_INTEGRATION_ERROR },
- ]);
- });
- });
-
describe('requestJiraIssueTypes', () => {
describe.each`
scenario | responseCode | response | action
diff --git a/spec/frontend/integrations/edit/store/mutations_spec.js b/spec/frontend/integrations/edit/store/mutations_spec.js
index 641547550d1..ecac9d88982 100644
--- a/spec/frontend/integrations/edit/store/mutations_spec.js
+++ b/spec/frontend/integrations/edit/store/mutations_spec.js
@@ -17,30 +17,6 @@ describe('Integration form store mutations', () => {
});
});
- describe(`${types.SET_IS_RESETTING}`, () => {
- it('sets isResetting', () => {
- mutations[types.SET_IS_RESETTING](state, true);
-
- expect(state.isResetting).toBe(true);
- });
- });
-
- describe(`${types.REQUEST_RESET_INTEGRATION}`, () => {
- it('sets isResetting', () => {
- mutations[types.REQUEST_RESET_INTEGRATION](state);
-
- expect(state.isResetting).toBe(true);
- });
- });
-
- describe(`${types.RECEIVE_RESET_INTEGRATION_ERROR}`, () => {
- it('sets isResetting', () => {
- mutations[types.RECEIVE_RESET_INTEGRATION_ERROR](state);
-
- expect(state.isResetting).toBe(false);
- });
- });
-
describe(`${types.SET_JIRA_ISSUE_TYPES}`, () => {
it('sets jiraIssueTypes', () => {
const jiraIssueTypes = ['issue', 'epic'];
diff --git a/spec/frontend/integrations/edit/store/state_spec.js b/spec/frontend/integrations/edit/store/state_spec.js
index 5582be7fd3c..0b4ca8fb65c 100644
--- a/spec/frontend/integrations/edit/store/state_spec.js
+++ b/spec/frontend/integrations/edit/store/state_spec.js
@@ -5,8 +5,6 @@ describe('Integration form state factory', () => {
expect(createState()).toEqual({
defaultState: null,
customState: {},
- isSaving: false,
- isResetting: false,
override: false,
isLoadingJiraIssueTypes: false,
jiraIssueTypes: [],