diff options
author | Phil Hughes <me@iamphill.com> | 2019-03-11 16:09:36 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2019-03-11 16:09:36 +0300 |
commit | c36095b2e363b7a2d2c704a917bedf2337631a66 (patch) | |
tree | 507eef2f111846ef3ac4d489dbfe9f9f5c700be3 /spec | |
parent | 97357c5bb6594be793c1af332bed8f942f2d72d2 (diff) |
Fix expand all button not working
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/51737
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/merge_request/user_views_diffs_spec.rb | 10 | ||||
-rw-r--r-- | spec/javascripts/diffs/components/diff_file_spec.js | 25 | ||||
-rw-r--r-- | spec/javascripts/diffs/store/actions_spec.js | 14 | ||||
-rw-r--r-- | spec/javascripts/diffs/store/mutations_spec.js | 18 |
4 files changed, 65 insertions, 2 deletions
diff --git a/spec/features/merge_request/user_views_diffs_spec.rb b/spec/features/merge_request/user_views_diffs_spec.rb index 0434db04113..74342b16cb2 100644 --- a/spec/features/merge_request/user_views_diffs_spec.rb +++ b/spec/features/merge_request/user_views_diffs_spec.rb @@ -34,6 +34,16 @@ describe 'User views diffs', :js do expect(page).not_to have_selector('.mr-loading-status .loading', visible: true) end + it 'expands all diffs' do + first('#a5cc2925ca8258af241be7e5b0381edf30266302 .js-file-title').click + + expect(page).to have_button('Expand all') + + click_button 'Expand all' + + expect(page).not_to have_button('Expand all') + end + context 'when in the inline view' do include_examples 'unfold diffs' end diff --git a/spec/javascripts/diffs/components/diff_file_spec.js b/spec/javascripts/diffs/components/diff_file_spec.js index ba04c8c4a4c..d9b298e84da 100644 --- a/spec/javascripts/diffs/components/diff_file_spec.js +++ b/spec/javascripts/diffs/components/diff_file_spec.js @@ -109,6 +109,31 @@ describe('DiffFile', () => { done(); }); }); + + it('should update store state', done => { + spyOn(vm.$store, 'dispatch'); + + vm.isCollapsed = true; + + vm.$nextTick(() => { + expect(vm.$store.dispatch).toHaveBeenCalledWith('diffs/setFileCollapsed', { + filePath: vm.file.file_path, + collapsed: true, + }); + + done(); + }); + }); + + it('updates local state when changing file state', done => { + vm.file.viewer.collapsed = true; + + vm.$nextTick(() => { + expect(vm.isCollapsed).toBe(true); + + done(); + }); + }); }); }); diff --git a/spec/javascripts/diffs/store/actions_spec.js b/spec/javascripts/diffs/store/actions_spec.js index 070bfb2ccd0..6c637097893 100644 --- a/spec/javascripts/diffs/store/actions_spec.js +++ b/spec/javascripts/diffs/store/actions_spec.js @@ -35,6 +35,7 @@ import actions, { receiveFullDiffError, fetchFullDiff, toggleFullDiff, + setFileCollapsed, } from '~/diffs/store/actions'; import eventHub from '~/notes/event_hub'; import * as types from '~/diffs/store/mutation_types'; @@ -977,4 +978,17 @@ describe('DiffsStoreActions', () => { ); }); }); + + describe('setFileCollapsed', () => { + it('commits SET_FILE_COLLAPSED', done => { + testAction( + setFileCollapsed, + { filePath: 'test', collapsed: true }, + null, + [{ type: types.SET_FILE_COLLAPSED, payload: { filePath: 'test', collapsed: true } }], + [], + done, + ); + }); + }); }); diff --git a/spec/javascripts/diffs/store/mutations_spec.js b/spec/javascripts/diffs/store/mutations_spec.js index 270e7d75666..5556a994a14 100644 --- a/spec/javascripts/diffs/store/mutations_spec.js +++ b/spec/javascripts/diffs/store/mutations_spec.js @@ -58,13 +58,15 @@ describe('DiffsStoreMutations', () => { describe('EXPAND_ALL_FILES', () => { it('should change the collapsed prop from diffFiles', () => { const diffFile = { - collapsed: true, + viewer: { + collapsed: true, + }, }; const state = { expandAllFiles: true, diffFiles: [diffFile] }; mutations[types.EXPAND_ALL_FILES](state); - expect(state.diffFiles[0].collapsed).toEqual(false); + expect(state.diffFiles[0].viewer.collapsed).toEqual(false); }); }); @@ -742,4 +744,16 @@ describe('DiffsStoreMutations', () => { expect(state.diffFiles[0].isShowingFullFile).toBe(true); }); }); + + describe('SET_FILE_COLLAPSED', () => { + it('sets collapsed', () => { + const state = { + diffFiles: [{ file_path: 'test', viewer: { collapsed: false } }], + }; + + mutations[types.SET_FILE_COLLAPSED](state, { filePath: 'test', collapsed: true }); + + expect(state.diffFiles[0].viewer.collapsed).toBe(true); + }); + }); }); |