From be45d454046b7f58c2b586923f5819b9bec95aa5 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 10 Apr 2018 11:10:16 +0100 Subject: Fixed bugs with IDE new directory Closes #44838 --- spec/javascripts/ide/stores/actions_spec.js | 49 +++++++++++++++++++++++++-- spec/javascripts/ide/stores/mutations_spec.js | 22 ++++++++++++ 2 files changed, 68 insertions(+), 3 deletions(-) (limited to 'spec') diff --git a/spec/javascripts/ide/stores/actions_spec.js b/spec/javascripts/ide/stores/actions_spec.js index cec572f4507..dd79856846d 100644 --- a/spec/javascripts/ide/stores/actions_spec.js +++ b/spec/javascripts/ide/stores/actions_spec.js @@ -1,7 +1,9 @@ import * as urlUtils from '~/lib/utils/url_utility'; +import * as actions from '~/ide/stores/actions'; import store from '~/ide/stores'; import router from '~/ide/ide_router'; import { resetStore, file } from '../helpers'; +import testAction from '../../helpers/vuex_action_helper'; describe('Multi-file store actions', () => { beforeEach(() => { @@ -191,9 +193,7 @@ describe('Multi-file store actions', () => { }) .then(f => { expect(f.tempFile).toBeTruthy(); - expect(store.state.trees['abcproject/mybranch'].tree.length).toBe( - 1, - ); + expect(store.state.trees['abcproject/mybranch'].tree.length).toBe(1); done(); }) @@ -303,4 +303,47 @@ describe('Multi-file store actions', () => { .catch(done.fail); }); }); + + describe('updateTempFlagForEntry', () => { + it('commits UPDATE_TEMP_FLAG', done => { + const f = { + ...file(), + path: 'test', + tempFile: true, + }; + store.state.entries[f.path] = f; + + testAction( + actions.updateTempFlagForEntry, + { entry: 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( + actions.updateTempFlagForEntry, + { entry: f, tempFile: false }, + store.state, + [{ type: 'UPDATE_TEMP_FLAG', payload: { path: f.path, tempFile: false } }], + [{ type: 'updateTempFlagForEntry', payload: { entry: parent, tempFile: false } }], + done, + ); + }); + }); }); diff --git a/spec/javascripts/ide/stores/mutations_spec.js b/spec/javascripts/ide/stores/mutations_spec.js index 38162a470ad..94051af7515 100644 --- a/spec/javascripts/ide/stores/mutations_spec.js +++ b/spec/javascripts/ide/stores/mutations_spec.js @@ -76,4 +76,26 @@ describe('Multi-file store mutations', () => { expect(localState.viewer).toBe('diff'); }); }); + + 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); + }); + }); }); -- cgit v1.2.3 From 6d1467de8697a08aa51745043ac4a0b967ad3d24 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 10 Apr 2018 11:54:07 +0100 Subject: fixed modal_spec --- spec/javascripts/ide/components/new_dropdown/modal_spec.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'spec') 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', () => { -- cgit v1.2.3 From 356a37cf50a3a164dd6004ed06f310895539105a Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Thu, 19 Apr 2018 09:01:27 +0100 Subject: added spec to new file dropdown --- .../ide/components/new_dropdown/index_spec.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'spec') 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(); + }); + }); + }); }); -- cgit v1.2.3 From 8e0d073b369ecabe7dabc75bda76b795b2d28931 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Thu, 19 Apr 2018 14:50:52 +0100 Subject: fixed failing commit actions spec --- spec/javascripts/ide/stores/actions_spec.js | 1 - 1 file changed, 1 deletion(-) (limited to 'spec') diff --git a/spec/javascripts/ide/stores/actions_spec.js b/spec/javascripts/ide/stores/actions_spec.js index 707cd9f9a53..d8ebd1019ed 100644 --- a/spec/javascripts/ide/stores/actions_spec.js +++ b/spec/javascripts/ide/stores/actions_spec.js @@ -1,7 +1,6 @@ import * as urlUtils from '~/lib/utils/url_utility'; import * as actions from '~/ide/stores/actions'; import store from '~/ide/stores'; -import * as actions from '~/ide/stores/actions'; import * as types from '~/ide/stores/mutation_types'; import router from '~/ide/ide_router'; import { resetStore, file } from '../helpers'; -- cgit v1.2.3 From ca3f7cf0e3e41206e2f557c49b5bf26d4b9cad0f Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Thu, 19 Apr 2018 15:51:43 +0100 Subject: added line height to label in modal fixed spec because of object key change --- spec/javascripts/ide/stores/actions_spec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'spec') diff --git a/spec/javascripts/ide/stores/actions_spec.js b/spec/javascripts/ide/stores/actions_spec.js index d8ebd1019ed..f307e6c4d22 100644 --- a/spec/javascripts/ide/stores/actions_spec.js +++ b/spec/javascripts/ide/stores/actions_spec.js @@ -352,7 +352,7 @@ describe('Multi-file store actions', () => { testAction( actions.updateTempFlagForEntry, - { entry: f, tempFile: false }, + { file: f, tempFile: false }, store.state, [{ type: 'UPDATE_TEMP_FLAG', payload: { path: f.path, tempFile: false } }], [], @@ -375,10 +375,10 @@ describe('Multi-file store actions', () => { testAction( actions.updateTempFlagForEntry, - { entry: f, tempFile: false }, + { file: f, tempFile: false }, store.state, [{ type: 'UPDATE_TEMP_FLAG', payload: { path: f.path, tempFile: false } }], - [{ type: 'updateTempFlagForEntry', payload: { entry: parent, tempFile: false } }], + [{ type: 'updateTempFlagForEntry', payload: { file: parent, tempFile: false } }], done, ); }); -- cgit v1.2.3