From df6860806d152b2873e89e659896ae6de146daea Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Mon, 2 Jul 2018 13:51:45 +0200 Subject: [PATCH] SONAR-10973 Modal window stays open after copying quality profile --- .../components/ProfileActions.tsx | 1 + .../__tests__/ProfileActions-test.tsx | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+) 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 { }; 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( + , + { context: { router: { push } } } + ); + + click(wrapper.find('[id="quality-profile-copy"]')); + expect(wrapper.find('CopyProfileForm').exists()).toBe(true); + + wrapper.find('CopyProfileForm').prop('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); +}); -- 2.39.5