Commit bbbaab1e authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'fix-create-mr-enabling-button' into 'master'

Fixed create merge request button not enabling

Closes #64454

See merge request gitlab-org/gitlab-ce!30776
parents 9dc41c51 dbc15448
...@@ -182,7 +182,7 @@ export default class CreateMergeRequestDropdown { ...@@ -182,7 +182,7 @@ export default class CreateMergeRequestDropdown {
} }
enable() { enable() {
if (!canCreateConfidentialMergeRequest()) return; if (isConfidentialIssue() && !canCreateConfidentialMergeRequest()) return;
this.createMergeRequestButton.classList.remove('disabled'); this.createMergeRequestButton.classList.remove('disabled');
this.createMergeRequestButton.removeAttribute('disabled'); this.createMergeRequestButton.removeAttribute('disabled');
......
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import CreateMergeRequestDropdown from '~/create_merge_request_dropdown'; import CreateMergeRequestDropdown from '~/create_merge_request_dropdown';
import confidentialState from '~/confidential_merge_request/state';
import { TEST_HOST } from './helpers/test_constants'; import { TEST_HOST } from './helpers/test_constants';
describe('CreateMergeRequestDropdown', () => { describe('CreateMergeRequestDropdown', () => {
...@@ -66,4 +67,37 @@ describe('CreateMergeRequestDropdown', () => { ...@@ -66,4 +67,37 @@ describe('CreateMergeRequestDropdown', () => {
); );
}); });
}); });
describe('enable', () => {
beforeEach(() => {
dropdown.createMergeRequestButton.classList.add('disabled');
});
afterEach(() => {
confidentialState.selectedProject = {};
});
it('enables button when not confidential issue', () => {
dropdown.enable();
expect(dropdown.createMergeRequestButton.classList).not.toContain('disabled');
});
it('enables when can create confidential issue', () => {
document.querySelector('.js-create-mr').setAttribute('data-is-confidential', 'true');
confidentialState.selectedProject = { name: 'test' };
dropdown.enable();
expect(dropdown.createMergeRequestButton.classList).not.toContain('disabled');
});
it('does not enable when can not create confidential issue', () => {
document.querySelector('.js-create-mr').setAttribute('data-is-confidential', 'true');
dropdown.enable();
expect(dropdown.createMergeRequestButton.classList).toContain('disabled');
});
});
}); });
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