diff options
Diffstat (limited to 'spec/frontend/ide')
38 files changed, 93 insertions, 101 deletions
diff --git a/spec/frontend/ide/components/activity_bar_spec.js b/spec/frontend/ide/components/activity_bar_spec.js index 8b3853d4535..762f3c5dad1 100644 --- a/spec/frontend/ide/components/activity_bar_spec.js +++ b/spec/frontend/ide/components/activity_bar_spec.js @@ -1,15 +1,17 @@ import Vue from 'vue'; -import store from '~/ide/stores'; +import { createStore } from '~/ide/stores'; import { leftSidebarViews } from '~/ide/constants'; import ActivityBar from '~/ide/components/activity_bar.vue'; import { createComponentWithStore } from '../../helpers/vue_mount_component_helper'; -import { resetStore } from '../helpers'; describe('IDE activity bar', () => { const Component = Vue.extend(ActivityBar); let vm; + let store; beforeEach(() => { + store = createStore(); + Vue.set(store.state.projects, 'abcproject', { web_url: 'testing', }); @@ -20,8 +22,6 @@ describe('IDE activity bar', () => { afterEach(() => { vm.$destroy(); - - resetStore(vm.$store); }); describe('updateActivityBarView', () => { diff --git a/spec/frontend/ide/components/commit_sidebar/empty_state_spec.js b/spec/frontend/ide/components/commit_sidebar/empty_state_spec.js index 16d0b354a30..dbb43e43c19 100644 --- a/spec/frontend/ide/components/commit_sidebar/empty_state_spec.js +++ b/spec/frontend/ide/components/commit_sidebar/empty_state_spec.js @@ -1,13 +1,15 @@ import Vue from 'vue'; -import store from '~/ide/stores'; +import { createStore } from '~/ide/stores'; import emptyState from '~/ide/components/commit_sidebar/empty_state.vue'; import { createComponentWithStore } from '../../../helpers/vue_mount_component_helper'; -import { resetStore } from '../../helpers'; describe('IDE commit panel empty state', () => { let vm; + let store; beforeEach(() => { + store = createStore(); + const Component = Vue.extend(emptyState); Vue.set(store.state, 'noChangesStateSvgPath', 'no-changes'); @@ -19,8 +21,6 @@ describe('IDE commit panel empty state', () => { afterEach(() => { vm.$destroy(); - - resetStore(vm.$store); }); it('renders no changes text when last commit message is empty', () => { diff --git a/spec/frontend/ide/components/commit_sidebar/form_spec.js b/spec/frontend/ide/components/commit_sidebar/form_spec.js index c62df4a3795..9245cefc183 100644 --- a/spec/frontend/ide/components/commit_sidebar/form_spec.js +++ b/spec/frontend/ide/components/commit_sidebar/form_spec.js @@ -1,19 +1,20 @@ import Vue from 'vue'; import { createComponentWithStore } from 'helpers/vue_mount_component_helper'; import { projectData } from 'jest/ide/mock_data'; -import store from '~/ide/stores'; +import waitForPromises from 'helpers/wait_for_promises'; +import { createStore } from '~/ide/stores'; import CommitForm from '~/ide/components/commit_sidebar/form.vue'; import { leftSidebarViews } from '~/ide/constants'; -import { resetStore } from '../../helpers'; -import waitForPromises from 'helpers/wait_for_promises'; describe('IDE commit form', () => { const Component = Vue.extend(CommitForm); let vm; + let store; const beginCommitButton = () => vm.$el.querySelector('[data-testid="begin-commit-button"]'); beforeEach(() => { + store = createStore(); store.state.changedFiles.push('test'); store.state.currentProjectId = 'abcproject'; store.state.currentBranchId = 'master'; @@ -24,8 +25,6 @@ describe('IDE commit form', () => { afterEach(() => { vm.$destroy(); - - resetStore(vm.$store); }); it('enables begin commit button when there are changes', () => { diff --git a/spec/frontend/ide/components/commit_sidebar/list_collapsed_spec.js b/spec/frontend/ide/components/commit_sidebar/list_collapsed_spec.js index 45372d18965..42e0a20bc7b 100644 --- a/spec/frontend/ide/components/commit_sidebar/list_collapsed_spec.js +++ b/spec/frontend/ide/components/commit_sidebar/list_collapsed_spec.js @@ -1,14 +1,17 @@ import Vue from 'vue'; import { createComponentWithStore } from 'helpers/vue_mount_component_helper'; -import store from '~/ide/stores'; +import { createStore } from '~/ide/stores'; import listCollapsed from '~/ide/components/commit_sidebar/list_collapsed.vue'; import { file } from '../../helpers'; import { removeWhitespace } from '../../../helpers/text_helper'; describe('Multi-file editor commit sidebar list collapsed', () => { let vm; + let store; beforeEach(() => { + store = createStore(); + const Component = Vue.extend(listCollapsed); vm = createComponentWithStore(Component, store, { diff --git a/spec/frontend/ide/components/commit_sidebar/list_spec.js b/spec/frontend/ide/components/commit_sidebar/list_spec.js index 2b5664ffc4e..2107ff96e95 100644 --- a/spec/frontend/ide/components/commit_sidebar/list_spec.js +++ b/spec/frontend/ide/components/commit_sidebar/list_spec.js @@ -1,13 +1,16 @@ import Vue from 'vue'; import { createComponentWithStore } from 'helpers/vue_mount_component_helper'; -import store from '~/ide/stores'; +import { createStore } from '~/ide/stores'; import commitSidebarList from '~/ide/components/commit_sidebar/list.vue'; -import { file, resetStore } from '../../helpers'; +import { file } from '../../helpers'; describe('Multi-file editor commit sidebar list', () => { + let store; let vm; beforeEach(() => { + store = createStore(); + const Component = Vue.extend(commitSidebarList); vm = createComponentWithStore(Component, store, { @@ -26,8 +29,6 @@ describe('Multi-file editor commit sidebar list', () => { afterEach(() => { vm.$destroy(); - - resetStore(vm.$store); }); describe('with a list of files', () => { diff --git a/spec/frontend/ide/components/commit_sidebar/radio_group_spec.js b/spec/frontend/ide/components/commit_sidebar/radio_group_spec.js index ac80ba58056..bf61f4bbe77 100644 --- a/spec/frontend/ide/components/commit_sidebar/radio_group_spec.js +++ b/spec/frontend/ide/components/commit_sidebar/radio_group_spec.js @@ -1,13 +1,15 @@ import Vue from 'vue'; import { createComponentWithStore } from 'helpers/vue_mount_component_helper'; -import { resetStore } from 'jest/ide/helpers'; -import store from '~/ide/stores'; +import { createStore } from '~/ide/stores'; import radioGroup from '~/ide/components/commit_sidebar/radio_group.vue'; describe('IDE commit sidebar radio group', () => { let vm; + let store; beforeEach(done => { + store = createStore(); + const Component = Vue.extend(radioGroup); store.state.commit.commitAction = '2'; @@ -25,8 +27,6 @@ describe('IDE commit sidebar radio group', () => { afterEach(() => { vm.$destroy(); - - resetStore(vm.$store); }); it('uses label if present', () => { diff --git a/spec/frontend/ide/components/commit_sidebar/success_message_spec.js b/spec/frontend/ide/components/commit_sidebar/success_message_spec.js index e1a432b81be..db13c90fbb9 100644 --- a/spec/frontend/ide/components/commit_sidebar/success_message_spec.js +++ b/spec/frontend/ide/components/commit_sidebar/success_message_spec.js @@ -1,13 +1,15 @@ import Vue from 'vue'; -import store from '~/ide/stores'; +import { createStore } from '~/ide/stores'; import successMessage from '~/ide/components/commit_sidebar/success_message.vue'; import { createComponentWithStore } from '../../../helpers/vue_mount_component_helper'; -import { resetStore } from '../../helpers'; describe('IDE commit panel successful commit state', () => { let vm; + let store; beforeEach(() => { + store = createStore(); + const Component = Vue.extend(successMessage); vm = createComponentWithStore(Component, store, { @@ -19,8 +21,6 @@ describe('IDE commit panel successful commit state', () => { afterEach(() => { vm.$destroy(); - - resetStore(vm.$store); }); it('renders last commit message when it exists', done => { diff --git a/spec/frontend/ide/components/file_row_extra_spec.js b/spec/frontend/ide/components/file_row_extra_spec.js index e78bacadebb..4bd27d23f76 100644 --- a/spec/frontend/ide/components/file_row_extra_spec.js +++ b/spec/frontend/ide/components/file_row_extra_spec.js @@ -2,7 +2,7 @@ import Vue from 'vue'; import { createComponentWithStore } from 'helpers/vue_mount_component_helper'; import { createStore } from '~/ide/stores'; import FileRowExtra from '~/ide/components/file_row_extra.vue'; -import { file, resetStore } from '../helpers'; +import { file } from '../helpers'; describe('IDE extra file row component', () => { let Component; @@ -32,7 +32,6 @@ describe('IDE extra file row component', () => { afterEach(() => { vm.$destroy(); - resetStore(vm.$store); stagedFilesCount = 0; unstagedFilesCount = 0; diff --git a/spec/frontend/ide/components/file_templates/bar_spec.js b/spec/frontend/ide/components/file_templates/bar_spec.js index 21dbe18a223..5a33837fb14 100644 --- a/spec/frontend/ide/components/file_templates/bar_spec.js +++ b/spec/frontend/ide/components/file_templates/bar_spec.js @@ -2,7 +2,7 @@ import Vue from 'vue'; import { mountComponentWithStore } from 'helpers/vue_mount_component_helper'; import { createStore } from '~/ide/stores'; import Bar from '~/ide/components/file_templates/bar.vue'; -import { resetStore, file } from '../../helpers'; +import { file } from '../../helpers'; describe('IDE file templates bar component', () => { let Component; @@ -26,7 +26,6 @@ describe('IDE file templates bar component', () => { afterEach(() => { vm.$destroy(); - resetStore(vm.$store); }); describe('template type dropdown', () => { diff --git a/spec/frontend/ide/components/ide_review_spec.js b/spec/frontend/ide/components/ide_review_spec.js index b56957e1f6d..c9ac2ac423d 100644 --- a/spec/frontend/ide/components/ide_review_spec.js +++ b/spec/frontend/ide/components/ide_review_spec.js @@ -3,7 +3,7 @@ import IdeReview from '~/ide/components/ide_review.vue'; import { createStore } from '~/ide/stores'; import { createComponentWithStore } from '../../helpers/vue_mount_component_helper'; import { trimText } from '../../helpers/text_helper'; -import { resetStore, file } from '../helpers'; +import { file } from '../helpers'; import { projectData } from '../mock_data'; describe('IDE review mode', () => { @@ -26,8 +26,6 @@ describe('IDE review mode', () => { afterEach(() => { vm.$destroy(); - - resetStore(vm.$store); }); it('renders list of files', () => { diff --git a/spec/frontend/ide/components/ide_side_bar_spec.js b/spec/frontend/ide/components/ide_side_bar_spec.js index 65cad2e7eb0..67257b40879 100644 --- a/spec/frontend/ide/components/ide_side_bar_spec.js +++ b/spec/frontend/ide/components/ide_side_bar_spec.js @@ -1,15 +1,17 @@ import Vue from 'vue'; import { createComponentWithStore } from 'helpers/vue_mount_component_helper'; -import store from '~/ide/stores'; +import { createStore } from '~/ide/stores'; import ideSidebar from '~/ide/components/ide_side_bar.vue'; import { leftSidebarViews } from '~/ide/constants'; -import { resetStore } from '../helpers'; import { projectData } from '../mock_data'; describe('IdeSidebar', () => { let vm; + let store; beforeEach(() => { + store = createStore(); + const Component = Vue.extend(ideSidebar); store.state.currentProjectId = 'abcproject'; @@ -20,8 +22,6 @@ describe('IdeSidebar', () => { afterEach(() => { vm.$destroy(); - - resetStore(vm.$store); }); it('renders a sidebar', () => { diff --git a/spec/frontend/ide/components/ide_spec.js b/spec/frontend/ide/components/ide_spec.js index efc1d984dec..a7b07a9f0e2 100644 --- a/spec/frontend/ide/components/ide_spec.js +++ b/spec/frontend/ide/components/ide_spec.js @@ -2,7 +2,7 @@ import Vue from 'vue'; import { createComponentWithStore } from 'helpers/vue_mount_component_helper'; import { createStore } from '~/ide/stores'; import ide from '~/ide/components/ide.vue'; -import { file, resetStore } from '../helpers'; +import { file } from '../helpers'; import { projectData } from '../mock_data'; import extendStore from '~/ide/stores/extend'; @@ -41,8 +41,6 @@ describe('ide component, empty repo', () => { afterEach(() => { vm.$destroy(); - - resetStore(vm.$store); }); it('renders "New file" button in empty repo', done => { @@ -63,8 +61,6 @@ describe('ide component, non-empty repo', () => { afterEach(() => { vm.$destroy(); - - resetStore(vm.$store); }); it('shows error message when set', done => { diff --git a/spec/frontend/ide/components/ide_tree_list_spec.js b/spec/frontend/ide/components/ide_tree_list_spec.js index 30f11db3153..4593ef6049b 100644 --- a/spec/frontend/ide/components/ide_tree_list_spec.js +++ b/spec/frontend/ide/components/ide_tree_list_spec.js @@ -1,8 +1,8 @@ import Vue from 'vue'; import IdeTreeList from '~/ide/components/ide_tree_list.vue'; -import store from '~/ide/stores'; +import { createStore } from '~/ide/stores'; import { createComponentWithStore } from '../../helpers/vue_mount_component_helper'; -import { resetStore, file } from '../helpers'; +import { file } from '../helpers'; import { projectData } from '../mock_data'; describe('IDE tree list', () => { @@ -10,6 +10,7 @@ describe('IDE tree list', () => { const normalBranchTree = [file('fileName')]; const emptyBranchTree = []; let vm; + let store; const bootstrapWithTree = (tree = normalBranchTree) => { store.state.currentProjectId = 'abcproject'; @@ -25,10 +26,12 @@ describe('IDE tree list', () => { }); }; + beforeEach(() => { + store = createStore(); + }); + afterEach(() => { vm.$destroy(); - - resetStore(vm.$store); }); describe('normal branch', () => { diff --git a/spec/frontend/ide/components/ide_tree_spec.js b/spec/frontend/ide/components/ide_tree_spec.js index 01f007f09c3..899daa0bf57 100644 --- a/spec/frontend/ide/components/ide_tree_spec.js +++ b/spec/frontend/ide/components/ide_tree_spec.js @@ -1,14 +1,17 @@ import Vue from 'vue'; import IdeTree from '~/ide/components/ide_tree.vue'; -import store from '~/ide/stores'; +import { createStore } from '~/ide/stores'; import { createComponentWithStore } from '../../helpers/vue_mount_component_helper'; -import { resetStore, file } from '../helpers'; +import { file } from '../helpers'; import { projectData } from '../mock_data'; describe('IdeRepoTree', () => { + let store; let vm; beforeEach(() => { + store = createStore(); + const IdeRepoTree = Vue.extend(IdeTree); store.state.currentProjectId = 'abcproject'; @@ -24,8 +27,6 @@ describe('IdeRepoTree', () => { afterEach(() => { vm.$destroy(); - - resetStore(vm.$store); }); it('renders list of files', () => { diff --git a/spec/frontend/ide/components/jobs/detail_spec.js b/spec/frontend/ide/components/jobs/detail_spec.js index 8f3815d5aab..acd30dee718 100644 --- a/spec/frontend/ide/components/jobs/detail_spec.js +++ b/spec/frontend/ide/components/jobs/detail_spec.js @@ -1,9 +1,9 @@ import Vue from 'vue'; +import { TEST_HOST } from 'helpers/test_constants'; import JobDetail from '~/ide/components/jobs/detail.vue'; import { createStore } from '~/ide/stores'; import { createComponentWithStore } from '../../../helpers/vue_mount_component_helper'; import { jobs } from '../../mock_data'; -import { TEST_HOST } from 'helpers/test_constants'; describe('IDE jobs detail view', () => { let vm; diff --git a/spec/frontend/ide/components/new_dropdown/index_spec.js b/spec/frontend/ide/components/new_dropdown/index_spec.js index 00781c16609..c6cebf36de3 100644 --- a/spec/frontend/ide/components/new_dropdown/index_spec.js +++ b/spec/frontend/ide/components/new_dropdown/index_spec.js @@ -1,13 +1,15 @@ import Vue from 'vue'; import { createComponentWithStore } from 'helpers/vue_mount_component_helper'; -import store from '~/ide/stores'; +import { createStore } from '~/ide/stores'; import newDropdown from '~/ide/components/new_dropdown/index.vue'; -import { resetStore } from '../../helpers'; describe('new dropdown component', () => { + let store; let vm; beforeEach(() => { + store = createStore(); + const component = Vue.extend(newDropdown); vm = createComponentWithStore(component, store, { @@ -30,8 +32,6 @@ describe('new dropdown component', () => { afterEach(() => { vm.$destroy(); - - resetStore(vm.$store); }); it('renders new file, upload and new directory links', () => { diff --git a/spec/frontend/ide/components/new_dropdown/modal_spec.js b/spec/frontend/ide/components/new_dropdown/modal_spec.js index da17cc3601e..ea8ba24c9d0 100644 --- a/spec/frontend/ide/components/new_dropdown/modal_spec.js +++ b/spec/frontend/ide/components/new_dropdown/modal_spec.js @@ -2,7 +2,7 @@ import Vue from 'vue'; import { createComponentWithStore } from 'helpers/vue_mount_component_helper'; import { createStore } from '~/ide/stores'; import modal from '~/ide/components/new_dropdown/modal.vue'; -import createFlash from '~/flash'; +import { deprecatedCreateFlash as createFlash } from '~/flash'; jest.mock('~/flash'); diff --git a/spec/frontend/ide/components/panes/collapsible_sidebar_spec.js b/spec/frontend/ide/components/panes/collapsible_sidebar_spec.js index e32abc98aae..bb9ba32a699 100644 --- a/spec/frontend/ide/components/panes/collapsible_sidebar_spec.js +++ b/spec/frontend/ide/components/panes/collapsible_sidebar_spec.js @@ -1,9 +1,9 @@ import { createLocalVue, shallowMount } from '@vue/test-utils'; +import Vuex from 'vuex'; import { createStore } from '~/ide/stores'; import paneModule from '~/ide/stores/modules/pane'; import CollapsibleSidebar from '~/ide/components/panes/collapsible_sidebar.vue'; import IdeSidebarNav from '~/ide/components/ide_sidebar_nav.vue'; -import Vuex from 'vuex'; const localVue = createLocalVue(); localVue.use(Vuex); diff --git a/spec/frontend/ide/components/pipelines/list_spec.js b/spec/frontend/ide/components/pipelines/list_spec.js index 795ded35d20..86cdbafaff9 100644 --- a/spec/frontend/ide/components/pipelines/list_spec.js +++ b/spec/frontend/ide/components/pipelines/list_spec.js @@ -2,11 +2,11 @@ import { shallowMount, createLocalVue } from '@vue/test-utils'; import Vuex from 'vuex'; import { GlLoadingIcon } from '@gitlab/ui'; import { TEST_HOST } from 'helpers/test_constants'; +import { pipelines } from 'jest/ide/mock_data'; import List from '~/ide/components/pipelines/list.vue'; import JobsList from '~/ide/components/jobs/list.vue'; import Tab from '~/vue_shared/components/tabs/tab.vue'; import CiIcon from '~/vue_shared/components/ci_icon.vue'; -import { pipelines } from 'jest/ide/mock_data'; import IDEServices from '~/ide/services'; const localVue = createLocalVue(); diff --git a/spec/frontend/ide/components/preview/navigator_spec.js b/spec/frontend/ide/components/preview/navigator_spec.js index aa15f391e77..ba5ac3bbbea 100644 --- a/spec/frontend/ide/components/preview/navigator_spec.js +++ b/spec/frontend/ide/components/preview/navigator_spec.js @@ -1,8 +1,8 @@ import { shallowMount } from '@vue/test-utils'; import { TEST_HOST } from 'helpers/test_constants'; import { GlLoadingIcon } from '@gitlab/ui'; -import ClientsideNavigator from '~/ide/components/preview/navigator.vue'; import { listen } from 'codesandbox-api'; +import ClientsideNavigator from '~/ide/components/preview/navigator.vue'; jest.mock('codesandbox-api', () => ({ listen: jest.fn().mockReturnValue(jest.fn()), diff --git a/spec/frontend/ide/components/repo_editor_spec.js b/spec/frontend/ide/components/repo_editor_spec.js index a4336b8f2eb..f0ae2ba732b 100644 --- a/spec/frontend/ide/components/repo_editor_spec.js +++ b/spec/frontend/ide/components/repo_editor_spec.js @@ -3,6 +3,8 @@ import Vue from 'vue'; import MockAdapter from 'axios-mock-adapter'; import '~/behaviors/markdown/render_gfm'; import { Range } from 'monaco-editor'; +import waitForPromises from 'helpers/wait_for_promises'; +import waitUsingRealTimer from 'helpers/wait_using_real_timer'; import axios from '~/lib/utils/axios_utils'; import service from '~/ide/services'; import { createStoreOptions } from '~/ide/stores'; @@ -15,10 +17,8 @@ import { viewerTypes, } from '~/ide/constants'; import { createComponentWithStore } from '../../helpers/vue_mount_component_helper'; -import waitForPromises from 'helpers/wait_for_promises'; import { file } from '../helpers'; import { exampleConfigs, exampleFiles } from '../lib/editorconfig/mock_data'; -import waitUsingRealTimer from 'helpers/wait_using_real_timer'; describe('RepoEditor', () => { let vm; diff --git a/spec/frontend/ide/helpers.js b/spec/frontend/ide/helpers.js index a9620d26313..8caa9c2b437 100644 --- a/spec/frontend/ide/helpers.js +++ b/spec/frontend/ide/helpers.js @@ -1,25 +1,5 @@ import * as pathUtils from 'path'; import { decorateData } from '~/ide/stores/utils'; -import state from '~/ide/stores/state'; -import commitState from '~/ide/stores/modules/commit/state'; -import mergeRequestsState from '~/ide/stores/modules/merge_requests/state'; -import pipelinesState from '~/ide/stores/modules/pipelines/state'; -import branchesState from '~/ide/stores/modules/branches/state'; -import fileTemplatesState from '~/ide/stores/modules/file_templates/state'; -import paneState from '~/ide/stores/modules/pane/state'; - -export const resetStore = store => { - const newState = { - ...state(), - commit: commitState(), - mergeRequests: mergeRequestsState(), - pipelines: pipelinesState(), - branches: branchesState(), - fileTemplates: fileTemplatesState(), - rightPane: paneState(), - }; - store.replaceState(newState); -}; export const file = (name = 'name', id = name, type = '', parent = null) => decorateData({ diff --git a/spec/frontend/ide/ide_router_spec.js b/spec/frontend/ide/ide_router_spec.js index b53e2019819..a4fe00883cf 100644 --- a/spec/frontend/ide/ide_router_spec.js +++ b/spec/frontend/ide/ide_router_spec.js @@ -1,6 +1,6 @@ +import waitForPromises from 'helpers/wait_for_promises'; import { createRouter } from '~/ide/ide_router'; import { createStore } from '~/ide/stores'; -import waitForPromises from 'helpers/wait_for_promises'; describe('IDE router', () => { const PROJECT_NAMESPACE = 'my-group/sub-group'; diff --git a/spec/frontend/ide/lib/decorations/controller_spec.js b/spec/frontend/ide/lib/decorations/controller_spec.js index 4556fc9d646..e9b7faaadfe 100644 --- a/spec/frontend/ide/lib/decorations/controller_spec.js +++ b/spec/frontend/ide/lib/decorations/controller_spec.js @@ -2,14 +2,17 @@ import Editor from '~/ide/lib/editor'; import DecorationsController from '~/ide/lib/decorations/controller'; import Model from '~/ide/lib/common/model'; import { file } from '../../helpers'; +import { createStore } from '~/ide/stores'; describe('Multi-file editor library decorations controller', () => { let editorInstance; let controller; let model; + let store; beforeEach(() => { - editorInstance = Editor.create(); + store = createStore(); + editorInstance = Editor.create(store); editorInstance.createInstance(document.createElement('div')); controller = new DecorationsController(editorInstance); diff --git a/spec/frontend/ide/lib/diff/controller_spec.js b/spec/frontend/ide/lib/diff/controller_spec.js index 0b33a4c6ad6..8ee6388a760 100644 --- a/spec/frontend/ide/lib/diff/controller_spec.js +++ b/spec/frontend/ide/lib/diff/controller_spec.js @@ -4,6 +4,7 @@ import ModelManager from '~/ide/lib/common/model_manager'; import DecorationsController from '~/ide/lib/decorations/controller'; import DirtyDiffController, { getDiffChangeType, getDecorator } from '~/ide/lib/diff/controller'; import { computeDiff } from '~/ide/lib/diff/diff'; +import { createStore } from '~/ide/stores'; import { file } from '../../helpers'; describe('Multi-file editor library dirty diff controller', () => { @@ -12,9 +13,12 @@ describe('Multi-file editor library dirty diff controller', () => { let modelManager; let decorationsController; let model; + let store; beforeEach(() => { - editorInstance = Editor.create(); + store = createStore(); + + editorInstance = Editor.create(store); editorInstance.createInstance(document.createElement('div')); modelManager = new ModelManager(); diff --git a/spec/frontend/ide/lib/editor_spec.js b/spec/frontend/ide/lib/editor_spec.js index 5f28309422d..529f80e6f6f 100644 --- a/spec/frontend/ide/lib/editor_spec.js +++ b/spec/frontend/ide/lib/editor_spec.js @@ -5,6 +5,7 @@ import { Selection, } from 'monaco-editor'; import Editor from '~/ide/lib/editor'; +import { createStore } from '~/ide/stores'; import { defaultEditorOptions } from '~/ide/lib/editor_options'; import { file } from '../helpers'; @@ -12,6 +13,7 @@ describe('Multi-file editor library', () => { let instance; let el; let holder; + let store; const setNodeOffsetWidth = val => { Object.defineProperty(instance.instance.getDomNode(), 'offsetWidth', { @@ -22,13 +24,14 @@ describe('Multi-file editor library', () => { }; beforeEach(() => { + store = createStore(); el = document.createElement('div'); holder = document.createElement('div'); el.appendChild(holder); document.body.appendChild(el); - instance = Editor.create(); + instance = Editor.create(store); }); afterEach(() => { @@ -44,7 +47,7 @@ describe('Multi-file editor library', () => { }); it('creates instance returns cached instance', () => { - expect(Editor.create()).toEqual(instance); + expect(Editor.create(store)).toEqual(instance); }); describe('createInstance', () => { diff --git a/spec/frontend/ide/lib/languages/vue_spec.js b/spec/frontend/ide/lib/languages/vue_spec.js index 3d8784c1436..ba5c31bb101 100644 --- a/spec/frontend/ide/lib/languages/vue_spec.js +++ b/spec/frontend/ide/lib/languages/vue_spec.js @@ -9,7 +9,7 @@ describe('tokenization for .vue files', () => { registerLanguages(vue); }); - test.each([ + it.each([ [ '<div v-if="something">content</div>', [ diff --git a/spec/frontend/ide/stores/actions/merge_request_spec.js b/spec/frontend/ide/stores/actions/merge_request_spec.js index e5c4f346459..62971b9cad6 100644 --- a/spec/frontend/ide/stores/actions/merge_request_spec.js +++ b/spec/frontend/ide/stores/actions/merge_request_spec.js @@ -1,7 +1,7 @@ import MockAdapter from 'axios-mock-adapter'; import axios from '~/lib/utils/axios_utils'; -import store from '~/ide/stores'; -import createFlash from '~/flash'; +import { createStore } from '~/ide/stores'; +import { deprecatedCreateFlash as createFlash } from '~/flash'; import { getMergeRequestData, getMergeRequestChanges, @@ -10,7 +10,6 @@ import { } from '~/ide/stores/actions/merge_request'; import service from '~/ide/services'; import { leftSidebarViews, PERMISSION_READ_MR } from '~/ide/constants'; -import { resetStore } from '../../helpers'; const TEST_PROJECT = 'abcproject'; const TEST_PROJECT_ID = 17; @@ -18,9 +17,12 @@ const TEST_PROJECT_ID = 17; jest.mock('~/flash'); describe('IDE store merge request actions', () => { + let store; let mock; beforeEach(() => { + store = createStore(); + mock = new MockAdapter(axios); store.state.projects[TEST_PROJECT] = { @@ -34,7 +36,6 @@ describe('IDE store merge request actions', () => { afterEach(() => { mock.restore(); - resetStore(store); }); describe('getMergeRequestsForBranch', () => { diff --git a/spec/frontend/ide/stores/actions/project_spec.js b/spec/frontend/ide/stores/actions/project_spec.js index 64024c12903..ca3687307a9 100644 --- a/spec/frontend/ide/stores/actions/project_spec.js +++ b/spec/frontend/ide/stores/actions/project_spec.js @@ -1,4 +1,6 @@ import MockAdapter from 'axios-mock-adapter'; +import testAction from 'helpers/vuex_action_helper'; +import { useMockLocationHelper } from 'helpers/mock_window_location_helper'; import axios from '~/lib/utils/axios_utils'; import { createStore } from '~/ide/stores'; import { @@ -12,8 +14,6 @@ import { } from '~/ide/stores/actions'; import service from '~/ide/services'; import api from '~/api'; -import testAction from 'helpers/vuex_action_helper'; -import { useMockLocationHelper } from 'helpers/mock_window_location_helper'; const TEST_PROJECT_ID = 'abc/def'; diff --git a/spec/frontend/ide/stores/actions/tree_spec.js b/spec/frontend/ide/stores/actions/tree_spec.js index c20941843c4..0eabd982d57 100644 --- a/spec/frontend/ide/stores/actions/tree_spec.js +++ b/spec/frontend/ide/stores/actions/tree_spec.js @@ -1,5 +1,6 @@ import MockAdapter from 'axios-mock-adapter'; import testAction from 'helpers/vuex_action_helper'; +import { TEST_HOST } from 'jest/helpers/test_constants'; import { showTreeEntry, getFiles, setDirectoryData } from '~/ide/stores/actions/tree'; import * as types from '~/ide/stores/mutation_types'; import axios from '~/lib/utils/axios_utils'; @@ -7,7 +8,6 @@ import { createStore } from '~/ide/stores'; import service from '~/ide/services'; import { createRouter } from '~/ide/ide_router'; import { file, createEntriesFromPaths } from '../../helpers'; -import { TEST_HOST } from 'jest/helpers/test_constants'; describe('Multi-file store tree actions', () => { let projectTree; diff --git a/spec/frontend/ide/stores/modules/file_templates/getters_spec.js b/spec/frontend/ide/stores/modules/file_templates/getters_spec.js index 5855496a330..c9676b23fa1 100644 --- a/spec/frontend/ide/stores/modules/file_templates/getters_spec.js +++ b/spec/frontend/ide/stores/modules/file_templates/getters_spec.js @@ -5,7 +5,7 @@ import * as getters from '~/ide/stores/modules/file_templates/getters'; describe('IDE file templates getters', () => { describe('templateTypes', () => { it('returns list of template types', () => { - expect(getters.templateTypes().length).toBe(4); + expect(getters.templateTypes().length).toBe(5); }); }); diff --git a/spec/frontend/ide/stores/modules/router/actions_spec.js b/spec/frontend/ide/stores/modules/router/actions_spec.js index 4795eae2b79..1458a43da57 100644 --- a/spec/frontend/ide/stores/modules/router/actions_spec.js +++ b/spec/frontend/ide/stores/modules/router/actions_spec.js @@ -1,6 +1,6 @@ +import testAction from 'helpers/vuex_action_helper'; import * as actions from '~/ide/stores/modules/router/actions'; import * as types from '~/ide/stores/modules/router/mutation_types'; -import testAction from 'helpers/vuex_action_helper'; const TEST_PATH = 'test/path/abc'; diff --git a/spec/frontend/ide/stores/modules/terminal/actions/session_controls_spec.js b/spec/frontend/ide/stores/modules/terminal/actions/session_controls_spec.js index 4bc937b4784..d0ac2af3ffd 100644 --- a/spec/frontend/ide/stores/modules/terminal/actions/session_controls_spec.js +++ b/spec/frontend/ide/stores/modules/terminal/actions/session_controls_spec.js @@ -6,7 +6,7 @@ import * as mutationTypes from '~/ide/stores/modules/terminal/mutation_types'; import * as actions from '~/ide/stores/modules/terminal/actions/session_controls'; import httpStatus from '~/lib/utils/http_status'; import axios from '~/lib/utils/axios_utils'; -import createFlash from '~/flash'; +import { deprecatedCreateFlash as createFlash } from '~/flash'; jest.mock('~/flash'); diff --git a/spec/frontend/ide/stores/modules/terminal/actions/session_status_spec.js b/spec/frontend/ide/stores/modules/terminal/actions/session_status_spec.js index 7909f828124..e25746e1dd1 100644 --- a/spec/frontend/ide/stores/modules/terminal/actions/session_status_spec.js +++ b/spec/frontend/ide/stores/modules/terminal/actions/session_status_spec.js @@ -5,7 +5,7 @@ import * as messages from '~/ide/stores/modules/terminal/messages'; import * as mutationTypes from '~/ide/stores/modules/terminal/mutation_types'; import * as actions from '~/ide/stores/modules/terminal/actions/session_status'; import axios from '~/lib/utils/axios_utils'; -import createFlash from '~/flash'; +import { deprecatedCreateFlash as createFlash } from '~/flash'; jest.mock('~/flash'); diff --git a/spec/frontend/ide/stores/modules/terminal/messages_spec.js b/spec/frontend/ide/stores/modules/terminal/messages_spec.js index 966158999da..1bb92a9dfa5 100644 --- a/spec/frontend/ide/stores/modules/terminal/messages_spec.js +++ b/spec/frontend/ide/stores/modules/terminal/messages_spec.js @@ -15,6 +15,8 @@ describe('IDE store terminal messages', () => { sprintf( messages.ERROR_CONFIG, { + codeStart: `<code>`, + codeEnd: `</code>`, helpStart: `<a href="${escape(TEST_HELP_URL)}" target="_blank">`, helpEnd: '</a>', }, diff --git a/spec/frontend/ide/stores/modules/terminal_sync/actions_spec.js b/spec/frontend/ide/stores/modules/terminal_sync/actions_spec.js index ac976300ed0..3fa57bde415 100644 --- a/spec/frontend/ide/stores/modules/terminal_sync/actions_spec.js +++ b/spec/frontend/ide/stores/modules/terminal_sync/actions_spec.js @@ -1,7 +1,7 @@ +import testAction from 'helpers/vuex_action_helper'; import * as actions from '~/ide/stores/modules/terminal_sync/actions'; import mirror, { canConnect, SERVICE_NAME } from '~/ide/lib/mirror'; import * as types from '~/ide/stores/modules/terminal_sync/mutation_types'; -import testAction from 'helpers/vuex_action_helper'; jest.mock('~/ide/lib/mirror'); diff --git a/spec/frontend/ide/sync_router_and_store_spec.js b/spec/frontend/ide/sync_router_and_store_spec.js index c4ce92b99cc..ccf6e200806 100644 --- a/spec/frontend/ide/sync_router_and_store_spec.js +++ b/spec/frontend/ide/sync_router_and_store_spec.js @@ -1,7 +1,7 @@ import VueRouter from 'vue-router'; +import waitForPromises from 'helpers/wait_for_promises'; import { createStore } from '~/ide/stores'; import { syncRouterAndStore } from '~/ide/sync_router_and_store'; -import waitForPromises from 'helpers/wait_for_promises'; const TEST_ROUTE = '/test/lorem/ipsum'; diff --git a/spec/frontend/ide/utils_spec.js b/spec/frontend/ide/utils_spec.js index b6de576a0a4..e7ef0de45a0 100644 --- a/spec/frontend/ide/utils_spec.js +++ b/spec/frontend/ide/utils_spec.js @@ -1,3 +1,4 @@ +import { languages } from 'monaco-editor'; import { isTextFile, registerLanguages, @@ -9,7 +10,6 @@ import { getPathParent, readFileAsDataURL, } from '~/ide/utils'; -import { languages } from 'monaco-editor'; describe('WebIDE utils', () => { describe('isTextFile', () => { |