Commit f728fe61 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'ph/324178/autoMergeWidgetUpdate' into 'master'

Updated auto merge widget to match new designs

See merge request gitlab-org/gitlab!66637
parents 0bd3371e e2c89667
...@@ -28,7 +28,12 @@ export default { ...@@ -28,7 +28,12 @@ export default {
}; };
</script> </script>
<template> <template>
<a v-gl-tooltip :href="authorUrl" :title="author.name" class="author-link inline"> <a
v-gl-tooltip
:href="authorUrl"
:title="showAuthorName ? null : author.name"
class="author-link inline"
>
<img :src="avatarUrl" class="avatar avatar-inline s16" /> <img :src="avatarUrl" class="avatar avatar-inline s16" />
<span v-if="showAuthorName" class="author">{{ author.name }}</span> <span v-if="showAuthorName" class="author">{{ author.name }}</span>
</a> </a>
......
<script> <script>
import { GlLoadingIcon, GlSkeletonLoader } from '@gitlab/ui'; import { GlSkeletonLoader, GlIcon, GlButton, GlSprintf } from '@gitlab/ui';
import autoMergeMixin from 'ee_else_ce/vue_merge_request_widget/mixins/auto_merge'; import autoMergeMixin from 'ee_else_ce/vue_merge_request_widget/mixins/auto_merge';
import autoMergeEnabledQuery from 'ee_else_ce/vue_merge_request_widget/queries/states/auto_merge_enabled.query.graphql'; import autoMergeEnabledQuery from 'ee_else_ce/vue_merge_request_widget/queries/states/auto_merge_enabled.query.graphql';
import createFlash from '~/flash'; import createFlash from '~/flash';
...@@ -10,7 +10,6 @@ import { AUTO_MERGE_STRATEGIES } from '../../constants'; ...@@ -10,7 +10,6 @@ import { AUTO_MERGE_STRATEGIES } from '../../constants';
import eventHub from '../../event_hub'; import eventHub from '../../event_hub';
import mergeRequestQueryVariablesMixin from '../../mixins/merge_request_query_variables'; import mergeRequestQueryVariablesMixin from '../../mixins/merge_request_query_variables';
import MrWidgetAuthor from '../mr_widget_author.vue'; import MrWidgetAuthor from '../mr_widget_author.vue';
import statusIcon from '../mr_widget_status_icon.vue';
export default { export default {
name: 'MRWidgetAutoMergeEnabled', name: 'MRWidgetAutoMergeEnabled',
...@@ -28,9 +27,10 @@ export default { ...@@ -28,9 +27,10 @@ export default {
}, },
components: { components: {
MrWidgetAuthor, MrWidgetAuthor,
statusIcon,
GlLoadingIcon,
GlSkeletonLoader, GlSkeletonLoader,
GlIcon,
GlButton,
GlSprintf,
}, },
mixins: [autoMergeMixin, glFeatureFlagMixin(), mergeRequestQueryVariablesMixin], mixins: [autoMergeMixin, glFeatureFlagMixin(), mergeRequestQueryVariablesMixin],
props: { props: {
...@@ -155,54 +155,44 @@ export default { ...@@ -155,54 +155,44 @@ export default {
</gl-skeleton-loader> </gl-skeleton-loader>
</div> </div>
<template v-else> <template v-else>
<status-icon status="success" /> <gl-icon name="status_scheduled" :size="24" class="gl-text-blue-500 gl-mr-3 gl-mt-1" />
<div class="media-body"> <div class="media-body">
<h4 class="gl-display-flex"> <h4 class="gl-display-flex">
<span class="gl-mr-3"> <span class="gl-mr-3">
<span class="js-status-text-before-author" data-testid="beforeStatusText">{{ <gl-sprintf :message="statusText" data-testid="statusText">
statusTextBeforeAuthor <template #merge_author>
}}</span> <mr-widget-author :author="mergeUser" />
<mr-widget-author :author="mergeUser" /> </template>
<span class="js-status-text-after-author" data-testid="afterStatusText">{{ </gl-sprintf>
statusTextAfterAuthor
}}</span>
</span> </span>
<a <gl-button
v-if="mr.canCancelAutomaticMerge" v-if="mr.canCancelAutomaticMerge"
:disabled="isCancellingAutoMerge" :loading="isCancellingAutoMerge"
role="button" size="small"
href="#" class="js-cancel-auto-merge"
class="btn btn-sm btn-default js-cancel-auto-merge"
data-qa-selector="cancel_auto_merge_button" data-qa-selector="cancel_auto_merge_button"
data-testid="cancelAutomaticMergeButton" data-testid="cancelAutomaticMergeButton"
@click.prevent="cancelAutomaticMerge" @click="cancelAutomaticMerge"
> >
<gl-loading-icon v-if="isCancellingAutoMerge" size="sm" inline class="gl-mr-1" />
{{ cancelButtonText }} {{ cancelButtonText }}
</a> </gl-button>
</h4> </h4>
<section class="mr-info-list"> <section class="mr-info-list">
<p>
{{ s__('mrWidget|The changes will be merged into') }}
<a :href="mr.targetBranchPath" class="label-branch">{{ targetBranch }}</a>
</p>
<p v-if="shouldRemoveSourceBranch"> <p v-if="shouldRemoveSourceBranch">
{{ s__('mrWidget|The source branch will be deleted') }} {{ s__('mrWidget|The source branch will be deleted') }}
</p> </p>
<p v-else class="gl-display-flex"> <p v-else class="gl-display-flex">
<span class="gl-mr-3">{{ s__('mrWidget|The source branch will not be deleted') }}</span> <span class="gl-mr-3">{{ s__('mrWidget|The source branch will not be deleted') }}</span>
<a <gl-button
v-if="canRemoveSourceBranch" v-if="canRemoveSourceBranch"
:disabled="isRemovingSourceBranch" :loading="isRemovingSourceBranch"
role="button" size="small"
class="btn btn-sm btn-default js-remove-source-branch" class="js-remove-source-branch"
href="#"
data-testid="removeSourceBranchButton" data-testid="removeSourceBranchButton"
@click.prevent="removeSourceBranch" @click="removeSourceBranch"
> >
<gl-loading-icon v-if="isRemovingSourceBranch" size="sm" inline class="gl-mr-1" />
{{ s__('mrWidget|Delete source branch') }} {{ s__('mrWidget|Delete source branch') }}
</a> </gl-button>
</p> </p>
</section> </section>
</div> </div>
......
...@@ -2,14 +2,13 @@ import { s__ } from '~/locale'; ...@@ -2,14 +2,13 @@ import { s__ } from '~/locale';
export default { export default {
computed: { computed: {
statusTextBeforeAuthor() { statusText() {
return s__('mrWidget|Set by'); return s__(
}, 'mrWidget|Set by %{merge_author} to be merged automatically when the pipeline succeeds',
statusTextAfterAuthor() { );
return s__('mrWidget|to be merged automatically when the pipeline succeeds');
}, },
cancelButtonText() { cancelButtonText() {
return s__('mrWidget|Cancel'); return s__('mrWidget|Cancel auto-merge');
}, },
}, },
}; };
...@@ -23,8 +23,8 @@ export default function deviseState() { ...@@ -23,8 +23,8 @@ export default function deviseState() {
return stateKey.pipelineBlocked; return stateKey.pipelineBlocked;
} else if (this.canMerge && this.isSHAMismatch) { } else if (this.canMerge && this.isSHAMismatch) {
return stateKey.shaMismatch; return stateKey.shaMismatch;
} else if (this.autoMergeEnabled) { } else if (this.autoMergeEnabled && !this.mergeError) {
return this.mergeError ? stateKey.autoMergeFailed : stateKey.autoMergeEnabled; return stateKey.autoMergeEnabled;
} else if (!this.canMerge) { } else if (!this.canMerge) {
return stateKey.notAllowedToMerge; return stateKey.notAllowedToMerge;
} else if (this.canBeMerged) { } else if (this.canBeMerged) {
......
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { import { MT_MERGE_STRATEGY, MTWPS_MERGE_STRATEGY } from '~/vue_merge_request_widget/constants';
MT_MERGE_STRATEGY,
MTWPS_MERGE_STRATEGY,
MWPS_MERGE_STRATEGY,
} from '~/vue_merge_request_widget/constants';
export default { export default {
computed: { computed: {
statusTextBeforeAuthor() { statusText() {
if (this.autoMergeStrategy === MT_MERGE_STRATEGY) {
return s__('mrWidget|Added to the merge train by');
}
return s__('mrWidget|Set by');
},
statusTextAfterAuthor() {
const { mergeTrainsCount } = this.glFeatures.mergeRequestWidgetGraphql ? this.state : this.mr; const { mergeTrainsCount } = this.glFeatures.mergeRequestWidgetGraphql ? this.state : this.mr;
if (this.autoMergeStrategy === MTWPS_MERGE_STRATEGY && mergeTrainsCount === 0) { if (this.autoMergeStrategy === MT_MERGE_STRATEGY) {
return s__('mrWidget|to start a merge train when the pipeline succeeds'); return s__('mrWidget|Added to the merge train by %{merge_author}');
} else if (this.autoMergeStrategy === MTWPS_MERGE_STRATEGY && mergeTrainsCount === 0) {
return s__(
'mrWidget|Set by %{merge_author} to start a merge train when the pipeline succeeds',
);
} else if (this.autoMergeStrategy === MTWPS_MERGE_STRATEGY && mergeTrainsCount !== 0) { } else if (this.autoMergeStrategy === MTWPS_MERGE_STRATEGY && mergeTrainsCount !== 0) {
return s__('mrWidget|to be added to the merge train when the pipeline succeeds'); return s__(
} else if (this.autoMergeStrategy === MWPS_MERGE_STRATEGY) { 'mrWidget|Set by %{merge_author} to be added to the merge train when the pipeline succeeds',
return s__('mrWidget|to be merged automatically when the pipeline succeeds'); );
} }
return ''; return s__(
'mrWidget|Set by %{merge_author} to be merged automatically when the pipeline succeeds',
);
}, },
cancelButtonText() { cancelButtonText() {
if (this.autoMergeStrategy === MT_MERGE_STRATEGY) { if (this.autoMergeStrategy === MT_MERGE_STRATEGY) {
return s__('mrWidget|Remove from merge train'); return s__('mrWidget|Remove from merge train');
} }
return s__('mrWidget|Cancel'); return s__('mrWidget|Cancel auto-merge');
}, },
}, },
}; };
...@@ -58,8 +58,8 @@ RSpec.describe 'User adds a merge request to a merge train', :js do ...@@ -58,8 +58,8 @@ RSpec.describe 'User adds a merge request to a merge train', :js do
within('.mr-widget-section') do within('.mr-widget-section') do
expect(page).to have_content("Added to the merge train by #{user.name}") expect(page).to have_content("Added to the merge train by #{user.name}")
expect(page).to have_content('The source branch will not be deleted') expect(page).to have_content('The source branch will not be deleted')
expect(page).to have_link('Remove from merge train') expect(page).to have_button('Remove from merge train')
expect(page).to have_link('Delete source branch') expect(page).to have_button('Delete source branch')
end end
end end
...@@ -84,7 +84,7 @@ RSpec.describe 'User adds a merge request to a merge train', :js do ...@@ -84,7 +84,7 @@ RSpec.describe 'User adds a merge request to a merge train', :js do
context "when user clicks 'Remove from merge train' button" do context "when user clicks 'Remove from merge train' button" do
before do before do
click_link 'Remove from merge train' click_button 'Remove from merge train'
end end
it 'cancels automatic merge' do it 'cancels automatic merge' do
...@@ -97,7 +97,7 @@ RSpec.describe 'User adds a merge request to a merge train', :js do ...@@ -97,7 +97,7 @@ RSpec.describe 'User adds a merge request to a merge train', :js do
context "when user clicks 'Delete source branch" do context "when user clicks 'Delete source branch" do
before do before do
click_link 'Delete source branch' click_button 'Delete source branch'
end end
it 'updates the merge option' do it 'updates the merge option' do
......
...@@ -59,14 +59,14 @@ RSpec.describe 'User adds to merge train when pipeline succeeds', :js do ...@@ -59,14 +59,14 @@ RSpec.describe 'User adds to merge train when pipeline succeeds', :js do
within('.mr-widget-section') do within('.mr-widget-section') do
expect(page).to have_content("Set by #{user.name} to start a merge train when the pipeline succeeds") expect(page).to have_content("Set by #{user.name} to start a merge train when the pipeline succeeds")
expect(page).to have_content('The source branch will not be deleted') expect(page).to have_content('The source branch will not be deleted')
expect(page).to have_link('Cancel') expect(page).to have_button('Cancel auto-merge')
expect(page).to have_link('Delete source branch') expect(page).to have_button('Delete source branch')
end end
end end
context "when user clicks 'Cancel' button" do context "when user clicks 'Cancel' button" do
before do before do
click_link 'Cancel' click_button 'Cancel auto-merge'
end end
it 'cancels automatic merge' do it 'cancels automatic merge' do
...@@ -79,7 +79,7 @@ RSpec.describe 'User adds to merge train when pipeline succeeds', :js do ...@@ -79,7 +79,7 @@ RSpec.describe 'User adds to merge train when pipeline succeeds', :js do
context "when user clicks 'Delete source branch" do context "when user clicks 'Delete source branch" do
before do before do
click_link 'Delete source branch' click_button 'Delete source branch'
end end
it 'updates the merge option' do it 'updates the merge option' do
......
...@@ -15,6 +15,8 @@ describe('MRWidgetAutoMergeEnabled', () => { ...@@ -15,6 +15,8 @@ describe('MRWidgetAutoMergeEnabled', () => {
poll: () => {}, poll: () => {},
}; };
const getStatusText = () => wrapper.find('[data-testid="statusText"]').attributes('message');
const mr = { const mr = {
shouldRemoveSourceBranch: false, shouldRemoveSourceBranch: false,
canRemoveSourceBranch: true, canRemoveSourceBranch: true,
...@@ -45,34 +47,16 @@ describe('MRWidgetAutoMergeEnabled', () => { ...@@ -45,34 +47,16 @@ describe('MRWidgetAutoMergeEnabled', () => {
}); });
describe('computed', () => { describe('computed', () => {
describe('statusTextBeforeAuthor', () => { describe('status', () => {
it('should return "Added to the merge train by" if the pipeline has been added to the merge train', () => {
factory({ autoMergeStrategy: MT_MERGE_STRATEGY });
expect(vm.statusTextBeforeAuthor).toBe('Added to the merge train by');
});
it('should return "Set by" if the MTWPS is selected', () => {
factory({ autoMergeStrategy: MTWPS_MERGE_STRATEGY });
expect(vm.statusTextBeforeAuthor).toBe('Set by');
});
it('should return "Set by" if the MWPS is selected', () => {
factory({ autoMergeStrategy: MWPS_MERGE_STRATEGY });
expect(vm.statusTextBeforeAuthor).toBe('Set by');
});
});
describe('statusTextAfterAuthor', () => {
it('should return "to start a merge train..." if MTWPS is selected and there is no existing merge train', () => { it('should return "to start a merge train..." if MTWPS is selected and there is no existing merge train', () => {
factory({ factory({
autoMergeStrategy: MTWPS_MERGE_STRATEGY, autoMergeStrategy: MTWPS_MERGE_STRATEGY,
mergeTrainsCount: 0, mergeTrainsCount: 0,
}); });
expect(vm.statusTextAfterAuthor).toBe('to start a merge train when the pipeline succeeds'); expect(getStatusText()).toBe(
'Set by %{merge_author} to start a merge train when the pipeline succeeds',
);
}); });
it('should return "to be added to the merge train..." if MTWPS is selected and there is an existing merge train', () => { it('should return "to be added to the merge train..." if MTWPS is selected and there is an existing merge train', () => {
...@@ -81,16 +65,16 @@ describe('MRWidgetAutoMergeEnabled', () => { ...@@ -81,16 +65,16 @@ describe('MRWidgetAutoMergeEnabled', () => {
mergeTrainsCount: 1, mergeTrainsCount: 1,
}); });
expect(vm.statusTextAfterAuthor).toBe( expect(getStatusText()).toBe(
'to be added to the merge train when the pipeline succeeds', 'Set by %{merge_author} to be added to the merge train when the pipeline succeeds',
); );
}); });
it('should return "to be merged automatically..." if MWPS is selected', () => { it('should return "to be merged automatically..." if MWPS is selected', () => {
factory({ autoMergeStrategy: MWPS_MERGE_STRATEGY }); factory({ autoMergeStrategy: MWPS_MERGE_STRATEGY });
expect(vm.statusTextAfterAuthor).toBe( expect(getStatusText()).toBe(
'to be merged automatically when the pipeline succeeds', 'Set by %{merge_author} to be merged automatically when the pipeline succeeds',
); );
}); });
}); });
...@@ -99,7 +83,7 @@ describe('MRWidgetAutoMergeEnabled', () => { ...@@ -99,7 +83,7 @@ describe('MRWidgetAutoMergeEnabled', () => {
it('should return "Cancel start merge train" if MTWPS is selected', () => { it('should return "Cancel start merge train" if MTWPS is selected', () => {
factory({ autoMergeStrategy: MTWPS_MERGE_STRATEGY }); factory({ autoMergeStrategy: MTWPS_MERGE_STRATEGY });
expect(vm.cancelButtonText).toBe('Cancel'); expect(vm.cancelButtonText).toBe('Cancel auto-merge');
}); });
it('should return "Remove from merge train" if the pipeline has been added to the merge train', () => { it('should return "Remove from merge train" if the pipeline has been added to the merge train', () => {
...@@ -111,40 +95,18 @@ describe('MRWidgetAutoMergeEnabled', () => { ...@@ -111,40 +95,18 @@ describe('MRWidgetAutoMergeEnabled', () => {
it('should return "Cancel" if MWPS is selected', () => { it('should return "Cancel" if MWPS is selected', () => {
factory({ autoMergeStrategy: MWPS_MERGE_STRATEGY }); factory({ autoMergeStrategy: MWPS_MERGE_STRATEGY });
expect(vm.cancelButtonText).toBe('Cancel'); expect(vm.cancelButtonText).toBe('Cancel auto-merge');
}); });
}); });
}); });
describe('template', () => { describe('template', () => {
it('should render the status text as "...to start a merge train" if MTWPS is selected and there is no existing merge train', () => {
factory({
autoMergeStrategy: MTWPS_MERGE_STRATEGY,
mergeTrainsCount: 0,
});
const statusText = wrapper.find('.js-status-text-after-author').text();
expect(statusText).toBe('to start a merge train when the pipeline succeeds');
});
it('should render the status text as "...to be added to the merge train" MTWPS is selected and there is an existing merge train', () => {
factory({
autoMergeStrategy: MTWPS_MERGE_STRATEGY,
mergeTrainsCount: 1,
});
const statusText = wrapper.find('.js-status-text-after-author').text();
expect(statusText).toBe('to be added to the merge train when the pipeline succeeds');
});
it('should render the cancel button as "Cancel" if MTWPS is selected', () => { it('should render the cancel button as "Cancel" if MTWPS is selected', () => {
factory({ autoMergeStrategy: MTWPS_MERGE_STRATEGY }); factory({ autoMergeStrategy: MTWPS_MERGE_STRATEGY });
const cancelButtonText = wrapper.find('.js-cancel-auto-merge').text(); const cancelButtonText = wrapper.find('.js-cancel-auto-merge').text();
expect(cancelButtonText).toBe('Cancel'); expect(cancelButtonText).toBe('Cancel auto-merge');
}); });
}); });
......
...@@ -39340,7 +39340,7 @@ msgstr "" ...@@ -39340,7 +39340,7 @@ msgstr ""
msgid "mrWidget|A new merge train has started and this merge request is the first of the queue." msgid "mrWidget|A new merge train has started and this merge request is the first of the queue."
msgstr "" msgstr ""
msgid "mrWidget|Added to the merge train by" msgid "mrWidget|Added to the merge train by %{merge_author}"
msgstr "" msgstr ""
msgid "mrWidget|Added to the merge train. There are %{mergeTrainPosition} merge requests waiting to be merged" msgid "mrWidget|Added to the merge train. There are %{mergeTrainPosition} merge requests waiting to be merged"
...@@ -39373,7 +39373,7 @@ msgstr "" ...@@ -39373,7 +39373,7 @@ msgstr ""
msgid "mrWidget|Are you adding technical debt or code vulnerabilities?" msgid "mrWidget|Are you adding technical debt or code vulnerabilities?"
msgstr "" msgstr ""
msgid "mrWidget|Cancel" msgid "mrWidget|Cancel auto-merge"
msgstr "" msgstr ""
msgid "mrWidget|Check out branch" msgid "mrWidget|Check out branch"
...@@ -39520,7 +39520,13 @@ msgstr "" ...@@ -39520,7 +39520,13 @@ msgstr ""
msgid "mrWidget|Revoke approval" msgid "mrWidget|Revoke approval"
msgstr "" msgstr ""
msgid "mrWidget|Set by" msgid "mrWidget|Set by %{merge_author} to be added to the merge train when the pipeline succeeds"
msgstr ""
msgid "mrWidget|Set by %{merge_author} to be merged automatically when the pipeline succeeds"
msgstr ""
msgid "mrWidget|Set by %{merge_author} to start a merge train when the pipeline succeeds"
msgstr "" msgstr ""
msgid "mrWidget|The changes were merged into" msgid "mrWidget|The changes were merged into"
...@@ -39592,15 +39598,6 @@ msgstr "" ...@@ -39592,15 +39598,6 @@ msgstr ""
msgid "mrWidget|into" msgid "mrWidget|into"
msgstr "" msgstr ""
msgid "mrWidget|to be added to the merge train when the pipeline succeeds"
msgstr ""
msgid "mrWidget|to be merged automatically when the pipeline succeeds"
msgstr ""
msgid "mrWidget|to start a merge train when the pipeline succeeds"
msgstr ""
msgid "must be a Debian package" msgid "must be a Debian package"
msgstr "" msgstr ""
......
...@@ -64,7 +64,7 @@ RSpec.describe 'Merge request > User merges when pipeline succeeds', :js do ...@@ -64,7 +64,7 @@ RSpec.describe 'Merge request > User merges when pipeline succeeds', :js do
context 'when enabled after it was previously canceled' do context 'when enabled after it was previously canceled' do
before do before do
click_button "Merge when pipeline succeeds" click_button "Merge when pipeline succeeds"
click_link "Cancel" click_button "Cancel auto-merge"
wait_for_requests wait_for_requests
...@@ -87,7 +87,7 @@ RSpec.describe 'Merge request > User merges when pipeline succeeds', :js do ...@@ -87,7 +87,7 @@ RSpec.describe 'Merge request > User merges when pipeline succeeds', :js do
before do before do
merge_request.merge_params['force_remove_source_branch'] = '0' merge_request.merge_params['force_remove_source_branch'] = '0'
merge_request.save! merge_request.save!
click_link "Cancel" click_button "Cancel auto-merge"
end end
it_behaves_like 'Merge when pipeline succeeds activator' it_behaves_like 'Merge when pipeline succeeds activator'
...@@ -114,7 +114,7 @@ RSpec.describe 'Merge request > User merges when pipeline succeeds', :js do ...@@ -114,7 +114,7 @@ RSpec.describe 'Merge request > User merges when pipeline succeeds', :js do
end end
it 'allows to cancel the automatic merge' do it 'allows to cancel the automatic merge' do
click_link "Cancel" click_button "Cancel auto-merge"
expect(page).to have_button "Merge when pipeline succeeds" expect(page).to have_button "Merge when pipeline succeeds"
...@@ -124,7 +124,7 @@ RSpec.describe 'Merge request > User merges when pipeline succeeds', :js do ...@@ -124,7 +124,7 @@ RSpec.describe 'Merge request > User merges when pipeline succeeds', :js do
end end
it 'allows to delete source branch' do it 'allows to delete source branch' do
click_link "Delete source branch" click_button "Delete source branch"
expect(page).to have_content "The source branch will be deleted" expect(page).to have_content "The source branch will be deleted"
end end
......
...@@ -151,7 +151,7 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request', ...@@ -151,7 +151,7 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request',
context 'when detached merge request pipeline is pending' do context 'when detached merge request pipeline is pending' do
it 'waits the head pipeline' do it 'waits the head pipeline' do
expect(page).to have_content('to be merged automatically when the pipeline succeeds') expect(page).to have_content('to be merged automatically when the pipeline succeeds')
expect(page).to have_link('Cancel') expect(page).to have_button('Cancel auto-merge')
end end
end end
...@@ -178,7 +178,7 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request', ...@@ -178,7 +178,7 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request',
it 'waits the head pipeline' do it 'waits the head pipeline' do
expect(page).to have_content('to be merged automatically when the pipeline succeeds') expect(page).to have_content('to be merged automatically when the pipeline succeeds')
expect(page).to have_link('Cancel') expect(page).to have_button('Cancel auto-merge')
end end
end end
end end
...@@ -377,7 +377,7 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request', ...@@ -377,7 +377,7 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request',
context 'when detached merge request pipeline is pending' do context 'when detached merge request pipeline is pending' do
it 'waits the head pipeline' do it 'waits the head pipeline' do
expect(page).to have_content('to be merged automatically when the pipeline succeeds') expect(page).to have_content('to be merged automatically when the pipeline succeeds')
expect(page).to have_link('Cancel') expect(page).to have_button('Cancel auto-merge')
end end
end end
...@@ -403,7 +403,7 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request', ...@@ -403,7 +403,7 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request',
it 'waits the head pipeline' do it 'waits the head pipeline' do
expect(page).to have_content('to be merged automatically when the pipeline succeeds') expect(page).to have_content('to be merged automatically when the pipeline succeeds')
expect(page).to have_link('Cancel') expect(page).to have_button('Cancel auto-merge')
end end
end end
end end
......
...@@ -4,8 +4,10 @@ exports[`MRWidgetAutoMergeEnabled when graphql is disabled template should have ...@@ -4,8 +4,10 @@ exports[`MRWidgetAutoMergeEnabled when graphql is disabled template should have
<div <div
class="mr-widget-body media" class="mr-widget-body media"
> >
<status-icon-stub <gl-icon-stub
status="success" class="gl-text-blue-500 gl-mr-3 gl-mt-1"
name="status_scheduled"
size="24"
/> />
<div <div
...@@ -17,55 +19,31 @@ exports[`MRWidgetAutoMergeEnabled when graphql is disabled template should have ...@@ -17,55 +19,31 @@ exports[`MRWidgetAutoMergeEnabled when graphql is disabled template should have
<span <span
class="gl-mr-3" class="gl-mr-3"
> >
<span <gl-sprintf-stub
class="js-status-text-before-author" data-testid="statusText"
data-testid="beforeStatusText" message="Set by %{merge_author} to be merged automatically when the pipeline succeeds"
>
Set by
</span>
<mr-widget-author-stub
author="[object Object]"
showauthorname="true"
/> />
<span
class="js-status-text-after-author"
data-testid="afterStatusText"
>
to be merged automatically when the pipeline succeeds
</span>
</span> </span>
<a <gl-button-stub
class="btn btn-sm btn-default js-cancel-auto-merge" buttontextclasses=""
category="primary"
class="js-cancel-auto-merge"
data-qa-selector="cancel_auto_merge_button" data-qa-selector="cancel_auto_merge_button"
data-testid="cancelAutomaticMergeButton" data-testid="cancelAutomaticMergeButton"
href="#" icon=""
role="button" size="small"
variant="default"
> >
<!---->
Cancel Cancel auto-merge
</a> </gl-button-stub>
</h4> </h4>
<section <section
class="mr-info-list" class="mr-info-list"
> >
<p>
The changes will be merged into
<a
class="label-branch"
href="/foo/bar"
>
foo
</a>
</p>
<p <p
class="gl-display-flex" class="gl-display-flex"
> >
...@@ -75,17 +53,19 @@ exports[`MRWidgetAutoMergeEnabled when graphql is disabled template should have ...@@ -75,17 +53,19 @@ exports[`MRWidgetAutoMergeEnabled when graphql is disabled template should have
The source branch will not be deleted The source branch will not be deleted
</span> </span>
<a <gl-button-stub
class="btn btn-sm btn-default js-remove-source-branch" buttontextclasses=""
category="primary"
class="js-remove-source-branch"
data-testid="removeSourceBranchButton" data-testid="removeSourceBranchButton"
href="#" icon=""
role="button" size="small"
variant="default"
> >
<!---->
Delete source branch Delete source branch
</a> </gl-button-stub>
</p> </p>
</section> </section>
</div> </div>
...@@ -96,8 +76,10 @@ exports[`MRWidgetAutoMergeEnabled when graphql is enabled template should have c ...@@ -96,8 +76,10 @@ exports[`MRWidgetAutoMergeEnabled when graphql is enabled template should have c
<div <div
class="mr-widget-body media" class="mr-widget-body media"
> >
<status-icon-stub <gl-icon-stub
status="success" class="gl-text-blue-500 gl-mr-3 gl-mt-1"
name="status_scheduled"
size="24"
/> />
<div <div
...@@ -109,55 +91,31 @@ exports[`MRWidgetAutoMergeEnabled when graphql is enabled template should have c ...@@ -109,55 +91,31 @@ exports[`MRWidgetAutoMergeEnabled when graphql is enabled template should have c
<span <span
class="gl-mr-3" class="gl-mr-3"
> >
<span <gl-sprintf-stub
class="js-status-text-before-author" data-testid="statusText"
data-testid="beforeStatusText" message="Set by %{merge_author} to be merged automatically when the pipeline succeeds"
>
Set by
</span>
<mr-widget-author-stub
author="[object Object]"
showauthorname="true"
/> />
<span
class="js-status-text-after-author"
data-testid="afterStatusText"
>
to be merged automatically when the pipeline succeeds
</span>
</span> </span>
<a <gl-button-stub
class="btn btn-sm btn-default js-cancel-auto-merge" buttontextclasses=""
category="primary"
class="js-cancel-auto-merge"
data-qa-selector="cancel_auto_merge_button" data-qa-selector="cancel_auto_merge_button"
data-testid="cancelAutomaticMergeButton" data-testid="cancelAutomaticMergeButton"
href="#" icon=""
role="button" size="small"
variant="default"
> >
<!---->
Cancel Cancel auto-merge
</a> </gl-button-stub>
</h4> </h4>
<section <section
class="mr-info-list" class="mr-info-list"
> >
<p>
The changes will be merged into
<a
class="label-branch"
href="/foo/bar"
>
foo
</a>
</p>
<p <p
class="gl-display-flex" class="gl-display-flex"
> >
...@@ -167,17 +125,19 @@ exports[`MRWidgetAutoMergeEnabled when graphql is enabled template should have c ...@@ -167,17 +125,19 @@ exports[`MRWidgetAutoMergeEnabled when graphql is enabled template should have c
The source branch will not be deleted The source branch will not be deleted
</span> </span>
<a <gl-button-stub
class="btn btn-sm btn-default js-remove-source-branch" buttontextclasses=""
category="primary"
class="js-remove-source-branch"
data-testid="removeSourceBranchButton" data-testid="removeSourceBranchButton"
href="#" icon=""
role="button" size="small"
variant="default"
> >
<!---->
Delete source branch Delete source branch
</a> </gl-button-stub>
</p> </p>
</section> </section>
</div> </div>
......
...@@ -72,6 +72,8 @@ const defaultMrProps = () => ({ ...@@ -72,6 +72,8 @@ const defaultMrProps = () => ({
autoMergeStrategy: MWPS_MERGE_STRATEGY, autoMergeStrategy: MWPS_MERGE_STRATEGY,
}); });
const getStatusText = () => wrapper.findByTestId('statusText').attributes('message');
describe('MRWidgetAutoMergeEnabled', () => { describe('MRWidgetAutoMergeEnabled', () => {
let oldWindowGl; let oldWindowGl;
...@@ -167,30 +169,6 @@ describe('MRWidgetAutoMergeEnabled', () => { ...@@ -167,30 +169,6 @@ describe('MRWidgetAutoMergeEnabled', () => {
}); });
}); });
describe('statusTextBeforeAuthor', () => {
it('should return "Set by" if the MWPS is selected', () => {
factory({
...defaultMrProps(),
autoMergeStrategy: MWPS_MERGE_STRATEGY,
});
expect(wrapper.findByTestId('beforeStatusText').text()).toBe('Set by');
});
});
describe('statusTextAfterAuthor', () => {
it('should return "to be merged automatically..." if MWPS is selected', () => {
factory({
...defaultMrProps(),
autoMergeStrategy: MWPS_MERGE_STRATEGY,
});
expect(wrapper.findByTestId('afterStatusText').text()).toBe(
'to be merged automatically when the pipeline succeeds',
);
});
});
describe('cancelButtonText', () => { describe('cancelButtonText', () => {
it('should return "Cancel" if MWPS is selected', () => { it('should return "Cancel" if MWPS is selected', () => {
factory({ factory({
...@@ -198,7 +176,9 @@ describe('MRWidgetAutoMergeEnabled', () => { ...@@ -198,7 +176,9 @@ describe('MRWidgetAutoMergeEnabled', () => {
autoMergeStrategy: MWPS_MERGE_STRATEGY, autoMergeStrategy: MWPS_MERGE_STRATEGY,
}); });
expect(wrapper.findByTestId('cancelAutomaticMergeButton').text()).toBe('Cancel'); expect(wrapper.findByTestId('cancelAutomaticMergeButton').text()).toBe(
'Cancel auto-merge',
);
}); });
}); });
}); });
...@@ -279,7 +259,7 @@ describe('MRWidgetAutoMergeEnabled', () => { ...@@ -279,7 +259,7 @@ describe('MRWidgetAutoMergeEnabled', () => {
await nextTick(); await nextTick();
expect(wrapper.find('.js-cancel-auto-merge').attributes('disabled')).toBe('disabled'); expect(wrapper.find('.js-cancel-auto-merge').props('loading')).toBe(true);
}); });
it('should show source branch will be deleted text when it source branch set to remove', () => { it('should show source branch will be deleted text when it source branch set to remove', () => {
...@@ -313,7 +293,7 @@ describe('MRWidgetAutoMergeEnabled', () => { ...@@ -313,7 +293,7 @@ describe('MRWidgetAutoMergeEnabled', () => {
await nextTick(); await nextTick();
expect(wrapper.find('.js-remove-source-branch').attributes('disabled')).toBe('disabled'); expect(wrapper.find('.js-remove-source-branch').props('loading')).toBe(true);
}); });
it('should render the status text as "...to merged automatically" if MWPS is selected', () => { it('should render the status text as "...to merged automatically" if MWPS is selected', () => {
...@@ -322,9 +302,9 @@ describe('MRWidgetAutoMergeEnabled', () => { ...@@ -322,9 +302,9 @@ describe('MRWidgetAutoMergeEnabled', () => {
autoMergeStrategy: MWPS_MERGE_STRATEGY, autoMergeStrategy: MWPS_MERGE_STRATEGY,
}); });
const statusText = trimText(wrapper.find('.js-status-text-after-author').text()); expect(getStatusText()).toBe(
'Set by %{merge_author} to be merged automatically when the pipeline succeeds',
expect(statusText).toBe('to be merged automatically when the pipeline succeeds'); );
}); });
it('should render the cancel button as "Cancel" if MWPS is selected', () => { it('should render the cancel button as "Cancel" if MWPS is selected', () => {
...@@ -335,7 +315,7 @@ describe('MRWidgetAutoMergeEnabled', () => { ...@@ -335,7 +315,7 @@ describe('MRWidgetAutoMergeEnabled', () => {
const cancelButtonText = trimText(wrapper.find('.js-cancel-auto-merge').text()); const cancelButtonText = trimText(wrapper.find('.js-cancel-auto-merge').text());
expect(cancelButtonText).toBe('Cancel'); expect(cancelButtonText).toBe('Cancel auto-merge');
}); });
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment