Commit d9d5bdf9 authored by Filipa Lacerda's avatar Filipa Lacerda

Use a factory function in the security apps store

parent 1189ecfc
...@@ -9,7 +9,7 @@ import eventHub from './event_hub'; ...@@ -9,7 +9,7 @@ import eventHub from './event_hub';
import SecurityReportApp from 'ee/vue_shared/security_reports/split_security_reports_app.vue'; // eslint-disable-line import/first import SecurityReportApp from 'ee/vue_shared/security_reports/split_security_reports_app.vue'; // eslint-disable-line import/first
import SastSummaryWidget from 'ee/pipelines/components/security_reports/report_summary_widget.vue'; // eslint-disable-line import/first import SastSummaryWidget from 'ee/pipelines/components/security_reports/report_summary_widget.vue'; // eslint-disable-line import/first
import store from 'ee/vue_shared/security_reports/store'; // eslint-disable-line import/first import createStore from 'ee/vue_shared/security_reports/store'; // eslint-disable-line import/first
Vue.use(Translate); Vue.use(Translate);
...@@ -116,6 +116,8 @@ export default () => { ...@@ -116,6 +116,8 @@ export default () => {
const vulnerabilityFeedbackPath = datasetOptions.vulnerabilityFeedbackPath; const vulnerabilityFeedbackPath = datasetOptions.vulnerabilityFeedbackPath;
const vulnerabilityFeedbackHelpPath = datasetOptions.vulnerabilityFeedbackHelpPath; const vulnerabilityFeedbackHelpPath = datasetOptions.vulnerabilityFeedbackHelpPath;
const pipelineId = parseInt(datasetOptions.pipelineId, 10); const pipelineId = parseInt(datasetOptions.pipelineId, 10);
const store = createStore();
// Widget summary // Widget summary
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new Vue({ new Vue({
......
<script> <script>
import { mapActions, mapState, mapGetters } from 'vuex'; import { mapActions, mapState, mapGetters } from 'vuex';
import { SAST, DAST, SAST_CONTAINER } from './store/constants'; import { SAST, DAST, SAST_CONTAINER } from './store/constants';
import store from './store'; import createStore from './store';
import ReportSection from './components/report_section.vue'; import ReportSection from './components/report_section.vue';
import SummaryRow from './components/summary_row.vue'; import SummaryRow from './components/summary_row.vue';
import IssuesList from './components/issues_list.vue'; import IssuesList from './components/issues_list.vue';
...@@ -9,7 +9,7 @@ import IssueModal from './components/modal.vue'; ...@@ -9,7 +9,7 @@ import IssueModal from './components/modal.vue';
import securityReportsMixin from './mixins/security_report_mixin'; import securityReportsMixin from './mixins/security_report_mixin';
export default { export default {
store, store: createStore(),
components: { components: {
ReportSection, ReportSection,
SummaryRow, SummaryRow,
......
...@@ -3,14 +3,12 @@ import { mapActions, mapState } from 'vuex'; ...@@ -3,14 +3,12 @@ import { mapActions, mapState } from 'vuex';
import { s__, sprintf, n__ } from '~/locale'; import { s__, sprintf, n__ } from '~/locale';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { SAST } from './store/constants'; import { SAST } from './store/constants';
import store from './store';
import ReportSection from './components/report_section.vue'; import ReportSection from './components/report_section.vue';
import IssueModal from './components/modal.vue'; import IssueModal from './components/modal.vue';
import mixin from './mixins/security_report_mixin'; import mixin from './mixins/security_report_mixin';
import reportsMixin from './mixins/reports_mixin'; import reportsMixin from './mixins/reports_mixin';
export default { export default {
store,
components: { components: {
ReportSection, ReportSection,
IssueModal, IssueModal,
......
...@@ -7,11 +7,9 @@ import state from './state'; ...@@ -7,11 +7,9 @@ import state from './state';
Vue.use(Vuex); Vue.use(Vuex);
const store = new Vuex.Store({ export default () => new Vuex.Store({
actions, actions,
getters, getters,
mutations, mutations,
state: state(), state: state(),
}); });
export default store;
import Vue from 'vue'; import Vue from 'vue';
import component from 'ee/vue_shared/security_reports/components/modal.vue'; import component from 'ee/vue_shared/security_reports/components/modal.vue';
import store from 'ee/vue_shared/security_reports/store'; import createStore from 'ee/vue_shared/security_reports/store';
import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper'; import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper';
describe('Security Reports modal', () => { describe('Security Reports modal', () => {
const Component = Vue.extend(component); const Component = Vue.extend(component);
let vm; let vm;
const store = createStore();
beforeEach(() => { beforeEach(() => {
store.dispatch('setVulnerabilityFeedbackPath', 'path'); store.dispatch('setVulnerabilityFeedbackPath', 'path');
......
...@@ -2,9 +2,9 @@ import Vue from 'vue'; ...@@ -2,9 +2,9 @@ import Vue from 'vue';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import component from 'ee/vue_shared/security_reports/split_security_reports_app.vue'; import component from 'ee/vue_shared/security_reports/split_security_reports_app.vue';
import createStore from 'ee/vue_shared/security_reports/store';
import state from 'ee/vue_shared/security_reports/store/state'; import state from 'ee/vue_shared/security_reports/store/state';
import { mountComponentWithStore } from '../../helpers/vue_mount_component_helper';
import mountComponent from '../../helpers/vue_mount_component_helper';
import { sastIssues } from './mock_data'; import { sastIssues } from './mock_data';
describe('Slipt security reports app', () => { describe('Slipt security reports app', () => {
...@@ -36,16 +36,19 @@ describe('Slipt security reports app', () => { ...@@ -36,16 +36,19 @@ describe('Slipt security reports app', () => {
mock.onGet('dss_head.json').reply(200, sastIssues); mock.onGet('dss_head.json').reply(200, sastIssues);
mock.onGet('vulnerability_feedback_path.json').reply(200, []); mock.onGet('vulnerability_feedback_path.json').reply(200, []);
vm = mountComponent(Component, { vm = mountComponentWithStore(Component, {
headBlobPath: 'path', store: createStore(),
baseBlobPath: 'path', props: {
sastHeadPath: 'sast_head.json', headBlobPath: 'path',
dependencyScanningHeadPath: 'dss_head.json', baseBlobPath: 'path',
sastHelpPath: 'path', sastHeadPath: 'sast_head.json',
dependencyScanningHelpPath: 'path', dependencyScanningHeadPath: 'dss_head.json',
vulnerabilityFeedbackPath: 'vulnerability_feedback_path.json', sastHelpPath: 'path',
vulnerabilityFeedbackHelpPath: 'path', dependencyScanningHelpPath: 'path',
pipelineId: 123, vulnerabilityFeedbackPath: 'vulnerability_feedback_path.json',
vulnerabilityFeedbackHelpPath: 'path',
pipelineId: 123,
},
}); });
}); });
...@@ -63,16 +66,19 @@ describe('Slipt security reports app', () => { ...@@ -63,16 +66,19 @@ describe('Slipt security reports app', () => {
mock.onGet('dss_head.json').reply(200, sastIssues); mock.onGet('dss_head.json').reply(200, sastIssues);
mock.onGet('vulnerability_feedback_path.json').reply(200, []); mock.onGet('vulnerability_feedback_path.json').reply(200, []);
vm = mountComponent(Component, { vm = mountComponentWithStore(Component, {
headBlobPath: 'path', store: createStore(),
baseBlobPath: 'path', props: {
sastHeadPath: 'sast_head.json', headBlobPath: 'path',
dependencyScanningHeadPath: 'dss_head.json', baseBlobPath: 'path',
sastHelpPath: 'path', sastHeadPath: 'sast_head.json',
dependencyScanningHelpPath: 'path', dependencyScanningHeadPath: 'dss_head.json',
vulnerabilityFeedbackPath: 'vulnerability_feedback_path.json', sastHelpPath: 'path',
vulnerabilityFeedbackHelpPath: 'path', dependencyScanningHelpPath: 'path',
pipelineId: 123, vulnerabilityFeedbackPath: 'vulnerability_feedback_path.json',
vulnerabilityFeedbackHelpPath: 'path',
pipelineId: 123,
},
}); });
}); });
...@@ -96,16 +102,19 @@ describe('Slipt security reports app', () => { ...@@ -96,16 +102,19 @@ describe('Slipt security reports app', () => {
mock.onGet('dss_head.json').reply(500); mock.onGet('dss_head.json').reply(500);
mock.onGet('vulnerability_feedback_path.json').reply(500, []); mock.onGet('vulnerability_feedback_path.json').reply(500, []);
vm = mountComponent(Component, { vm = mountComponentWithStore(Component, {
headBlobPath: 'path', store: createStore(),
baseBlobPath: 'path', props: {
sastHeadPath: 'sast_head.json', headBlobPath: 'path',
dependencyScanningHeadPath: 'dss_head.json', baseBlobPath: 'path',
sastHelpPath: 'path', sastHeadPath: 'sast_head.json',
dependencyScanningHelpPath: 'path', dependencyScanningHeadPath: 'dss_head.json',
vulnerabilityFeedbackPath: 'vulnerability_feedback_path.json', sastHelpPath: 'path',
vulnerabilityFeedbackHelpPath: 'path', dependencyScanningHelpPath: 'path',
pipelineId: 123, vulnerabilityFeedbackPath: 'vulnerability_feedback_path.json',
vulnerabilityFeedbackHelpPath: 'path',
pipelineId: 123,
},
}); });
}); });
......
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