Commit 5cb9bcd5 authored by Savas Vedova's avatar Savas Vedova

Merge branch '325728-replace-create-flash-with-gl-modal' into 'master'

Use GlAlert instead of a custom alert class

See merge request gitlab-org/gitlab!69854
parents 1e3b765c ccb0bd21
<script> <script>
import { GlModal } from '@gitlab/ui'; import { GlModal, GlAlert } from '@gitlab/ui';
import DismissalCommentBoxToggle from 'ee/vue_shared/security_reports/components/dismissal_comment_box_toggle.vue'; import DismissalCommentBoxToggle from 'ee/vue_shared/security_reports/components/dismissal_comment_box_toggle.vue';
import DismissalCommentModalFooter from 'ee/vue_shared/security_reports/components/dismissal_comment_modal_footer.vue'; import DismissalCommentModalFooter from 'ee/vue_shared/security_reports/components/dismissal_comment_modal_footer.vue';
import DismissalNote from 'ee/vue_shared/security_reports/components/dismissal_note.vue'; import DismissalNote from 'ee/vue_shared/security_reports/components/dismissal_note.vue';
...@@ -19,6 +19,7 @@ export default { ...@@ -19,6 +19,7 @@ export default {
DismissalCommentModalFooter, DismissalCommentModalFooter,
IssueNote, IssueNote,
MergeRequestNote, MergeRequestNote,
GlAlert,
GlModal, GlModal,
ModalFooter, ModalFooter,
SolutionCard, SolutionCard,
...@@ -252,7 +253,9 @@ export default { ...@@ -252,7 +253,9 @@ export default {
/> />
</div> </div>
<div v-if="modal.error" class="alert alert-danger">{{ modal.error }}</div> <gl-alert v-if="modal.error" variant="danger" :dismissible="false">{{
modal.error
}}</gl-alert>
</slot> </slot>
<template #modal-footer> <template #modal-footer>
<dismissal-comment-modal-footer <dismissal-comment-modal-footer
......
import { GlModal } from '@gitlab/ui'; import { GlModal, GlAlert } from '@gitlab/ui';
import { mount, shallowMount } from '@vue/test-utils'; import { mount, shallowMount } from '@vue/test-utils';
import Vue from 'vue'; import Vue from 'vue';
import IssueNote from 'ee/vue_shared/security_reports/components/issue_note.vue'; import IssueNote from 'ee/vue_shared/security_reports/components/issue_note.vue';
...@@ -28,10 +28,25 @@ describe('Security Reports modal', () => { ...@@ -28,10 +28,25 @@ describe('Security Reports modal', () => {
}; };
describe('modal', () => { describe('modal', () => {
const findAlert = () => wrapper.findComponent(GlAlert);
it('renders a large modal', () => { it('renders a large modal', () => {
mountComponent({ modal: createState().modal }, mount); mountComponent({ modal: createState().modal }, mount);
expect(modal.props('size')).toBe('lg'); expect(modal.props('size')).toBe('lg');
}); });
it('does not render the error message the modal has no error', () => {
mountComponent({ modal: createState().modal });
expect(findAlert().exists()).toBe(false);
});
it('renders an error message when the modal has an error', () => {
const { modal: modalData } = createState();
modalData.error = 'Something went wront';
mountComponent({ modal: modalData });
expect(findAlert().props('variant')).toBe('danger');
expect(findAlert().text()).toBe(modalData.error);
});
}); });
describe('with permissions', () => { describe('with permissions', () => {
......
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