diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
commit | 6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch) | |
tree | dc4d20fe6064752c0bd323187252c77e0a89144b /spec/frontend/batch_comments/components/submit_dropdown_spec.js | |
parent | 9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff) |
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'spec/frontend/batch_comments/components/submit_dropdown_spec.js')
-rw-r--r-- | spec/frontend/batch_comments/components/submit_dropdown_spec.js | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/spec/frontend/batch_comments/components/submit_dropdown_spec.js b/spec/frontend/batch_comments/components/submit_dropdown_spec.js index 4f5ff797230..462ef7e7280 100644 --- a/spec/frontend/batch_comments/components/submit_dropdown_spec.js +++ b/spec/frontend/batch_comments/components/submit_dropdown_spec.js @@ -8,7 +8,7 @@ Vue.use(Vuex); let wrapper; let publishReview; -function factory() { +function factory({ canApprove = true } = {}) { publishReview = jest.fn(); const store = new Vuex.Store({ @@ -17,8 +17,13 @@ function factory() { markdownDocsPath: '/markdown/docs', quickActionsDocsPath: '/quickactions/docs', }), - getNoteableData: () => ({ id: 1, preview_note_path: '/preview' }), + getNoteableData: () => ({ + id: 1, + preview_note_path: '/preview', + current_user: { can_approve: canApprove }, + }), noteableType: () => 'merge_request', + getCurrentUserLastNote: () => ({ id: 1 }), }, modules: { batchComments: { @@ -41,6 +46,7 @@ const findForm = () => wrapper.findByTestId('submit-gl-form'); describe('Batch comments submit dropdown', () => { afterEach(() => { wrapper.destroy(); + window.mrTabs = null; }); it('calls publishReview with note data', async () => { @@ -54,9 +60,24 @@ describe('Batch comments submit dropdown', () => { noteable_type: 'merge_request', noteable_id: 1, note: 'Hello world', + approve: false, + approval_password: '', }); }); + it('switches to the overview tab after submit', async () => { + window.mrTabs = { tabShown: jest.fn() }; + + factory(); + + findCommentTextarea().setValue('Hello world'); + + await findForm().vm.$emit('submit', { preventDefault: jest.fn() }); + await Vue.nextTick(); + + expect(window.mrTabs.tabShown).toHaveBeenCalledWith('show'); + }); + it('sets submit dropdown to loading', async () => { factory(); @@ -66,4 +87,14 @@ describe('Batch comments submit dropdown', () => { expect(findSubmitButton().props('loading')).toBe(true); }); + + it.each` + canApprove | exists | existsText + ${true} | ${true} | ${'shows'} + ${false} | ${false} | ${'hides'} + `('$existsText approve checkbox if can_approve is $canApprove', ({ canApprove, exists }) => { + factory({ canApprove }); + + expect(wrapper.findByTestId('approve_merge_request').exists()).toBe(exists); + }); }); |