Commit a5a91d7e authored by Fatih Acet's avatar Fatih Acet

Merge branch '42255-disable-mr-checkout-button-when-source-branch-deleted' into 'master'

Resolve "MR "Check out branch" button should be disabled when the source branch is deleted"

Closes #42255

See merge request gitlab-org/gitlab-ce!16631
parents 44fceaf8 0f000716
...@@ -76,6 +76,7 @@ export default { ...@@ -76,6 +76,7 @@ export default {
<a <a
href="#modal_merge_info" href="#modal_merge_info"
data-toggle="modal" data-toggle="modal"
:disabled="mr.sourceBranchRemoved"
class="btn btn-sm inline"> class="btn btn-sm inline">
Check out branch Check out branch
</a> </a>
......
---
title: Disable MR check out button when source branch is deleted
merge_request: 16631
author: Jacopo Beschi @jacopo-beschi
type: fixed
...@@ -48,11 +48,15 @@ describe('MRWidgetHeader', () => { ...@@ -48,11 +48,15 @@ describe('MRWidgetHeader', () => {
describe('template', () => { describe('template', () => {
let vm; let vm;
let el; let el;
let mr;
const sourceBranchPath = '/foo/bar/mr-widget-refactor'; const sourceBranchPath = '/foo/bar/mr-widget-refactor';
const mr = {
beforeEach(() => {
mr = {
divergedCommitsCount: 12, divergedCommitsCount: 12,
sourceBranch: 'mr-widget-refactor', sourceBranch: 'mr-widget-refactor',
sourceBranchLink: `<a href="${sourceBranchPath}">mr-widget-refactor</a>`, sourceBranchLink: `<a href="${sourceBranchPath}">mr-widget-refactor</a>`,
sourceBranchRemoved: false,
targetBranchPath: 'foo/bar/commits-path', targetBranchPath: 'foo/bar/commits-path',
targetBranchTreePath: 'foo/bar/tree/path', targetBranchTreePath: 'foo/bar/tree/path',
targetBranch: 'master', targetBranch: 'master',
...@@ -61,7 +65,6 @@ describe('MRWidgetHeader', () => { ...@@ -61,7 +65,6 @@ describe('MRWidgetHeader', () => {
plainDiffPath: '/mr/plainDiffPath', plainDiffPath: '/mr/plainDiffPath',
}; };
beforeEach(() => {
vm = createComponent(mr); vm = createComponent(mr);
el = vm.$el; el = vm.$el;
}); });
...@@ -82,6 +85,8 @@ describe('MRWidgetHeader', () => { ...@@ -82,6 +85,8 @@ describe('MRWidgetHeader', () => {
expect(el.textContent).toContain('Check out branch'); expect(el.textContent).toContain('Check out branch');
expect(el.querySelectorAll('.dropdown li a')[0].getAttribute('href')).toEqual(mr.emailPatchesPath); expect(el.querySelectorAll('.dropdown li a')[0].getAttribute('href')).toEqual(mr.emailPatchesPath);
expect(el.querySelectorAll('.dropdown li a')[1].getAttribute('href')).toEqual(mr.plainDiffPath); expect(el.querySelectorAll('.dropdown li a')[1].getAttribute('href')).toEqual(mr.plainDiffPath);
expect(el.querySelector('a[href="#modal_merge_info"]').getAttribute('disabled')).toBeNull();
}); });
it('should not have right action links if the MR state is not open', (done) => { it('should not have right action links if the MR state is not open', (done) => {
...@@ -101,5 +106,16 @@ describe('MRWidgetHeader', () => { ...@@ -101,5 +106,16 @@ describe('MRWidgetHeader', () => {
done(); done();
}); });
}); });
it('should disable check out branch button if source branch has been removed', (done) => {
vm.mr.sourceBranchRemoved = true;
Vue.nextTick()
.then(() => {
expect(el.querySelector('a[href="#modal_merge_info"]').getAttribute('disabled')).toBe('disabled');
done();
})
.catch(done.fail);
});
}); });
}); });
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