Commit 7ca18982 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'tomquirk/342463-final-improve-integration-settings-form-spec' into 'master'

Improvements to integration_settings_form_spec.js

See merge request gitlab-org/gitlab!72743
parents 47077623 a7e73ed0
import { s__ } from '~/locale'; import { s__, __ } from '~/locale';
export const TEST_INTEGRATION_EVENT = 'testIntegration'; export const TEST_INTEGRATION_EVENT = 'testIntegration';
export const SAVE_INTEGRATION_EVENT = 'saveIntegration'; export const SAVE_INTEGRATION_EVENT = 'saveIntegration';
...@@ -21,3 +21,9 @@ export const overrideDropdownDescriptions = { ...@@ -21,3 +21,9 @@ export const overrideDropdownDescriptions = {
'Integrations|Default settings are inherited from the instance level.', 'Integrations|Default settings are inherited from the instance level.',
), ),
}; };
export const I18N_FETCH_TEST_SETTINGS_DEFAULT_ERROR_MESSAGE = s__(
'Integrations|Connection failed. Please check your settings.',
);
export const I18N_DEFAULT_ERROR_MESSAGE = __('Something went wrong on our end.');
export const I18N_SUCCESSFUL_CONNECTION_MESSAGE = s__('Integrations|Connection successful.');
import { delay } from 'lodash'; import { delay } from 'lodash';
import { __, s__ } from '~/locale';
import toast from '~/vue_shared/plugins/global_toast'; import toast from '~/vue_shared/plugins/global_toast';
import axios from '../lib/utils/axios_utils'; import axios from '../lib/utils/axios_utils';
import initForm from './edit'; import initForm from './edit';
...@@ -10,6 +9,9 @@ import { ...@@ -10,6 +9,9 @@ import {
GET_JIRA_ISSUE_TYPES_EVENT, GET_JIRA_ISSUE_TYPES_EVENT,
TOGGLE_INTEGRATION_EVENT, TOGGLE_INTEGRATION_EVENT,
VALIDATE_INTEGRATION_FORM_EVENT, VALIDATE_INTEGRATION_FORM_EVENT,
I18N_FETCH_TEST_SETTINGS_DEFAULT_ERROR_MESSAGE,
I18N_DEFAULT_ERROR_MESSAGE,
I18N_SUCCESSFUL_CONNECTION_MESSAGE,
} from './constants'; } from './constants';
export default class IntegrationSettingsForm { export default class IntegrationSettingsForm {
...@@ -104,11 +106,7 @@ export default class IntegrationSettingsForm { ...@@ -104,11 +106,7 @@ export default class IntegrationSettingsForm {
return this.fetchTestSettings(formData) return this.fetchTestSettings(formData)
.then( .then(
({ ({
data: { data: { issuetypes, error, message = I18N_FETCH_TEST_SETTINGS_DEFAULT_ERROR_MESSAGE },
issuetypes,
error,
message = s__('Integrations|Connection failed. Please check your settings.'),
},
}) => { }) => {
if (error || !issuetypes?.length) { if (error || !issuetypes?.length) {
eventHub.$emit(VALIDATE_INTEGRATION_FORM_EVENT); eventHub.$emit(VALIDATE_INTEGRATION_FORM_EVENT);
...@@ -118,7 +116,7 @@ export default class IntegrationSettingsForm { ...@@ -118,7 +116,7 @@ export default class IntegrationSettingsForm {
dispatch('receiveJiraIssueTypesSuccess', issuetypes); dispatch('receiveJiraIssueTypesSuccess', issuetypes);
}, },
) )
.catch(({ message = __('Something went wrong on our end.') }) => { .catch(({ message = I18N_DEFAULT_ERROR_MESSAGE }) => {
dispatch('receiveJiraIssueTypesError', message); dispatch('receiveJiraIssueTypesError', message);
}); });
} }
...@@ -140,11 +138,11 @@ export default class IntegrationSettingsForm { ...@@ -140,11 +138,11 @@ export default class IntegrationSettingsForm {
toast(`${data.message} ${data.service_response}`); toast(`${data.message} ${data.service_response}`);
} else { } else {
this.vue.$store.dispatch('receiveJiraIssueTypesSuccess', data.issuetypes); this.vue.$store.dispatch('receiveJiraIssueTypesSuccess', data.issuetypes);
toast(s__('Integrations|Connection successful.')); toast(I18N_SUCCESSFUL_CONNECTION_MESSAGE);
} }
}) })
.catch(() => { .catch(() => {
toast(__('Something went wrong on our end.')); toast(I18N_DEFAULT_ERROR_MESSAGE);
}) })
.finally(() => { .finally(() => {
this.vue.$store.dispatch('setIsTesting', false); this.vue.$store.dispatch('setIsTesting', false);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment