Commit 40549ff5 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'dj-scanner-profile-refactor' into 'master'

Abstract out tooltip from DAST Scanner Profile Form

See merge request gitlab-org/gitlab!43978
parents d83d9f9c 8053ca7b
...@@ -8,8 +8,6 @@ import { ...@@ -8,8 +8,6 @@ import {
GlFormInput, GlFormInput,
GlFormInputGroup, GlFormInputGroup,
GlModal, GlModal,
GlIcon,
GlTooltipDirective,
GlInputGroupText, GlInputGroupText,
GlFormCheckbox, GlFormCheckbox,
GlFormRadioGroup, GlFormRadioGroup,
...@@ -20,6 +18,7 @@ import { redirectTo } from '~/lib/utils/url_utility'; ...@@ -20,6 +18,7 @@ import { redirectTo } from '~/lib/utils/url_utility';
import { serializeFormObject, isEmptyValue } from '~/lib/utils/forms'; import { serializeFormObject, isEmptyValue } from '~/lib/utils/forms';
import dastScannerProfileCreateMutation from '../graphql/dast_scanner_profile_create.mutation.graphql'; import dastScannerProfileCreateMutation from '../graphql/dast_scanner_profile_create.mutation.graphql';
import dastScannerProfileUpdateMutation from '../graphql/dast_scanner_profile_update.mutation.graphql'; import dastScannerProfileUpdateMutation from '../graphql/dast_scanner_profile_update.mutation.graphql';
import tooltipIcon from './tooltip_icon.vue';
import { SCAN_TYPE, SCAN_TYPE_OPTIONS } from '../constants'; import { SCAN_TYPE, SCAN_TYPE_OPTIONS } from '../constants';
const initField = (value, isRequired = true) => ({ const initField = (value, isRequired = true) => ({
...@@ -44,13 +43,10 @@ export default { ...@@ -44,13 +43,10 @@ export default {
GlFormInput, GlFormInput,
GlFormInputGroup, GlFormInputGroup,
GlModal, GlModal,
GlIcon,
GlInputGroupText, GlInputGroupText,
GlFormCheckbox, GlFormCheckbox,
GlFormRadioGroup, GlFormRadioGroup,
}, tooltipIcon,
directives: {
GlTooltip: GlTooltipDirective,
}, },
props: { props: {
projectFullPath: { projectFullPath: {
...@@ -265,12 +261,7 @@ export default { ...@@ -265,12 +261,7 @@ export default {
<gl-form-group> <gl-form-group>
<template #label> <template #label>
{{ s__('DastProfiles|Scan mode') }} {{ s__('DastProfiles|Scan mode') }}
<gl-icon <tooltip-icon :title="i18n.tooltips.scanMode" />
v-gl-tooltip.hover
name="information-o"
class="gl-vertical-align-text-bottom gl-text-gray-400 gl-ml-2"
:title="i18n.tooltips.scanMode"
/>
</template> </template>
<gl-form-radio-group <gl-form-radio-group
...@@ -288,12 +279,7 @@ export default { ...@@ -288,12 +279,7 @@ export default {
> >
<template #label> <template #label>
{{ s__('DastProfiles|Spider timeout') }} {{ s__('DastProfiles|Spider timeout') }}
<gl-icon <tooltip-icon :title="i18n.tooltips.spiderTimeout" />
v-gl-tooltip.hover
name="information-o"
class="gl-vertical-align-text-bottom gl-text-gray-400 gl-ml-2"
:title="i18n.tooltips.spiderTimeout"
/>
</template> </template>
<gl-form-input-group <gl-form-input-group
v-model.number="form.spiderTimeout.value" v-model.number="form.spiderTimeout.value"
...@@ -320,12 +306,7 @@ export default { ...@@ -320,12 +306,7 @@ export default {
> >
<template #label> <template #label>
{{ s__('DastProfiles|Target timeout') }} {{ s__('DastProfiles|Target timeout') }}
<gl-icon <tooltip-icon :title="i18n.tooltips.targetTimeout" />
v-gl-tooltip.hover
name="information-o"
class="gl-vertical-align-text-bottom gl-text-gray-400 gl-ml-2"
:title="i18n.tooltips.targetTimeout"
/>
</template> </template>
<gl-form-input-group <gl-form-input-group
v-model.number="form.targetTimeout.value" v-model.number="form.targetTimeout.value"
...@@ -352,12 +333,7 @@ export default { ...@@ -352,12 +333,7 @@ export default {
<gl-form-group class="col-md-6 mb-0"> <gl-form-group class="col-md-6 mb-0">
<template #label> <template #label>
{{ s__('DastProfiles|AJAX spider') }} {{ s__('DastProfiles|AJAX spider') }}
<gl-icon <tooltip-icon :title="i18n.tooltips.ajaxSpider" />
v-gl-tooltip.hover
name="information-o"
class="gl-vertical-align-text-bottom gl-text-gray-400 gl-ml-2"
:title="i18n.tooltips.ajaxSpider"
/>
</template> </template>
<gl-form-checkbox v-model="form.useAjaxSpider.value">{{ <gl-form-checkbox v-model="form.useAjaxSpider.value">{{
s__('DastProfiles|Turn on AJAX spider') s__('DastProfiles|Turn on AJAX spider')
...@@ -367,12 +343,7 @@ export default { ...@@ -367,12 +343,7 @@ export default {
<gl-form-group class="col-md-6 mb-0"> <gl-form-group class="col-md-6 mb-0">
<template #label> <template #label>
{{ s__('DastProfiles|Debug messages') }} {{ s__('DastProfiles|Debug messages') }}
<gl-icon <tooltip-icon :title="i18n.tooltips.debugMessage" />
v-gl-tooltip.hover
name="information-o"
class="gl-vertical-align-text-bottom gl-text-gray-400 gl-ml-2"
:title="i18n.tooltips.debugMessage"
/>
</template> </template>
<gl-form-checkbox v-model="form.showDebugMessages.value">{{ <gl-form-checkbox v-model="form.showDebugMessages.value">{{
s__('DastProfiles|Show debug messages') s__('DastProfiles|Show debug messages')
......
<script>
import { GlIcon, GlTooltipDirective } from '@gitlab/ui';
export default {
components: {
GlIcon,
},
directives: {
GlTooltip: GlTooltipDirective,
},
props: {
title: {
type: String,
required: true,
},
},
};
</script>
<template>
<gl-icon
v-gl-tooltip.hover="title"
name="information-o"
class="gl-vertical-align-text-bottom gl-text-gray-400 gl-ml-2"
/>
</template>
import { shallowMount } from '@vue/test-utils';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import { GlIcon } from '@gitlab/ui';
import TooltipIcon from 'ee/security_configuration/dast_scanner_profiles/components/tooltip_icon.vue';
describe('Tooltip Icon', () => {
let wrapper;
const findIcon = () => wrapper.find(GlIcon);
const title = 'Hello world';
const createComponent = (props = {}, mountFn = shallowMount) => {
wrapper = mountFn(TooltipIcon, {
propsData: {
title,
...props,
},
directives: {
GlTooltip: createMockDirective(),
},
});
};
beforeEach(() => {
createComponent();
});
afterEach(() => {
wrapper.destroy();
});
it('renders icon correctly', () => {
expect(findIcon().exists()).toBe(true);
});
it('renders tooltip correctly', () => {
const tooltip = getBinding(findIcon().element, 'gl-tooltip').value;
expect(tooltip).toBeDefined();
expect(tooltip).toBe(title);
});
});
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