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 {
<a
href="#modal_merge_info"
data-toggle="modal"
:disabled="mr.sourceBranchRemoved"
class="btn btn-sm inline">
Check out branch
</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', () => {
describe('template', () => {
let vm;
let el;
let mr;
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(() => {
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);
el = vm.$el;
});
......@@ -82,6 +85,8 @@ describe('MRWidgetHeader', () => {
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')[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) => {
......@@ -101,5 +106,16 @@ describe('MRWidgetHeader', () => {
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