aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStas Vilchik <stas.vilchik@sonarsource.com>2018-07-02 13:51:45 +0200
committersonartech <sonartech@sonarsource.com>2018-07-04 09:31:06 +0200
commitdf6860806d152b2873e89e659896ae6de146daea (patch)
tree4385e7cce22c0ff63a4f67031a5abc5aca0e5ab0
parent35acc6b68f1c1a9157483fd129cc8067a6f67311 (diff)
downloadsonarqube-df6860806d152b2873e89e659896ae6de146daea.tar.gz
sonarqube-df6860806d152b2873e89e659896ae6de146daea.zip
SONAR-10973 Modal window stays open after copying quality profile
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.tsx1
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileActions-test.tsx28
2 files changed, 29 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.tsx
index 17dea8322e9..c4b3566803e 100644
--- a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.tsx
+++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.tsx
@@ -88,6 +88,7 @@ export default class ProfileActions extends React.PureComponent<Props, State> {
};
handleProfileCopy = (name: string) => {
+ this.closeCopyForm();
this.props.updateProfiles().then(
() => {
this.context.router.push(
diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileActions-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileActions-test.tsx
index 1b0e0c34ab2..c407c0e64fe 100644
--- a/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileActions-test.tsx
+++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileActions-test.tsx
@@ -20,6 +20,7 @@
import * as React from 'react';
import { shallow } from 'enzyme';
import ProfileActions from '../ProfileActions';
+import { click, waitAndUpdate } from '../../../../helpers/testUtils';
const PROFILE = {
activeRuleCount: 68,
@@ -84,3 +85,30 @@ it('renders with all permissions', () => {
)
).toMatchSnapshot();
});
+
+it('should copy profile', async () => {
+ const updateProfiles = jest.fn(() => Promise.resolve());
+ const push = jest.fn();
+ const wrapper = shallow(
+ <ProfileActions
+ onRequestFail={jest.fn()}
+ organization="org"
+ profile={{ ...PROFILE, actions: { copy: true } }}
+ updateProfiles={updateProfiles}
+ />,
+ { context: { router: { push } } }
+ );
+
+ click(wrapper.find('[id="quality-profile-copy"]'));
+ expect(wrapper.find('CopyProfileForm').exists()).toBe(true);
+
+ wrapper.find('CopyProfileForm').prop<Function>('onCopy')('new-name');
+ expect(updateProfiles).toBeCalled();
+ await waitAndUpdate(wrapper);
+
+ expect(push).toBeCalledWith({
+ pathname: '/organizations/org/quality_profiles/show',
+ query: { language: 'java', name: 'new-name' }
+ });
+ expect(wrapper.find('CopyProfileForm').exists()).toBe(false);
+});