Commit dc63b0a6 authored by Libor Vanc's avatar Libor Vanc Committed by Martin Wortschack

Replace LoadingButton with GlButton for the comment dismissal modal

parent 25b507dd
---
title: Replace LoadingButton with GlButton for the comment dismissal modal
merge_request: 40882
author:
type: performance
...@@ -2,13 +2,11 @@ ...@@ -2,13 +2,11 @@
import { GlButton } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import LoadingButton from '~/vue_shared/components/loading_button.vue';
export default { export default {
name: 'DismissalCommentModalFooter', name: 'DismissalCommentModalFooter',
components: { components: {
GlButton, GlButton,
LoadingButton,
}, },
props: { props: {
isDismissingVulnerability: { isDismissingVulnerability: {
...@@ -68,14 +66,15 @@ export default { ...@@ -68,14 +66,15 @@ export default {
<gl-button variant="default" category="primary" class="js-cancel" @click="$emit('cancel')"> <gl-button variant="default" category="primary" class="js-cancel" @click="$emit('cancel')">
{{ __('Cancel') }} {{ __('Cancel') }}
</gl-button> </gl-button>
<loading-button <gl-button
:loading="isDismissingVulnerability" :loading="isDismissingVulnerability"
:disabled="isDismissingVulnerability" :disabled="isDismissingVulnerability"
:label="submitLabel"
data-qa-selector="add_and_dismiss_button" data-qa-selector="add_and_dismiss_button"
class="js-loading-button" data-testid="add_and_dismiss_button"
container-class="btn btn-close" variant="warning"
@click="handleSubmit" @click="handleSubmit"
/> >
{{ submitLabel }}
</gl-button>
</div> </div>
</template> </template>
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import component from 'ee/vue_shared/security_reports/components/dismissal_comment_modal_footer.vue'; import component from 'ee/vue_shared/security_reports/components/dismissal_comment_modal_footer.vue';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import LoadingButton from '~/vue_shared/components/loading_button.vue';
jest.mock('~/tracking'); jest.mock('~/tracking');
...@@ -9,6 +8,8 @@ describe('DismissalCommentModalFooter', () => { ...@@ -9,6 +8,8 @@ describe('DismissalCommentModalFooter', () => {
let origPage; let origPage;
let wrapper; let wrapper;
const findAddAndDismissButton = () => wrapper.find('[data-testid="add_and_dismiss_button"]');
afterEach(() => { afterEach(() => {
document.body.dataset.page = origPage; document.body.dataset.page = origPage;
wrapper.destroy(); wrapper.destroy();
...@@ -25,11 +26,11 @@ describe('DismissalCommentModalFooter', () => { ...@@ -25,11 +26,11 @@ describe('DismissalCommentModalFooter', () => {
}); });
it('should render the "Add comment and dismiss" button', () => { it('should render the "Add comment and dismiss" button', () => {
expect(wrapper.find(LoadingButton).text()).toBe('Add comment & dismiss'); expect(findAddAndDismissButton().text()).toBe('Add comment & dismiss');
}); });
it('should emit the "addCommentAndDismiss" event when clicked', () => { it('should emit the "addCommentAndDismiss" event when clicked', () => {
wrapper.find(LoadingButton).trigger('click'); findAddAndDismissButton().trigger('click');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().addCommentAndDismiss).toBeTruthy(); expect(wrapper.emitted().addCommentAndDismiss).toBeTruthy();
...@@ -59,11 +60,11 @@ describe('DismissalCommentModalFooter', () => { ...@@ -59,11 +60,11 @@ describe('DismissalCommentModalFooter', () => {
}); });
it('should render the "Add comment and dismiss" button', () => { it('should render the "Add comment and dismiss" button', () => {
expect(wrapper.find(LoadingButton).text()).toBe('Add comment'); expect(findAddAndDismissButton().text()).toBe('Add comment');
}); });
it('should emit the "addCommentAndDismiss" event when clicked', () => { it('should emit the "addCommentAndDismiss" event when clicked', () => {
wrapper.find(LoadingButton).trigger('click'); findAddAndDismissButton().trigger('click');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().addDismissalComment).toBeTruthy(); expect(wrapper.emitted().addDismissalComment).toBeTruthy();
...@@ -82,11 +83,11 @@ describe('DismissalCommentModalFooter', () => { ...@@ -82,11 +83,11 @@ describe('DismissalCommentModalFooter', () => {
}); });
it('should render the "Save comment" button', () => { it('should render the "Save comment" button', () => {
expect(wrapper.find(LoadingButton).text()).toBe('Save comment'); expect(findAddAndDismissButton().text()).toBe('Save comment');
}); });
it('should emit the "addCommentAndDismiss" event when clicked', () => { it('should emit the "addCommentAndDismiss" event when clicked', () => {
wrapper.find(LoadingButton).trigger('click'); findAddAndDismissButton().trigger('click');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().addDismissalComment).toBeTruthy(); expect(wrapper.emitted().addDismissalComment).toBeTruthy();
......
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