diff options
author | Philippe Perrin <philippe.perrin@sonarsource.com> | 2022-03-22 14:03:04 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-03-25 20:02:53 +0000 |
commit | 8ecc599d9bcbee170569b2f11d1ea583f1d2354d (patch) | |
tree | 7658ff733a13a2462913bb0728dcf42c5ac6fa0e /server/sonar-web/src | |
parent | 6f055b4762d71bc42d561974e1c157d5ab036602 (diff) | |
download | sonarqube-8ecc599d9bcbee170569b2f11d1ea583f1d2354d.tar.gz sonarqube-8ecc599d9bcbee170569b2f11d1ea583f1d2354d.zip |
SONAR-16147 Allow users to assign acknowledged Security Hotspots
Diffstat (limited to 'server/sonar-web/src')
3 files changed, 17 insertions, 25 deletions
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<Props, State> { 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 ( <AssigneeRenderer diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/Assignee-test.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/Assignee-test.tsx index 4bf5b33262e..b67579254b7 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/Assignee-test.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/Assignee-test.tsx @@ -24,7 +24,7 @@ import addGlobalSuccessMessage from '../../../../../app/utils/addGlobalSuccessMe import { mockHotspot } from '../../../../../helpers/mocks/security-hotspots'; import { mockCurrentUser, mockUser } from '../../../../../helpers/testMocks'; import { waitAndUpdate } from '../../../../../helpers/testUtils'; -import { HotspotStatus } from '../../../../../types/security-hotspots'; +import { HotspotResolution, HotspotStatus } from '../../../../../types/security-hotspots'; import { UserActive } from '../../../../../types/users'; import { Assignee } from '../Assignee'; import AssigneeRenderer from '../AssigneeRenderer'; @@ -37,9 +37,19 @@ jest.mock('../../../../../app/utils/addGlobalSuccessMessage', () => 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`] = ` -<AssigneeRenderer - assignee={ - Object { - "active": true, - "local": true, - "login": "assignee", - "name": "John Doe", - } - } - canEdit={true} - editing={false} - loading={false} - onAssign={[Function]} - onEnterEditionMode={[Function]} - onExitEditionMode={[Function]} -/> -`; |