Commit 0f000716 authored by Jacopo's avatar Jacopo

Disable MR check out button when source branch is deleted

After source branch deletion the Merge request `Check out branch` button is disabled.
parent 092a34fe
...@@ -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,20 +48,23 @@ describe('MRWidgetHeader', () => { ...@@ -48,20 +48,23 @@ 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 = {
divergedCommitsCount: 12,
sourceBranch: 'mr-widget-refactor',
sourceBranchLink: `<a href="${sourceBranchPath}">mr-widget-refactor</a>`,
targetBranchPath: 'foo/bar/commits-path',
targetBranchTreePath: 'foo/bar/tree/path',
targetBranch: 'master',
isOpen: true,
emailPatchesPath: '/mr/email-patches',
plainDiffPath: '/mr/plainDiffPath',
};
beforeEach(() => { beforeEach(() => {
mr = {
divergedCommitsCount: 12,
sourceBranch: 'mr-widget-refactor',
sourceBranchLink: `<a href="${sourceBranchPath}">mr-widget-refactor</a>`,
sourceBranchRemoved: false,
targetBranchPath: 'foo/bar/commits-path',
targetBranchTreePath: 'foo/bar/tree/path',
targetBranch: 'master',
isOpen: true,
emailPatchesPath: '/mr/email-patches',
plainDiffPath: '/mr/plainDiffPath',
};
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