From: Jeremy Davis Date: Mon, 27 May 2019 09:33:34 +0000 (+0200) Subject: SONAR-11676 Fix Bulk Apply Permission Template X-Git-Tag: 7.8~125 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=30edd004be7d356a446735766d7edb9c4ef6cbc1;p=sonarqube.git SONAR-11676 Fix Bulk Apply Permission Template --- diff --git a/server/sonar-web/src/main/js/apps/create/components/__tests__/ProjectKeyInput-test.tsx b/server/sonar-web/src/main/js/apps/create/components/__tests__/ProjectKeyInput-test.tsx index 4b47eaef943..14a4b9c33b0 100644 --- a/server/sonar-web/src/main/js/apps/create/components/__tests__/ProjectKeyInput-test.tsx +++ b/server/sonar-web/src/main/js/apps/create/components/__tests__/ProjectKeyInput-test.tsx @@ -59,3 +59,29 @@ it('should have an error when the key already exists', async () => { await new Promise(setImmediate); expect(wrapper.find('ValidationInput').prop('isInvalid')).toBe(true); }); + +it('should handle Change', async () => { + const onChange = jest.fn(); + const wrapper = shallow(); + await waitAndUpdate(wrapper); + + wrapper.find('input').simulate('change', { currentTarget: { value: 'key' } }); + + expect(wrapper.state('touched')).toBe(true); + expect(onChange).toBeCalledWith('key'); +}); + +it('should ignore promise return if value has been changed in the meantime', async () => { + const onChange = (value: string) => wrapper.setProps({ value }); + const wrapper = shallow(); + await waitAndUpdate(wrapper); + + wrapper.find('input').simulate('change', { currentTarget: { value: 'exists' } }); + wrapper.find('input').simulate('change', { currentTarget: { value: 'exists%' } }); + + jest.runAllTimers(); + await new Promise(setImmediate); + + expect(wrapper.state('touched')).toBe(true); + expect(wrapper.state('error')).toBe('onboarding.create_project.project_key.error'); +}); diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/BulkApplyTemplateModal.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/BulkApplyTemplateModal.tsx index 495fe5e077d..e3c32aa20e4 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/BulkApplyTemplateModal.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/BulkApplyTemplateModal.tsx @@ -88,6 +88,7 @@ export default class BulkApplyTemplateModal extends React.PureComponent { }); it('bulk applies template to selected results', async () => { - const wrapper = shallow(render({ selection: ['proj1', 'proj2'] })); + const wrapper = shallow(render({ qualifier: 'VW', selection: ['proj1', 'proj2'] })); (wrapper.instance() as BulkApplyTemplateModal).mounted = true; expect(wrapper).toMatchSnapshot(); @@ -88,6 +88,7 @@ it('bulk applies template to selected results', async () => { expect(bulkApplyTemplate).toBeCalledWith({ organization: 'org', projects: 'proj1,proj2', + qualifiers: 'VW', templateId: 'foo' }); diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx index 9a8a57bf77d..3b3eb4786da 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx @@ -73,8 +73,9 @@ export default class SourceViewerHeader extends React.PureComponent { const { branchLike, issues, sourceViewerFile } = this.props; - if (issues && issues.length > 0) { - return ( + return ( + issues && + issues.length > 0 && ( <>
@@ -101,8 +102,8 @@ export default class SourceViewerHeader extends React.PureComponent - ); - } + ) + ); }; render() {