Commit 39a0fc6b authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'nmezzopera-update-ee-vue-shared-tests-for-boostrap-vue' into 'master'

Update EE vue shared tests for boostrap vue upgrade

See merge request gitlab-org/gitlab!20712
parents dc49f6cd a5cd4b95
...@@ -25,6 +25,7 @@ describe('Card security reports app', () => { ...@@ -25,6 +25,7 @@ describe('Card security reports app', () => {
localVue, localVue,
store: createStore(), store: createStore(),
sync: false, sync: false,
attachToDocument: true,
stubs: ['security-dashboard-table'], stubs: ['security-dashboard-table'],
propsData: { propsData: {
hasPipelineData: true, hasPipelineData: true,
......
...@@ -5,12 +5,16 @@ import LoadingButton from '~/vue_shared/components/loading_button.vue'; ...@@ -5,12 +5,16 @@ import LoadingButton from '~/vue_shared/components/loading_button.vue';
describe('DismissalButton', () => { describe('DismissalButton', () => {
let wrapper; let wrapper;
const mountComponent = options => {
wrapper = mount(component, { sync: false, attachToDocument: true, ...options });
};
describe('With a non-dismissed vulnerability', () => { describe('With a non-dismissed vulnerability', () => {
beforeEach(() => { beforeEach(() => {
const propsData = { const propsData = {
isDismissed: false, isDismissed: false,
}; };
wrapper = mount(component, { propsData }); mountComponent({ propsData });
}); });
it('should render the dismiss button', () => { it('should render the dismiss button', () => {
...@@ -37,7 +41,7 @@ describe('DismissalButton', () => { ...@@ -37,7 +41,7 @@ describe('DismissalButton', () => {
const propsData = { const propsData = {
isDismissed: true, isDismissed: true,
}; };
wrapper = mount(component, { propsData }); mountComponent({ propsData });
}); });
it('should render the undo dismiss button', () => { it('should render the undo dismiss button', () => {
......
...@@ -21,9 +21,13 @@ describe('dismissal note', () => { ...@@ -21,9 +21,13 @@ describe('dismissal note', () => {
}; };
let wrapper; let wrapper;
const mountComponent = (options, mountFn = shallowMount) => {
wrapper = mountFn(component, { sync: false, attachToDocument: true, ...options });
};
describe('with no attached project or pipeline', () => { describe('with no attached project or pipeline', () => {
beforeEach(() => { beforeEach(() => {
wrapper = shallowMount(component, { mountComponent({
propsData: { feedback }, propsData: { feedback },
}); });
}); });
...@@ -43,7 +47,7 @@ describe('dismissal note', () => { ...@@ -43,7 +47,7 @@ describe('dismissal note', () => {
describe('with an attached project', () => { describe('with an attached project', () => {
beforeEach(() => { beforeEach(() => {
wrapper = shallowMount(component, { mountComponent({
propsData: { feedback, project }, propsData: { feedback, project },
}); });
}); });
...@@ -55,7 +59,7 @@ describe('dismissal note', () => { ...@@ -55,7 +59,7 @@ describe('dismissal note', () => {
describe('with an attached pipeline', () => { describe('with an attached pipeline', () => {
beforeEach(() => { beforeEach(() => {
wrapper = shallowMount(component, { mountComponent({
propsData: { feedback: { ...feedback, pipeline } }, propsData: { feedback: { ...feedback, pipeline } },
}); });
}); });
...@@ -67,7 +71,7 @@ describe('dismissal note', () => { ...@@ -67,7 +71,7 @@ describe('dismissal note', () => {
describe('with an attached pipeline and project', () => { describe('with an attached pipeline and project', () => {
beforeEach(() => { beforeEach(() => {
wrapper = shallowMount(component, { mountComponent({
propsData: { feedback: { ...feedback, pipeline }, project }, propsData: { feedback: { ...feedback, pipeline }, project },
}); });
}); });
...@@ -84,7 +88,7 @@ describe('dismissal note', () => { ...@@ -84,7 +88,7 @@ describe('dismissal note', () => {
}; };
beforeEach(() => { beforeEach(() => {
wrapper = shallowMount(component, { mountComponent({
propsData: { propsData: {
feedback, feedback,
project: unsafeProject, project: unsafeProject,
...@@ -116,7 +120,7 @@ describe('dismissal note', () => { ...@@ -116,7 +120,7 @@ describe('dismissal note', () => {
describe('without confirm deletion buttons', () => { describe('without confirm deletion buttons', () => {
beforeEach(() => { beforeEach(() => {
wrapper = shallowMount(component, { mountComponent({
propsData: { propsData: {
feedback: { feedback: {
...feedback, ...feedback,
...@@ -143,7 +147,8 @@ describe('dismissal note', () => { ...@@ -143,7 +147,8 @@ describe('dismissal note', () => {
describe('with confirm deletion buttons', () => { describe('with confirm deletion buttons', () => {
beforeEach(() => { beforeEach(() => {
wrapper = mount(component, { mountComponent(
{
propsData: { propsData: {
feedback: { feedback: {
...feedback, ...feedback,
...@@ -152,7 +157,9 @@ describe('dismissal note', () => { ...@@ -152,7 +157,9 @@ describe('dismissal note', () => {
project, project,
isShowingDeleteButtons: true, isShowingDeleteButtons: true,
}, },
}); },
mount,
);
commentItem = wrapper.findAll(EventItem).at(1); commentItem = wrapper.findAll(EventItem).at(1);
}); });
......
...@@ -2,9 +2,13 @@ import Component from 'ee/vue_shared/security_reports/components/event_item.vue' ...@@ -2,9 +2,13 @@ import Component from 'ee/vue_shared/security_reports/components/event_item.vue'
import { shallowMount, mount } from '@vue/test-utils'; import { shallowMount, mount } from '@vue/test-utils';
describe('Event Item', () => { describe('Event Item', () => {
describe('initial state', () => {
let wrapper; let wrapper;
const mountComponent = (options, mountFn = shallowMount) => {
wrapper = mountFn(Component, { sync: false, attachToDocument: true, ...options });
};
describe('initial state', () => {
const propsData = { const propsData = {
author: { author: {
name: 'Tanuki', name: 'Tanuki',
...@@ -17,7 +21,7 @@ describe('Event Item', () => { ...@@ -17,7 +21,7 @@ describe('Event Item', () => {
}); });
beforeEach(() => { beforeEach(() => {
wrapper = shallowMount(Component, { propsData }); mountComponent({ propsData });
}); });
it('uses the author name', () => { it('uses the author name', () => {
...@@ -41,8 +45,6 @@ describe('Event Item', () => { ...@@ -41,8 +45,6 @@ describe('Event Item', () => {
}); });
}); });
describe('with action buttons', () => { describe('with action buttons', () => {
let wrapper;
const propsData = { const propsData = {
author: { author: {
name: 'Tanuki', name: 'Tanuki',
...@@ -67,7 +69,7 @@ describe('Event Item', () => { ...@@ -67,7 +69,7 @@ describe('Event Item', () => {
}); });
beforeEach(() => { beforeEach(() => {
wrapper = mount(Component, { propsData }); mountComponent({ propsData }, mount);
}); });
it('renders the action buttons container', () => { it('renders the action buttons container', () => {
......
...@@ -8,13 +8,17 @@ import createState from 'ee/vue_shared/security_reports/store/state'; ...@@ -8,13 +8,17 @@ import createState from 'ee/vue_shared/security_reports/store/state';
describe('Security Reports modal footer', () => { describe('Security Reports modal footer', () => {
let wrapper; let wrapper;
const mountComponent = options => {
wrapper = mount(component, { sync: false, attachToDocument: true, ...options });
};
describe('can only create issue', () => { describe('can only create issue', () => {
beforeEach(() => { beforeEach(() => {
const propsData = { const propsData = {
modal: createState().modal, modal: createState().modal,
canCreateIssue: true, canCreateIssue: true,
}; };
wrapper = mount(component, { propsData }); mountComponent({ propsData });
}); });
it('does not render dismiss button', () => { it('does not render dismiss button', () => {
...@@ -38,7 +42,7 @@ describe('Security Reports modal footer', () => { ...@@ -38,7 +42,7 @@ describe('Security Reports modal footer', () => {
modal: createState().modal, modal: createState().modal,
canCreateMergeRequest: true, canCreateMergeRequest: true,
}; };
wrapper = mount(component, { propsData }); mountComponent({ propsData });
}); });
it('only renders the create merge request button', () => { it('only renders the create merge request button', () => {
...@@ -58,7 +62,7 @@ describe('Security Reports modal footer', () => { ...@@ -58,7 +62,7 @@ describe('Security Reports modal footer', () => {
modal: createState().modal, modal: createState().modal,
canDownloadPatch: true, canDownloadPatch: true,
}; };
wrapper = mount(component, { propsData }); mountComponent({ propsData });
}); });
it('renders the download patch button', () => { it('renders the download patch button', () => {
...@@ -79,7 +83,7 @@ describe('Security Reports modal footer', () => { ...@@ -79,7 +83,7 @@ describe('Security Reports modal footer', () => {
canCreateIssue: true, canCreateIssue: true,
canCreateMergeRequest: true, canCreateMergeRequest: true,
}; };
wrapper = mount(component, { propsData }); mountComponent({ propsData });
}); });
it('renders create merge request and issue button as a split button', () => { it('renders create merge request and issue button as a split button', () => {
...@@ -99,7 +103,7 @@ describe('Security Reports modal footer', () => { ...@@ -99,7 +103,7 @@ describe('Security Reports modal footer', () => {
canCreateMergeRequest: true, canCreateMergeRequest: true,
canDownloadPatch: true, canDownloadPatch: true,
}; };
wrapper = mount(component, { propsData }); mountComponent({ propsData });
}); });
it('renders the split button', () => { it('renders the split button', () => {
...@@ -117,7 +121,7 @@ describe('Security Reports modal footer', () => { ...@@ -117,7 +121,7 @@ describe('Security Reports modal footer', () => {
modal: createState().modal, modal: createState().modal,
canDismissVulnerability: true, canDismissVulnerability: true,
}; };
wrapper = mount(component, { propsData }); mountComponent({ propsData });
}); });
it('should render the dismiss button', () => { it('should render the dismiss button', () => {
......
...@@ -4,9 +4,12 @@ import createState from 'ee/vue_shared/security_reports/store/state'; ...@@ -4,9 +4,12 @@ import createState from 'ee/vue_shared/security_reports/store/state';
import { mount, shallowMount } from '@vue/test-utils'; import { mount, shallowMount } from '@vue/test-utils';
describe('Security Reports modal', () => { describe('Security Reports modal', () => {
const Component = Vue.extend(component);
let wrapper; let wrapper;
const mountComponent = (options, mountFn = shallowMount) => {
wrapper = mountFn(component, { sync: false, attachToDocument: true, ...options });
};
describe('with permissions', () => { describe('with permissions', () => {
describe('with dismissed issue', () => { describe('with dismissed issue', () => {
beforeEach(() => { beforeEach(() => {
...@@ -19,7 +22,7 @@ describe('Security Reports modal', () => { ...@@ -19,7 +22,7 @@ describe('Security Reports modal', () => {
author: { username: 'jsmith', name: 'John Smith' }, author: { username: 'jsmith', name: 'John Smith' },
pipeline: { id: '123', path: '#' }, pipeline: { id: '123', path: '#' },
}; };
wrapper = mount(Component, { propsData }); mountComponent({ propsData }, mount);
}); });
it('renders dismissal author and associated pipeline', () => { it('renders dismissal author and associated pipeline', () => {
...@@ -39,7 +42,7 @@ describe('Security Reports modal', () => { ...@@ -39,7 +42,7 @@ describe('Security Reports modal', () => {
modal: createState().modal, modal: createState().modal,
canDismissVulnerability: true, canDismissVulnerability: true,
}; };
wrapper = mount(Component, { propsData }); mountComponent({ propsData }, mount);
}); });
it('renders the footer', () => { it('renders the footer', () => {
...@@ -57,7 +60,7 @@ describe('Security Reports modal', () => { ...@@ -57,7 +60,7 @@ describe('Security Reports modal', () => {
const summary = 'Upgrade to 123'; const summary = 'Upgrade to 123';
const diff = 'abc123'; const diff = 'abc123';
propsData.modal.vulnerability.remediations = [{ summary, diff }]; propsData.modal.vulnerability.remediations = [{ summary, diff }];
wrapper = mount(Component, { propsData, sync: true }); mountComponent({ propsData }, mount);
}); });
it('renders create merge request and issue button as a split button', () => { it('renders create merge request and issue button as a split button', () => {
...@@ -100,7 +103,7 @@ describe('Security Reports modal', () => { ...@@ -100,7 +103,7 @@ describe('Security Reports modal', () => {
vulnerabilityFeedbackHelpPath: 'feedbacksHelpPath', vulnerabilityFeedbackHelpPath: 'feedbacksHelpPath',
}; };
propsData.modal.title = 'Arbitrary file existence disclosure in Action Pack'; propsData.modal.title = 'Arbitrary file existence disclosure in Action Pack';
wrapper = mount(Component, { propsData }); mountComponent({ propsData }, mount);
}); });
it('renders title', () => { it('renders title', () => {
...@@ -120,7 +123,7 @@ describe('Security Reports modal', () => { ...@@ -120,7 +123,7 @@ describe('Security Reports modal', () => {
const propsData = { const propsData = {
modal: createState().modal, modal: createState().modal,
}; };
wrapper = shallowMount(Component, { propsData }); mountComponent({ propsData });
}); });
it('does not display the footer', () => { it('does not display the footer', () => {
...@@ -138,7 +141,7 @@ describe('Security Reports modal', () => { ...@@ -138,7 +141,7 @@ describe('Security Reports modal', () => {
propsData.modal.vulnerability.issue_feedback = { propsData.modal.vulnerability.issue_feedback = {
issue_url: 'http://issue.url', issue_url: 'http://issue.url',
}; };
wrapper = shallowMount(Component, { propsData }); mountComponent({ propsData });
}); });
it('displays a link to the issue', () => { it('displays a link to the issue', () => {
...@@ -156,7 +159,7 @@ describe('Security Reports modal', () => { ...@@ -156,7 +159,7 @@ describe('Security Reports modal', () => {
propsData.modal.vulnerability.issue_feedback = { propsData.modal.vulnerability.issue_feedback = {
issue_url: null, issue_url: null,
}; };
wrapper = shallowMount(Component, { propsData }); mountComponent({ propsData });
}); });
it('hides the link to the issue', () => { it('hides the link to the issue', () => {
...@@ -176,7 +179,7 @@ describe('Security Reports modal', () => { ...@@ -176,7 +179,7 @@ describe('Security Reports modal', () => {
propsData.modal.vulnerability.merge_request_feedback = { propsData.modal.vulnerability.merge_request_feedback = {
merge_request_path: 'http://mr.url', merge_request_path: 'http://mr.url',
}; };
wrapper = shallowMount(Component, { propsData }); mountComponent({ propsData });
}); });
it('displays a link to the merge request', () => { it('displays a link to the merge request', () => {
...@@ -194,7 +197,7 @@ describe('Security Reports modal', () => { ...@@ -194,7 +197,7 @@ describe('Security Reports modal', () => {
propsData.modal.vulnerability.merge_request_feedback = { propsData.modal.vulnerability.merge_request_feedback = {
merge_request_path: null, merge_request_path: null,
}; };
wrapper = shallowMount(Component, { propsData }); mountComponent({ propsData });
}); });
it('hides the link to the merge request', () => { it('hides the link to the merge request', () => {
...@@ -210,7 +213,7 @@ describe('Security Reports modal', () => { ...@@ -210,7 +213,7 @@ describe('Security Reports modal', () => {
modal: createState().modal, modal: createState().modal,
}; };
propsData.modal.isResolved = true; propsData.modal.isResolved = true;
wrapper = shallowMount(Component, { propsData }); mountComponent({ propsData });
}); });
it('does not display the footer', () => { it('does not display the footer', () => {
...@@ -230,7 +233,7 @@ describe('Security Reports modal', () => { ...@@ -230,7 +233,7 @@ describe('Security Reports modal', () => {
propsData.modal.vulnerability.blob_path = blobPath; propsData.modal.vulnerability.blob_path = blobPath;
propsData.modal.data.namespace.value = namespaceValue; propsData.modal.data.namespace.value = namespaceValue;
propsData.modal.data.file.value = fileValue; propsData.modal.data.file.value = fileValue;
wrapper = mount(Component, { propsData }); mountComponent({ propsData }, mount);
}); });
it('is rendered', () => { it('is rendered', () => {
...@@ -265,7 +268,7 @@ describe('Security Reports modal', () => { ...@@ -265,7 +268,7 @@ describe('Security Reports modal', () => {
const solution = 'Upgrade to XYZ'; const solution = 'Upgrade to XYZ';
propsData.modal.vulnerability.solution = solution; propsData.modal.vulnerability.solution = solution;
wrapper = mount(Component, { propsData }); mountComponent({ propsData }, mount);
const solutionCard = wrapper.find('.js-solution-card'); const solutionCard = wrapper.find('.js-solution-card');
...@@ -280,7 +283,7 @@ describe('Security Reports modal', () => { ...@@ -280,7 +283,7 @@ describe('Security Reports modal', () => {
}; };
const summary = 'Upgrade to 123'; const summary = 'Upgrade to 123';
propsData.modal.vulnerability.remediations = [{ summary }]; propsData.modal.vulnerability.remediations = [{ summary }];
wrapper = mount(Component, { propsData }); mountComponent({ propsData }, mount);
const solutionCard = wrapper.find('.js-solution-card'); const solutionCard = wrapper.find('.js-solution-card');
...@@ -293,7 +296,7 @@ describe('Security Reports modal', () => { ...@@ -293,7 +296,7 @@ describe('Security Reports modal', () => {
const propsData = { const propsData = {
modal: createState().modal, modal: createState().modal,
}; };
wrapper = mount(Component, { propsData }); mountComponent({ propsData }, mount);
const solutionCard = wrapper.find('.js-solution-card'); const solutionCard = wrapper.find('.js-solution-card');
...@@ -325,7 +328,7 @@ describe('Security Reports modal', () => { ...@@ -325,7 +328,7 @@ describe('Security Reports modal', () => {
describe('with a non-dismissed vulnerability', () => { describe('with a non-dismissed vulnerability', () => {
beforeEach(() => { beforeEach(() => {
wrapper = mount(Component, { propsData }); mountComponent({ propsData });
}); });
it('creates an error when an empty comment is submitted', () => { it('creates an error when an empty comment is submitted', () => {
...@@ -349,7 +352,7 @@ describe('Security Reports modal', () => { ...@@ -349,7 +352,7 @@ describe('Security Reports modal', () => {
describe('with a dismissed vulnerability', () => { describe('with a dismissed vulnerability', () => {
beforeEach(() => { beforeEach(() => {
propsData.modal.vulnerability.dismissal_feedback = { author: {} }; propsData.modal.vulnerability.dismissal_feedback = { author: {} };
wrapper = mount(Component, { propsData }); mountComponent({ propsData });
}); });
it('creates an error when an empty comment is submitted', () => { it('creates an error when an empty comment is submitted', () => {
......
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