diff options
author | Denys Mishunov <dmishunov@gitlab.com> | 2019-06-26 14:50:31 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2019-06-26 14:50:31 +0000 |
commit | f0fc53589755d00320b8c12ae739ba6c18872c3c (patch) | |
tree | 5fffcfa518cb76e34c3debbbcb19d275dcc9f4fc /spec/javascripts | |
parent | 4b7f053a49168491215e8ee20060c7283e138858 (diff) | |
download | gitlab-ce-f0fc53589755d00320b8c12ae739ba6c18872c3c.tar.gz |
Re-name entries in one commit
Update window's URL after entry's re-name
Set proper hook for correct fileLanguage
Filtered out `moved` entries from the tree
Diffstat (limited to 'spec/javascripts')
-rw-r--r-- | spec/javascripts/ide/components/ide_tree_list_spec.js | 14 | ||||
-rw-r--r-- | spec/javascripts/ide/stores/actions/file_spec.js | 37 | ||||
-rw-r--r-- | spec/javascripts/ide/stores/actions_spec.js | 10 | ||||
-rw-r--r-- | spec/javascripts/ide/stores/mutations_spec.js | 11 |
4 files changed, 61 insertions, 11 deletions
diff --git a/spec/javascripts/ide/components/ide_tree_list_spec.js b/spec/javascripts/ide/components/ide_tree_list_spec.js index f63007c7dd2..554bd1ae3b5 100644 --- a/spec/javascripts/ide/components/ide_tree_list_spec.js +++ b/spec/javascripts/ide/components/ide_tree_list_spec.js @@ -58,6 +58,20 @@ describe('IDE tree list', () => { it('renders list of files', () => { expect(vm.$el.textContent).toContain('fileName'); }); + + it('does not render moved entries', done => { + const tree = [file('moved entry'), file('normal entry')]; + tree[0].moved = true; + store.state.trees['abcproject/master'].tree = tree; + const container = vm.$el.querySelector('.ide-tree-body'); + + vm.$nextTick(() => { + expect(container.children.length).toBe(1); + expect(vm.$el.textContent).not.toContain('moved entry'); + expect(vm.$el.textContent).toContain('normal entry'); + done(); + }); + }); }); describe('empty-branch state', () => { diff --git a/spec/javascripts/ide/stores/actions/file_spec.js b/spec/javascripts/ide/stores/actions/file_spec.js index dd2313dc800..021c3076094 100644 --- a/spec/javascripts/ide/stores/actions/file_spec.js +++ b/spec/javascripts/ide/stores/actions/file_spec.js @@ -275,6 +275,43 @@ describe('IDE store file actions', () => { }); }); + describe('Re-named success', () => { + beforeEach(() => { + localFile = file(`newCreate-${Math.random()}`); + localFile.url = `project/getFileDataURL`; + localFile.prevPath = 'old-dull-file'; + localFile.path = 'new-shiny-file'; + store.state.entries[localFile.path] = localFile; + + mock.onGet(`${RELATIVE_URL_ROOT}/project/getFileDataURL`).replyOnce( + 200, + { + blame_path: 'blame_path', + commits_path: 'commits_path', + permalink: 'permalink', + raw_path: 'raw_path', + binary: false, + html: '123', + render_error: '', + }, + { + 'page-title': 'testing old-dull-file', + }, + ); + }); + + it('sets document title considering `prevPath` on a file', done => { + store + .dispatch('getFileData', { path: localFile.path }) + .then(() => { + expect(document.title).toBe('testing new-shiny-file'); + + done(); + }) + .catch(done.fail); + }); + }); + describe('error', () => { beforeEach(() => { mock.onGet(`project/getFileDataURL`).networkError(); diff --git a/spec/javascripts/ide/stores/actions_spec.js b/spec/javascripts/ide/stores/actions_spec.js index 537152f5eed..2d105103c1c 100644 --- a/spec/javascripts/ide/stores/actions_spec.js +++ b/spec/javascripts/ide/stores/actions_spec.js @@ -536,8 +536,15 @@ describe('Multi-file store actions', () => { type: types.RENAME_ENTRY, payload: { path: 'test', name: 'new-name', entryPath: null, parentPath: 'parent-path' }, }, + { + type: types.TOGGLE_FILE_CHANGED, + payload: { + file: store.state.entries['parent-path/new-name'], + changed: true, + }, + }, ], - [{ type: 'deleteEntry', payload: 'test' }, { type: 'triggerFilesChange' }], + [{ type: 'triggerFilesChange' }], done, ); }); @@ -584,7 +591,6 @@ describe('Multi-file store actions', () => { parentPath: 'parent-path/new-name', }, }, - { type: 'deleteEntry', payload: 'test' }, { type: 'triggerFilesChange' }, ], done, diff --git a/spec/javascripts/ide/stores/mutations_spec.js b/spec/javascripts/ide/stores/mutations_spec.js index 5ee098bf17f..460c5b01081 100644 --- a/spec/javascripts/ide/stores/mutations_spec.js +++ b/spec/javascripts/ide/stores/mutations_spec.js @@ -309,7 +309,7 @@ describe('Multi-file store mutations', () => { ...localState.entries.oldPath, id: 'newPath', name: 'newPath', - key: 'newPath-blob-name', + key: 'newPath-blob-oldPath', path: 'newPath', tempFile: true, prevPath: 'oldPath', @@ -318,6 +318,7 @@ describe('Multi-file store mutations', () => { url: `${gl.TEST_HOST}/newPath`, moved: jasmine.anything(), movedPath: jasmine.anything(), + opened: false, }); }); @@ -349,13 +350,5 @@ describe('Multi-file store mutations', () => { expect(localState.entries.parentPath.tree.length).toBe(1); }); - - it('adds to openFiles if previously opened', () => { - localState.entries.oldPath.opened = true; - - mutations.RENAME_ENTRY(localState, { path: 'oldPath', name: 'newPath' }); - - expect(localState.openFiles).toEqual([localState.entries.newPath]); - }); }); }); |