diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-05 22:40:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-05 22:40:33 +0300 |
commit | d7c5be92af9c10cf20e78363c188c1a707a6bb90 (patch) | |
tree | df2d354bc4277c7a0324fb8240bd4e24d58007f2 /spec/frontend | |
parent | b28d1361dd1ec63053dbfae475097928c6d01116 (diff) |
Add latest changes from gitlab-org/gitlab@15-6-stable-ee
Diffstat (limited to 'spec/frontend')
-rw-r--r-- | spec/frontend/branches/components/delete_branch_modal_spec.js | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/spec/frontend/branches/components/delete_branch_modal_spec.js b/spec/frontend/branches/components/delete_branch_modal_spec.js index 2b8c8d408c4..c977868ca93 100644 --- a/spec/frontend/branches/components/delete_branch_modal_spec.js +++ b/spec/frontend/branches/components/delete_branch_modal_spec.js @@ -46,6 +46,7 @@ const findDeleteButton = () => wrapper.findByTestId('delete-branch-confirmation- const findCancelButton = () => wrapper.findByTestId('delete-branch-cancel-button'); const findFormInput = () => wrapper.findComponent(GlFormInput); const findForm = () => wrapper.find('form'); +const submitFormSpy = () => jest.spyOn(wrapper.vm.$refs.form, 'submit'); describe('Delete branch modal', () => { const expectedUnmergedWarning = @@ -73,12 +74,10 @@ describe('Delete branch modal', () => { }); it('submits the form when the delete button is clicked', () => { - const submitFormSpy = jest.spyOn(wrapper.vm.$refs.form, 'submit'); - findDeleteButton().trigger('click'); expect(findForm().attributes('action')).toBe(deletePath); - expect(submitFormSpy).toHaveBeenCalled(); + expect(submitFormSpy()).toHaveBeenCalled(); }); it('calls show on the modal when a `openModal` event is received through the event hub', async () => { @@ -136,7 +135,18 @@ describe('Delete branch modal', () => { }); }); - it('opens with the delete button disabled and enables it when branch name is confirmed', async () => { + it('opens with the delete button disabled and doesn`t fire submit when clicked or pressed enter', async () => { + expect(findDeleteButton().props('disabled')).toBe(true); + + findFormInput().vm.$emit('input', 'hello'); + + await waitForPromises(); + + findDeleteButton().trigger('click'); + expect(submitFormSpy()).not.toHaveBeenCalled(); + }); + + it('opens with the delete button disabled and enables it when branch name is confirmed and fires submit', async () => { expect(findDeleteButton().props('disabled')).toBe(true); findFormInput().vm.$emit('input', branchName); @@ -144,6 +154,9 @@ describe('Delete branch modal', () => { await waitForPromises(); expect(findDeleteButton().props('disabled')).not.toBe(true); + + findDeleteButton().trigger('click'); + expect(submitFormSpy()).toHaveBeenCalled(); }); }); |