aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web
diff options
context:
space:
mode:
authorStas Vilchik <stas.vilchik@sonarsource.com>2018-03-06 10:18:04 +0100
committerGitHub <noreply@github.com>2018-03-06 10:18:04 +0100
commit321d6082dc978b1f50bf50d0638110d83e07e545 (patch)
tree024561d4ffe77f13aa473387dc3cf049d4295c70 /server/sonar-web
parent59c992d35dc045d829ef82a592e2576e98873467 (diff)
downloadsonarqube-321d6082dc978b1f50bf50d0638110d83e07e545.tar.gz
sonarqube-321d6082dc978b1f50bf50d0638110d83e07e545.zip
fix application leak tooltip (#3117)
Diffstat (limited to 'server/sonar-web')
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/__tests__/ApplicationLeakPeriodLegend-test.tsx21
2 files changed, 15 insertions, 8 deletions
diff --git a/server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx b/server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx
index 55d8c5082ce..6045dd6871d 100644
--- a/server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx
@@ -50,7 +50,7 @@ export default class ApplicationLeakPeriodLegend extends React.Component<Props,
}
fetchLeaks = (visible: boolean) => {
- if (visible && this.state.leaks) {
+ if (visible && !this.state.leaks) {
getApplicationLeak(this.props.component).then(
leaks => {
if (this.mounted) {
diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/ApplicationLeakPeriodLegend-test.tsx b/server/sonar-web/src/main/js/apps/overview/components/__tests__/ApplicationLeakPeriodLegend-test.tsx
index ee95828e890..42b2caeb249 100644
--- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/ApplicationLeakPeriodLegend-test.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/ApplicationLeakPeriodLegend-test.tsx
@@ -20,15 +20,22 @@
import * as React from 'react';
import { shallow } from 'enzyme';
import ApplicationLeakPeriodLegend from '../ApplicationLeakPeriodLegend';
+import { waitAndUpdate } from '../../../../helpers/testUtils';
-it('renders', () => {
- const wrapper = shallow(<ApplicationLeakPeriodLegend component="foo" />);
- expect(wrapper).toMatchSnapshot();
- wrapper.setState({
- leaks: [
+jest.mock('../../../../api/application', () => ({
+ getApplicationLeak: jest.fn(() =>
+ Promise.resolve([
{ date: '2017-01-01T11:39:03+0100', project: 'foo', projectName: 'Foo' },
{ date: '2017-02-01T11:39:03+0100', project: 'bar', projectName: 'Bar' }
- ]
- });
+ ])
+ )
+}));
+
+it('renders', async () => {
+ const wrapper = shallow(<ApplicationLeakPeriodLegend component="foo" />);
+ expect(wrapper).toMatchSnapshot();
+
+ wrapper.find('Tooltip').prop<Function>('onVisibleChange')(true);
+ await waitAndUpdate(wrapper);
expect(wrapper).toMatchSnapshot();
});