From e8d2c2579383897a1dd7f9debd359abe8ae8373d Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 20 Jul 2021 09:55:51 +0000 Subject: Add latest changes from gitlab-org/gitlab@14-1-stable-ee --- .../components/mr_widget_header_spec.js | 70 +++++++++++----------- .../components/mr_widget_rebase_spec.js | 14 ++--- .../components/states/commit_edit_spec.js | 2 +- .../components/states/mr_widget_conflicts_spec.js | 2 +- .../components/states/mr_widget_merged_spec.js | 2 - .../states/mr_widget_ready_to_merge_spec.js | 3 + spec/frontend/vue_mr_widget/mock_data.js | 4 +- 7 files changed, 48 insertions(+), 49 deletions(-) (limited to 'spec/frontend/vue_mr_widget') diff --git a/spec/frontend/vue_mr_widget/components/mr_widget_header_spec.js b/spec/frontend/vue_mr_widget/components/mr_widget_header_spec.js index 115f21d8b35..f44f0b98207 100644 --- a/spec/frontend/vue_mr_widget/components/mr_widget_header_spec.js +++ b/spec/frontend/vue_mr_widget/components/mr_widget_header_spec.js @@ -1,4 +1,4 @@ -import { shallowMount } from '@vue/test-utils'; +import { shallowMount, mount } from '@vue/test-utils'; import { nextTick } from 'vue'; import Header from '~/vue_merge_request_widget/components/mr_widget_header.vue'; @@ -26,6 +26,15 @@ describe('MRWidgetHeader', () => { expect(downloadPlainDiffEl.attributes('href')).toBe('/mr/plainDiffPath'); }; + const commonMrProps = { + divergedCommitsCount: 1, + sourceBranch: 'mr-widget-refactor', + sourceBranchLink: 'Link', + targetBranch: 'main', + targetBranchPath: '/foo/bar/main', + statusPath: 'abc', + }; + describe('computed', () => { describe('shouldShowCommitsBehindText', () => { it('return true when there are divergedCommitsCount', () => { @@ -59,36 +68,28 @@ describe('MRWidgetHeader', () => { describe('commitsBehindText', () => { it('returns singular when there is one commit', () => { - createComponent({ - mr: { - divergedCommitsCount: 1, - sourceBranch: 'mr-widget-refactor', - sourceBranchLink: 'Link', - targetBranch: 'main', - targetBranchPath: '/foo/bar/main', - statusPath: 'abc', + wrapper = mount(Header, { + propsData: { + mr: commonMrProps, }, }); - expect(wrapper.vm.commitsBehindText).toBe( - 'The source branch is 1 commit behind the target branch', + expect(wrapper.find('.diverged-commits-count').element.innerHTML).toBe( + 'The source branch is 1 commit behind the target branch', ); }); it('returns plural when there is more than one commit', () => { - createComponent({ - mr: { - divergedCommitsCount: 2, - sourceBranch: 'mr-widget-refactor', - sourceBranchLink: 'Link', - targetBranch: 'main', - targetBranchPath: '/foo/bar/main', - statusPath: 'abc', + wrapper = mount(Header, { + propsData: { + mr: { + ...commonMrProps, + divergedCommitsCount: 2, + }, }, }); - - expect(wrapper.vm.commitsBehindText).toBe( - 'The source branch is 2 commits behind the target branch', + expect(wrapper.find('.diverged-commits-count').element.innerHTML).toBe( + 'The source branch is 2 commits behind the target branch', ); }); }); @@ -273,19 +274,18 @@ describe('MRWidgetHeader', () => { describe('with diverged commits', () => { beforeEach(() => { - createComponent({ - mr: { - divergedCommitsCount: 12, - sourceBranch: 'mr-widget-refactor', - sourceBranchLink: 'mr-widget-refactor', - sourceBranchRemoved: false, - targetBranchPath: 'foo/bar/commits-path', - targetBranchTreePath: 'foo/bar/tree/path', - targetBranch: 'main', - isOpen: true, - emailPatchesPath: '/mr/email-patches', - plainDiffPath: '/mr/plainDiffPath', - statusPath: 'abc', + wrapper = mount(Header, { + propsData: { + mr: { + ...commonMrProps, + divergedCommitsCount: 12, + sourceBranchRemoved: false, + targetBranchPath: 'foo/bar/commits-path', + targetBranchTreePath: 'foo/bar/tree/path', + isOpen: true, + emailPatchesPath: '/mr/email-patches', + plainDiffPath: '/mr/plainDiffPath', + }, }, }); }); diff --git a/spec/frontend/vue_mr_widget/components/mr_widget_rebase_spec.js b/spec/frontend/vue_mr_widget/components/mr_widget_rebase_spec.js index 5081e1e5906..d3221cc2fc7 100644 --- a/spec/frontend/vue_mr_widget/components/mr_widget_rebase_spec.js +++ b/spec/frontend/vue_mr_widget/components/mr_widget_rebase_spec.js @@ -70,9 +70,9 @@ describe('Merge request widget rebase component', () => { const text = findRebaseMessageElText(); - expect(text).toContain('Fast-forward merge is not possible.'); + expect(text).toContain('Merge blocked'); expect(text.replace(/\s\s+/g, ' ')).toContain( - 'Rebase the source branch onto the target branch.', + 'the source branch must be rebased onto the target branch', ); }); @@ -111,12 +111,10 @@ describe('Merge request widget rebase component', () => { const text = findRebaseMessageElText(); - expect(text).toContain('Fast-forward merge is not possible.'); - expect(text).toContain('Rebase the source branch onto'); - expect(text).toContain('foo'); - expect(text.replace(/\s\s+/g, ' ')).toContain( - 'to allow this merge request to be merged.', + expect(text).toContain( + 'Merge blocked: the source branch must be rebased onto the target branch.', ); + expect(text).toContain('the source branch must be rebased'); }); it('should render the correct target branch name', () => { @@ -136,7 +134,7 @@ describe('Merge request widget rebase component', () => { const elem = findRebaseMessageEl(); expect(elem.text()).toContain( - `Fast-forward merge is not possible. Rebase the source branch onto ${targetBranch} to allow this merge request to be merged.`, + `Merge blocked: the source branch must be rebased onto the target branch.`, ); }); }); diff --git a/spec/frontend/vue_mr_widget/components/states/commit_edit_spec.js b/spec/frontend/vue_mr_widget/components/states/commit_edit_spec.js index 5d09af50420..8214cedc4a1 100644 --- a/spec/frontend/vue_mr_widget/components/states/commit_edit_spec.js +++ b/spec/frontend/vue_mr_widget/components/states/commit_edit_spec.js @@ -63,7 +63,7 @@ describe('Commits edit component', () => { beforeEach(() => { createComponent({ header: `
${testCommitMessage}
`, - checkbox: ``, + checkbox: ``, }); }); diff --git a/spec/frontend/vue_mr_widget/components/states/mr_widget_conflicts_spec.js b/spec/frontend/vue_mr_widget/components/states/mr_widget_conflicts_spec.js index fee78d3af94..e1bce7f0474 100644 --- a/spec/frontend/vue_mr_widget/components/states/mr_widget_conflicts_spec.js +++ b/spec/frontend/vue_mr_widget/components/states/mr_widget_conflicts_spec.js @@ -199,7 +199,7 @@ describe('MRWidgetConflicts', () => { }); expect(removeBreakLine(wrapper.text()).trim()).toContain( - 'Fast-forward merge is not possible. To merge this request, first rebase locally.', + 'Merge blocked: fast-forward merge is not possible. To merge this request, first rebase locally.', ); }); }); diff --git a/spec/frontend/vue_mr_widget/components/states/mr_widget_merged_spec.js b/spec/frontend/vue_mr_widget/components/states/mr_widget_merged_spec.js index 6bb87893c31..9c3a6d581e8 100644 --- a/spec/frontend/vue_mr_widget/components/states/mr_widget_merged_spec.js +++ b/spec/frontend/vue_mr_widget/components/states/mr_widget_merged_spec.js @@ -217,7 +217,6 @@ describe('MRWidgetMerged', () => { vm.mr.sourceBranchRemoved = false; Vue.nextTick(() => { - expect(vm.$el.innerText).toContain('You can delete the source branch now'); expect(vm.$el.innerText).not.toContain('The source branch has been deleted'); done(); }); @@ -229,7 +228,6 @@ describe('MRWidgetMerged', () => { Vue.nextTick(() => { expect(vm.$el.innerText).toContain('The source branch is being deleted'); - expect(vm.$el.innerText).not.toContain('You can delete the source branch now'); expect(vm.$el.innerText).not.toContain('The source branch has been deleted'); done(); }); diff --git a/spec/frontend/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js b/spec/frontend/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js index 2d00cd8e8d4..cd77d442cbf 100644 --- a/spec/frontend/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js +++ b/spec/frontend/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js @@ -70,6 +70,9 @@ const createComponent = (customConfig = {}, mergeRequestWidgetGraphql = false) = mergeRequestWidgetGraphql, }, }, + stubs: { + CommitEdit, + }, }); }; diff --git a/spec/frontend/vue_mr_widget/mock_data.js b/spec/frontend/vue_mr_widget/mock_data.js index 8e36a9225d6..e6f1e15d718 100644 --- a/spec/frontend/vue_mr_widget/mock_data.js +++ b/spec/frontend/vue_mr_widget/mock_data.js @@ -273,9 +273,9 @@ export default { 'http://localhost:3000/root/acets-app/commit/53027d060246c8f47e4a9310fb332aa52f221775', mr_troubleshooting_docs_path: 'help', ci_troubleshooting_docs_path: 'help2', - merge_request_pipelines_docs_path: '/help/ci/merge_request_pipelines/index.md', + merge_request_pipelines_docs_path: '/help/ci/pipelines/merge_request_pipelines.md', merge_train_when_pipeline_succeeds_docs_path: - '/help/ci/merge_request_pipelines/pipelines_for_merged_results/merge_trains/#startadd-to-merge-train-when-pipeline-succeeds', + '/help/ci/pipelines/merge_trains.md#startadd-to-merge-train-when-pipeline-succeeds', squash: true, visual_review_app_available: true, merge_trains_enabled: true, -- cgit v1.2.3