diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2018-04-26 13:58:03 +0000 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2018-04-26 13:58:03 +0000 |
commit | 25c17102df4b583f322aaa577330e2bda1695d0e (patch) | |
tree | 5e053bcabb4dba6fe6ecb27d07d2484792c38bf9 /spec | |
parent | 12dff60c65c552552850ea95ff6fa6377d238b9e (diff) | |
parent | 9990afb92c28c94e89a1c81c8b2f2c02c04dc86b (diff) | |
download | gitlab-ce-25c17102df4b583f322aaa577330e2bda1695d0e.tar.gz |
Merge branch 'ide-temp-file-folder-fixes' into 'master'
Fixed bugs with IDE new directory
Closes #44838
See merge request gitlab-org/gitlab-ce!18274
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/ide/components/new_dropdown/index_spec.js | 22 | ||||
-rw-r--r-- | spec/javascripts/ide/components/new_dropdown/modal_spec.js | 14 | ||||
-rw-r--r-- | spec/javascripts/ide/stores/actions_spec.js | 50 | ||||
-rw-r--r-- | spec/javascripts/ide/stores/mutations_spec.js | 22 |
4 files changed, 90 insertions, 18 deletions
diff --git a/spec/javascripts/ide/components/new_dropdown/index_spec.js b/spec/javascripts/ide/components/new_dropdown/index_spec.js index e08abe7d849..7b637f37eba 100644 --- a/spec/javascripts/ide/components/new_dropdown/index_spec.js +++ b/spec/javascripts/ide/components/new_dropdown/index_spec.js @@ -32,12 +32,8 @@ describe('new dropdown component', () => { it('renders new file, upload and new directory links', () => { expect(vm.$el.querySelectorAll('a')[0].textContent.trim()).toBe('New file'); - expect(vm.$el.querySelectorAll('a')[1].textContent.trim()).toBe( - 'Upload file', - ); - expect(vm.$el.querySelectorAll('a')[2].textContent.trim()).toBe( - 'New directory', - ); + expect(vm.$el.querySelectorAll('a')[1].textContent.trim()).toBe('Upload file'); + expect(vm.$el.querySelectorAll('a')[2].textContent.trim()).toBe('New directory'); }); describe('createNewItem', () => { @@ -81,4 +77,18 @@ describe('new dropdown component', () => { .catch(done.fail); }); }); + + describe('dropdownOpen', () => { + it('scrolls dropdown into view', done => { + spyOn(vm.$refs.dropdownMenu, 'scrollIntoView'); + + vm.dropdownOpen = true; + + setTimeout(() => { + expect(vm.$refs.dropdownMenu.scrollIntoView).toHaveBeenCalled(); + + done(); + }); + }); + }); }); diff --git a/spec/javascripts/ide/components/new_dropdown/modal_spec.js b/spec/javascripts/ide/components/new_dropdown/modal_spec.js index a6e1e5a0d35..f362ed4db65 100644 --- a/spec/javascripts/ide/components/new_dropdown/modal_spec.js +++ b/spec/javascripts/ide/components/new_dropdown/modal_spec.js @@ -25,25 +25,17 @@ describe('new file modal component', () => { it(`sets modal title as ${type}`, () => { const title = type === 'tree' ? 'directory' : 'file'; - expect(vm.$el.querySelector('.modal-title').textContent.trim()).toBe( - `Create new ${title}`, - ); + expect(vm.$el.querySelector('.modal-title').textContent.trim()).toBe(`Create new ${title}`); }); it(`sets button label as ${type}`, () => { const title = type === 'tree' ? 'directory' : 'file'; - expect(vm.$el.querySelector('.btn-success').textContent.trim()).toBe( - `Create ${title}`, - ); + expect(vm.$el.querySelector('.btn-success').textContent.trim()).toBe(`Create ${title}`); }); it(`sets form label as ${type}`, () => { - const title = type === 'tree' ? 'Directory' : 'File'; - - expect(vm.$el.querySelector('.label-light').textContent.trim()).toBe( - `${title} name`, - ); + expect(vm.$el.querySelector('.label-light').textContent.trim()).toBe('Name'); }); describe('createEntryInStore', () => { diff --git a/spec/javascripts/ide/stores/actions_spec.js b/spec/javascripts/ide/stores/actions_spec.js index b6eadf56f9d..a64af5b941b 100644 --- a/spec/javascripts/ide/stores/actions_spec.js +++ b/spec/javascripts/ide/stores/actions_spec.js @@ -1,4 +1,9 @@ -import actions, { stageAllChanges, unstageAllChanges, toggleFileFinder } from '~/ide/stores/actions'; +import actions, { + stageAllChanges, + unstageAllChanges, + toggleFileFinder, + updateTempFlagForEntry, +} from '~/ide/stores/actions'; import store from '~/ide/stores'; import * as types from '~/ide/stores/mutation_types'; import router from '~/ide/ide_router'; @@ -340,6 +345,49 @@ describe('Multi-file store actions', () => { }); }); + describe('updateTempFlagForEntry', () => { + it('commits UPDATE_TEMP_FLAG', done => { + const f = { + ...file(), + path: 'test', + tempFile: true, + }; + store.state.entries[f.path] = f; + + testAction( + updateTempFlagForEntry, + { file: f, tempFile: false }, + store.state, + [{ type: 'UPDATE_TEMP_FLAG', payload: { path: f.path, tempFile: false } }], + [], + done, + ); + }); + + it('commits UPDATE_TEMP_FLAG and dispatches for parent', done => { + const parent = { + ...file(), + path: 'testing', + }; + const f = { + ...file(), + path: 'test', + parentPath: 'testing', + }; + store.state.entries[parent.path] = parent; + store.state.entries[f.path] = f; + + testAction( + updateTempFlagForEntry, + { file: f, tempFile: false }, + store.state, + [{ type: 'UPDATE_TEMP_FLAG', payload: { path: f.path, tempFile: false } }], + [{ type: 'updateTempFlagForEntry', payload: { file: parent, tempFile: false } }], + done, + ); + }); + }); + describe('toggleFileFinder', () => { it('commits TOGGLE_FILE_FINDER', done => { testAction( diff --git a/spec/javascripts/ide/stores/mutations_spec.js b/spec/javascripts/ide/stores/mutations_spec.js index 575039e755e..997711d1e19 100644 --- a/spec/javascripts/ide/stores/mutations_spec.js +++ b/spec/javascripts/ide/stores/mutations_spec.js @@ -87,6 +87,28 @@ describe('Multi-file store mutations', () => { }); }); + describe('UPDATE_TEMP_FLAG', () => { + beforeEach(() => { + localState.entries.test = { + ...file(), + tempFile: true, + changed: true, + }; + }); + + it('updates tempFile flag', () => { + mutations.UPDATE_TEMP_FLAG(localState, { path: 'test', tempFile: false }); + + expect(localState.entries.test.tempFile).toBe(false); + }); + + it('updates changed flag', () => { + mutations.UPDATE_TEMP_FLAG(localState, { path: 'test', tempFile: false }); + + expect(localState.entries.test.changed).toBe(false); + }); + }); + describe('TOGGLE_FILE_FINDER', () => { it('updates fileFindVisible', () => { mutations.TOGGLE_FILE_FINDER(localState, true); |