From 8ecc599d9bcbee170569b2f11d1ea583f1d2354d Mon Sep 17 00:00:00 2001 From: Philippe Perrin Date: Tue, 22 Mar 2022 14:03:04 +0100 Subject: SONAR-16147 Allow users to assign acknowledged Security Hotspots --- .../components/assignee/Assignee.tsx | 7 ++++--- .../components/assignee/__tests__/Assignee-test.tsx | 16 +++++++++++++--- .../__tests__/__snapshots__/Assignee-test.tsx.snap | 19 ------------------- 3 files changed, 17 insertions(+), 25 deletions(-) (limited to 'server/sonar-web/src') diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/Assignee.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/Assignee.tsx index 89a43531b3b..51f34af34bc 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/Assignee.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/Assignee.tsx @@ -22,7 +22,7 @@ import { assignSecurityHotspot } from '../../../../api/security-hotspots'; import withCurrentUserContext from '../../../../app/components/current-user/withCurrentUserContext'; import addGlobalSuccessMessage from '../../../../app/utils/addGlobalSuccessMessage'; import { translate, translateWithParameters } from '../../../../helpers/l10n'; -import { Hotspot, HotspotStatus } from '../../../../types/security-hotspots'; +import { Hotspot, HotspotResolution, HotspotStatus } from '../../../../types/security-hotspots'; import { CurrentUser, isLoggedIn, UserActive } from '../../../../types/users'; import AssigneeRenderer from './AssigneeRenderer'; @@ -85,11 +85,12 @@ export class Assignee extends React.PureComponent { render() { const { currentUser, - hotspot: { assigneeUser, status } + hotspot: { assigneeUser, status, resolution } } = this.props; const { editing, loading } = this.state; - const canEdit = status === HotspotStatus.TO_REVIEW; + const canEdit = + status === HotspotStatus.TO_REVIEW || resolution === HotspotResolution.ACKNOWLEDGED; return ( jest.fn()); it('should render correctly', () => { expect(shallowRender()).toMatchSnapshot(); +}); + +it.each([ + [HotspotStatus.TO_REVIEW, undefined, true], + [HotspotStatus.REVIEWED, HotspotResolution.FIXED, false], + [HotspotStatus.REVIEWED, HotspotResolution.SAFE, false], + [HotspotStatus.REVIEWED, HotspotResolution.ACKNOWLEDGED, true] +])('should allow edition properly', (status, resolution, canEdit) => { expect( - shallowRender({ hotspot: mockHotspot({ status: HotspotStatus.TO_REVIEW }) }) - ).toMatchSnapshot('can edit'); + shallowRender({ hotspot: mockHotspot({ status, resolution }) }) + .find(AssigneeRenderer) + .props().canEdit + ).toBe(canEdit); }); it('should handle edition event correctly', () => { diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/__snapshots__/Assignee-test.tsx.snap b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/__snapshots__/Assignee-test.tsx.snap index 1cb486f7a56..1b919702f03 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/__snapshots__/Assignee-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/__snapshots__/Assignee-test.tsx.snap @@ -18,22 +18,3 @@ exports[`should render correctly 1`] = ` onExitEditionMode={[Function]} /> `; - -exports[`should render correctly: can edit 1`] = ` - -`; -- cgit v1.2.3