]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10973 Modal window stays open after copying quality profile
authorStas Vilchik <stas.vilchik@sonarsource.com>
Mon, 2 Jul 2018 11:51:45 +0000 (13:51 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 4 Jul 2018 07:31:06 +0000 (09:31 +0200)
server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.tsx
server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileActions-test.tsx

index 17dea8322e907e55ee01c726c8b6d7f535b79692..c4b3566803e1c4a3233086254388b3871a2e4d27 100644 (file)
@@ -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(
index 1b0e0c34ab2c6708066ae4c986ee2bc1f3b9f65a..c407c0e64fe6bc70260092cd47d4d4566a45d243 100644 (file)
@@ -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);
+});