diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-22 18:09:48 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-22 18:09:48 +0300 |
commit | 640007842a876dfa551578feccfd0fe2307c522a (patch) | |
tree | 4204c45a13b9beac3040df00572ffe0ecdb0ca40 /spec/frontend/batch_comments/components/preview_dropdown_spec.js | |
parent | 421f6c92d5984d035a7a6687d70277ba88f5f92b (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/batch_comments/components/preview_dropdown_spec.js')
-rw-r--r-- | spec/frontend/batch_comments/components/preview_dropdown_spec.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/frontend/batch_comments/components/preview_dropdown_spec.js b/spec/frontend/batch_comments/components/preview_dropdown_spec.js index bf3bbf4de26..079b64225e4 100644 --- a/spec/frontend/batch_comments/components/preview_dropdown_spec.js +++ b/spec/frontend/batch_comments/components/preview_dropdown_spec.js @@ -1,8 +1,15 @@ import Vue, { nextTick } from 'vue'; import Vuex from 'vuex'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; +import { TEST_HOST } from 'helpers/test_constants'; +import { visitUrl } from '~/lib/utils/url_utility'; import PreviewDropdown from '~/batch_comments/components/preview_dropdown.vue'; +jest.mock('~/lib/utils/url_utility', () => ({ + visitUrl: jest.fn(), + setUrlParams: jest.requireActual('~/lib/utils/url_utility').setUrlParams, +})); + Vue.use(Vuex); let wrapper; @@ -27,6 +34,11 @@ function factory({ viewDiffsFileByFile = false, draftsCount = 1, sortedDrafts = actions: { scrollToDraft }, getters: { draftsCount: () => draftsCount, sortedDrafts: () => sortedDrafts }, }, + notes: { + getters: { + getNoteableData: () => ({ diff_head_sha: '123' }), + }, + }, }, }); @@ -67,5 +79,19 @@ describe('Batch comments preview dropdown', () => { expect(scrollToDraft).toHaveBeenCalledWith(expect.anything(), { id: 1 }); }); + + it('changes window location to navigate to commit', async () => { + factory({ + viewDiffsFileByFile: false, + sortedDrafts: [{ id: 1, position: { head_sha: '1234' } }], + }); + + wrapper.findByTestId('preview-item').vm.$emit('click'); + + await nextTick(); + + expect(scrollToDraft).not.toHaveBeenCalled(); + expect(visitUrl).toHaveBeenCalledWith(`${TEST_HOST}/?commit_id=1234#note_1`); + }); }); }); |