From: Pascal Mugnier Date: Mon, 22 Oct 2018 13:45:02 +0000 (+0200) Subject: SONAR-11371 Change the banner text with rules missing info X-Git-Tag: 7.5~235 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a8634266cf554b4679544e9842d726f0b3771a81;p=sonarqube.git SONAR-11371 Change the banner text with rules missing info --- diff --git a/server/sonar-web/src/main/js/apps/securityReports/components/App.tsx b/server/sonar-web/src/main/js/apps/securityReports/components/App.tsx index 025b661e649..7f7bc9b1790 100755 --- a/server/sonar-web/src/main/js/apps/securityReports/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/securityReports/components/App.tsx @@ -125,6 +125,44 @@ export default class App extends React.PureComponent { this.setState({ showCWE: checked }, this.fetchSecurityHotspots); }; + renderAdditionalRulesMessage = () => { + const { component } = this.props; + const { findings, type } = this.state; + if (findings.length === 0) { + return null; + } + + const total = findings.map(f => f.totalRules).reduce((sum, count) => sum + count); + const active = findings.map(f => f.activeRules).reduce((sum, count) => sum + count); + if (active === total) { + return null; + } + + const standard = translate('security_reports', type, 'page'); + return ( +
+ + {translate('security_reports.info.link')} + + ), + standard, + total: total - active + }} + /> +
+ ); + }; + render() { const { branchLike, component, params } = this.props; const { loading, findings, showCWE, type } = this.state; @@ -145,24 +183,7 @@ export default class App extends React.PureComponent { to={{ pathname: '/documentation/user-guide/security-reports/' }}> {translate('learn_more')} -
- - {translate('security_reports.info.link')} - - ) - }} - /> -
+ {this.renderAdditionalRulesMessage()}
diff --git a/server/sonar-web/src/main/js/apps/securityReports/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/securityReports/components/__tests__/App-test.tsx index cdc43e9abdf..61c8f980517 100644 --- a/server/sonar-web/src/main/js/apps/securityReports/components/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/securityReports/components/__tests__/App-test.tsx @@ -60,6 +60,16 @@ jest.mock('../../../../api/security-reports', () => ({ toReviewSecurityHotspots: 8, openSecurityHotspots: 100, wontFixSecurityHotspots: 10 + }, + { + activeRules: 0, + totalRules: 1, + category: 'a3', + vulnerabilities: 3, + vulnerabiliyRating: 3, + toReviewSecurityHotspots: 8, + openSecurityHotspots: 100, + wontFixSecurityHotspots: 10 } ] }); @@ -94,10 +104,11 @@ it('renders error on wrong type parameters', () => { expect(wrapper).toMatchSnapshot(); }); -it('renders owaspTop10', () => { +it('renders owaspTop10', async () => { const wrapper = shallow(, { context }); + await waitAndUpdate(wrapper); expect(getSecurityHotspots).toBeCalledWith({ project: 'foo', standard: 'owaspTop10', diff --git a/server/sonar-web/src/main/js/apps/securityReports/components/__tests__/__snapshots__/App-test.tsx.snap b/server/sonar-web/src/main/js/apps/securityReports/components/__tests__/__snapshots__/App-test.tsx.snap index 840caeee3a1..7f23c59af71 100644 --- a/server/sonar-web/src/main/js/apps/securityReports/components/__tests__/__snapshots__/App-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/securityReports/components/__tests__/__snapshots__/App-test.tsx.snap @@ -38,33 +38,6 @@ exports[`handle checkbox for cwe display 1`] = ` > learn_more -
- - security_reports.info.link - , - } - } - /> -
security_reports.info.link , + "standard": "security_reports.owaspTop10.page", + "total": 1, } } /> @@ -252,6 +227,16 @@ exports[`handle checkbox for cwe display 2`] = ` "vulnerabiliyRating": 3, "wontFixSecurityHotspots": 10, }, + Object { + "activeRules": 0, + "category": "a3", + "openSecurityHotspots": 100, + "toReviewSecurityHotspots": 8, + "totalRules": 1, + "vulnerabilities": 3, + "vulnerabiliyRating": 3, + "wontFixSecurityHotspots": 10, + }, ] } showCWE={true} @@ -328,6 +313,8 @@ exports[`renders owaspTop10 1`] = ` > security_reports.info.link , + "standard": "security_reports.owaspTop10.page", + "total": 1, } } /> @@ -340,7 +327,7 @@ exports[`renders owaspTop10 1`] = `
@@ -415,33 +453,6 @@ exports[`renders sansTop25 1`] = ` > learn_more -
- - security_reports.info.link - , - } - } - /> -
learn_more -
- - security_reports.info.link - , - } - } - /> -