diff options
5 files changed, 22 insertions, 12 deletions
diff --git a/app/assets/javascripts/import_projects/index.js b/app/assets/javascripts/import_projects/index.js index 5c77484aee1..2d99d716609 100644 --- a/app/assets/javascripts/import_projects/index.js +++ b/app/assets/javascripts/import_projects/index.js @@ -3,7 +3,7 @@ import { mapActions } from 'vuex'; import Translate from '../vue_shared/translate'; import ImportProjectsTable from './components/import_projects_table.vue'; import { parseBoolean } from '../lib/utils/common_utils'; -import store from './store'; +import createStore from './store'; Vue.use(Translate); @@ -20,6 +20,7 @@ export default function mountImportProjectsTable(mountElement) { ciCdOnly, } = mountElement.dataset; + const store = createStore(); return new Vue({ el: mountElement, store, diff --git a/app/assets/javascripts/import_projects/store/index.js b/app/assets/javascripts/import_projects/store/index.js index 6ac9bfd8189..f666e2ebf33 100644 --- a/app/assets/javascripts/import_projects/store/index.js +++ b/app/assets/javascripts/import_projects/store/index.js @@ -7,9 +7,10 @@ import mutations from './mutations'; Vue.use(Vuex); -export default new Vuex.Store({ - state: state(), - actions, - mutations, - getters, -}); +export default () => + new Vuex.Store({ + state: state(), + actions, + mutations, + getters, + }); diff --git a/spec/javascripts/import_projects/components/import_projects_table_spec.js b/spec/javascripts/import_projects/components/import_projects_table_spec.js index a1ff84ce259..ab8642bf0dd 100644 --- a/spec/javascripts/import_projects/components/import_projects_table_spec.js +++ b/spec/javascripts/import_projects/components/import_projects_table_spec.js @@ -1,7 +1,7 @@ import Vue from 'vue'; import MockAdapter from 'axios-mock-adapter'; import axios from '~/lib/utils/axios_utils'; -import store from '~/import_projects/store'; +import createStore from '~/import_projects/store'; import importProjectsTable from '~/import_projects/components/import_projects_table.vue'; import STATUS_MAP from '~/import_projects/constants'; import setTimeoutPromise from '../../helpers/set_timeout_promise_helper'; @@ -9,6 +9,7 @@ import setTimeoutPromise from '../../helpers/set_timeout_promise_helper'; describe('ImportProjectsTable', () => { let vm; let mock; + let store; const reposPath = '/repos-path'; const jobsPath = '/jobs-path'; const providerTitle = 'THE PROVIDER'; @@ -31,12 +32,13 @@ describe('ImportProjectsTable', () => { }, }).$mount(); - component.$store.dispatch('stopJobsPolling'); + store.dispatch('stopJobsPolling'); return component; } beforeEach(() => { + store = createStore(); store.dispatch('setInitialData', { reposPath }); mock = new MockAdapter(axios); }); @@ -167,7 +169,7 @@ describe('ImportProjectsTable', () => { expect(vm.$el.querySelector(`.ic-status_${statusObject.icon}`)).not.toBeNull(); mock.onGet(jobsPath).replyOnce(200, updatedProjects); - return vm.$store.dispatch('restartJobsPolling'); + return store.dispatch('restartJobsPolling'); }) .then(() => setTimeoutPromise()) .then(() => { diff --git a/spec/javascripts/import_projects/components/imported_project_table_row_spec.js b/spec/javascripts/import_projects/components/imported_project_table_row_spec.js index 8af3b5954a9..7dac7e9ccc1 100644 --- a/spec/javascripts/import_projects/components/imported_project_table_row_spec.js +++ b/spec/javascripts/import_projects/components/imported_project_table_row_spec.js @@ -1,5 +1,5 @@ import Vue from 'vue'; -import store from '~/import_projects/store'; +import createStore from '~/import_projects/store'; import importedProjectTableRow from '~/import_projects/components/imported_project_table_row.vue'; import STATUS_MAP from '~/import_projects/constants'; @@ -16,6 +16,7 @@ describe('ImportedProjectTableRow', () => { function createComponent() { const ImportedProjectTableRow = Vue.extend(importedProjectTableRow); + const store = createStore(); return new ImportedProjectTableRow({ store, propsData: { diff --git a/spec/javascripts/import_projects/components/provider_repo_table_row_spec.js b/spec/javascripts/import_projects/components/provider_repo_table_row_spec.js index 69377f8d685..4d2bacd2ad0 100644 --- a/spec/javascripts/import_projects/components/provider_repo_table_row_spec.js +++ b/spec/javascripts/import_projects/components/provider_repo_table_row_spec.js @@ -1,12 +1,13 @@ import Vue from 'vue'; import MockAdapter from 'axios-mock-adapter'; import axios from '~/lib/utils/axios_utils'; -import store from '~/import_projects/store'; +import createStore from '~/import_projects/store'; import providerRepoTableRow from '~/import_projects/components/provider_repo_table_row.vue'; import STATUS_MAP, { STATUSES } from '~/import_projects/constants'; import setTimeoutPromise from '../../helpers/set_timeout_promise_helper'; describe('ProviderRepoTableRow', () => { + let store; let vm; const repo = { id: 10, @@ -28,6 +29,10 @@ describe('ProviderRepoTableRow', () => { }).$mount(); } + beforeEach(() => { + store = createStore(); + }); + afterEach(() => { vm.$destroy(); }); |